WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-225286-20210503163846.patch (text/plain), 42.25 KB, created by
Sam Weinig
on 2021-05-03 16:38:47 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sam Weinig
Created:
2021-05-03 16:38:47 PDT
Size:
42.25 KB
patch
obsolete
>Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 276929) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,15 @@ >+2021-05-02 Sam Weinig <weinig@apple.com> >+ >+ Add preliminary support for specifying a color space for 2D canvas >+ https://bugs.webkit.org/show_bug.cgi?id=225286 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add new experimental feature, CanvasColorSpaceEnabled, which blocks >+ access to the new ability to specify color spaces for 2D canvas. >+ >+ * Scripts/Preferences/WebPreferencesExperimental.yaml: >+ > 2021-05-03 Chris Dumez <cdumez@apple.com> > > Unreviewed attempt to fix JSCOnly build with recent clang after r276879 >Index: Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml >=================================================================== >--- Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (revision 276929) >+++ Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (working copy) >@@ -245,6 +245,18 @@ CSSTypedOMEnabled: > "ENABLE(EXPERIMENTAL_FEATURES) && (PLATFORM(GTK) || PLATFORM(WPE))": true > default: false > >+CanvasColorSpaceEnabled: >+ type: bool >+ humanReadableName: "Canvas Color Spaces" >+ humanReadableDescription: "Enable use of predefined canvas color spaces" >+ defaultValue: >+ WebKitLegacy: >+ default: false >+ WebKit: >+ default: false >+ WebCore: >+ default: false >+ > CaptureVideoInGPUProcessEnabled: > type: bool > humanReadableName: "GPU Process: Video Capture" >Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 276929) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,84 @@ >+2021-05-03 Sam Weinig <weinig@apple.com> >+ >+ Add preliminary support for specifying a color space for 2D canvas >+ https://bugs.webkit.org/show_bug.cgi?id=225286 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html >+ fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html >+ fast/canvas/canvas-color-space-display-p3.html >+ >+ * CMakeLists.txt: >+ * DerivedSources-input.xcfilelist: >+ * DerivedSources-output.xcfilelist: >+ * DerivedSources.make: >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ Add new files. >+ >+ * html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl: Added. >+ * html/canvas/CanvasRenderingContext2DSettings.h: >+ Add a new setting blocked member to the CanvasRenderingContext2DSettings >+ dictionary for specifying a color space. >+ >+ * html/canvas/PredefinedColorSpace.cpp: Added. >+ * html/canvas/PredefinedColorSpace.h: Added. >+ * html/canvas/PredefinedColorSpace.idl: Added. >+ Add a new IDL enumeration to represent the possible color spaces supported. >+ For ports that don't support DisplayP3, trying to use it will result in >+ type error from JS. >+ >+ * html/HTMLCanvasElement.cpp: >+ (WebCore::HTMLCanvasElement::reset): >+ Add checks for color space and pixel format to 2d context reset optimation. >+ This can happen if the image buffer is allocated prior to the context being >+ requested (such as via canvas.toDataURL() or canvas.toBlob()). >+ >+ (WebCore::HTMLCanvasElement::createImageBuffer const): >+ Pass the correct color space and pixel format (though >+ the later is always BGRA8 at the moment) to the ImageBuffer >+ create function to make a backing store in the right format. >+ >+ * html/HTMLVideoElement.cpp: >+ (WebCore::HTMLVideoElement::createBufferForPainting const): >+ * html/HTMLVideoElement.h: >+ Pass color space and pixel format through to ensure the helper >+ buffer matches the correct color space. >+ >+ * html/ImageBitmap.cpp: >+ (WebCore::ImageBitmap::createPromise): >+ Pass the existing defaults to HTMLVideoElement::createBufferForPainting. >+ In the future, ImageBitmap will also gain color space and pixel >+ format specificity and this will be updated. >+ >+ * html/canvas/CanvasRenderingContext.cpp: >+ (WebCore::CanvasRenderingContext::pixelFormat const): >+ (WebCore::CanvasRenderingContext::colorSpace const): >+ * html/canvas/CanvasRenderingContext.h: >+ Add virtual base implementations of colorSpace and pixelFormat >+ which CanvasRenderingContext2D can override to return the >+ values specified in the CanvasRenderingContext2DSettings. >+ >+ * html/canvas/CanvasRenderingContext2D.h: >+ * html/canvas/CanvasRenderingContext2D.cpp: >+ (WebCore::CanvasRenderingContext2D::fontProxy const): >+ Fix incorrect formatting. >+ >+ (WebCore::CanvasRenderingContext2D::pixelFormat const): >+ (WebCore::CanvasRenderingContext2D::colorSpace const): >+ Add overrides, return m_settings.colorSpace for colorSpace. >+ >+ * html/canvas/CanvasRenderingContext2DBase.cpp: >+ (WebCore::CanvasRenderingContext2DBase::drawImage): >+ (WebCore::CanvasRenderingContext2DBase::createCompositingBuffer): >+ (WebCore::CanvasRenderingContext2DBase::createPattern): >+ (WebCore::CanvasRenderingContext2DBase::drawTextUnchecked): >+ Pass along the colorSpace and pixelFormat when creating buffers. >+ >+ * html/shadow/DateTimeSymbolicFieldElement.cpp: >+ Add missing includes that are now needed. >+ > 2021-05-03 Aditya Keerthi <akeerthi@apple.com> > > [iOS][FCR] Missing fill color on slider ticks >Index: Source/WebCore/CMakeLists.txt >=================================================================== >--- Source/WebCore/CMakeLists.txt (revision 276929) >+++ Source/WebCore/CMakeLists.txt (working copy) >@@ -1052,6 +1052,7 @@ set(WebCore_NON_SVG_IDL_FILES > html/canvas/CanvasPattern.idl > html/canvas/CanvasRect.idl > html/canvas/CanvasRenderingContext2D.idl >+ html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl > html/canvas/CanvasRenderingContext2DSettings.idl > html/canvas/CanvasShadowStyles.idl > html/canvas/CanvasState.idl >@@ -1067,6 +1068,7 @@ set(WebCore_NON_SVG_IDL_FILES > html/canvas/OffscreenCanvasRenderingContext2D.idl > html/canvas/PaintRenderingContext2D.idl > html/canvas/Path2D.idl >+ html/canvas/PredefinedColorSpace.idl > > html/track/AudioTrack.idl > html/track/AudioTrackList.idl >Index: Source/WebCore/DerivedSources-input.xcfilelist >=================================================================== >--- Source/WebCore/DerivedSources-input.xcfilelist (revision 276929) >+++ Source/WebCore/DerivedSources-input.xcfilelist (working copy) >@@ -1065,6 +1065,7 @@ $(PROJECT_DIR)/html/canvas/CanvasPathDra > $(PROJECT_DIR)/html/canvas/CanvasPattern.idl > $(PROJECT_DIR)/html/canvas/CanvasRect.idl > $(PROJECT_DIR)/html/canvas/CanvasRenderingContext2D.idl >+$(PROJECT_DIR)/html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl > $(PROJECT_DIR)/html/canvas/CanvasRenderingContext2DSettings.idl > $(PROJECT_DIR)/html/canvas/CanvasShadowStyles.idl > $(PROJECT_DIR)/html/canvas/CanvasState.idl >@@ -1098,6 +1099,7 @@ $(PROJECT_DIR)/html/canvas/OESVertexArra > $(PROJECT_DIR)/html/canvas/OffscreenCanvasRenderingContext2D.idl > $(PROJECT_DIR)/html/canvas/PaintRenderingContext2D.idl > $(PROJECT_DIR)/html/canvas/Path2D.idl >+$(PROJECT_DIR)/html/canvas/PredefinedColorSpace.idl > $(PROJECT_DIR)/html/canvas/WebGL2RenderingContext.idl > $(PROJECT_DIR)/html/canvas/WebGLActiveInfo.idl > $(PROJECT_DIR)/html/canvas/WebGLBuffer.idl >Index: Source/WebCore/DerivedSources-output.xcfilelist >=================================================================== >--- Source/WebCore/DerivedSources-output.xcfilelist (revision 276929) >+++ Source/WebCore/DerivedSources-output.xcfilelist (working copy) >@@ -361,6 +361,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/Web > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRect.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2D.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2D.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2DSettings+ColorSpace.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2DSettings+ColorSpace.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2DSettings.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasRenderingContext2DSettings.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSCanvasShadowStyles.cpp >@@ -1642,6 +1644,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/Web > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPositionOptions.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPostMessageOptions.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPostMessageOptions.h >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPredefinedColorSpace.cpp >+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSPredefinedColorSpace.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProcessingInstruction.cpp > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProcessingInstruction.h > $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSProgressEvent.cpp >Index: Source/WebCore/DerivedSources.make >=================================================================== >--- Source/WebCore/DerivedSources.make (revision 276929) >+++ Source/WebCore/DerivedSources.make (working copy) >@@ -926,6 +926,7 @@ JS_BINDING_IDLS := \ > $(WebCore)/html/canvas/CanvasPattern.idl \ > $(WebCore)/html/canvas/CanvasRect.idl \ > $(WebCore)/html/canvas/CanvasRenderingContext2D.idl \ >+ $(WebCore)/html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl \ > $(WebCore)/html/canvas/CanvasRenderingContext2DSettings.idl \ > $(WebCore)/html/canvas/CanvasShadowStyles.idl \ > $(WebCore)/html/canvas/CanvasState.idl \ >@@ -959,6 +960,7 @@ JS_BINDING_IDLS := \ > $(WebCore)/html/canvas/OffscreenCanvasRenderingContext2D.idl \ > $(WebCore)/html/canvas/PaintRenderingContext2D.idl \ > $(WebCore)/html/canvas/Path2D.idl \ >+ $(WebCore)/html/canvas/PredefinedColorSpace.idl \ > $(WebCore)/html/canvas/WebGL2RenderingContext.idl \ > $(WebCore)/html/canvas/WebGLActiveInfo.idl \ > $(WebCore)/html/canvas/WebGLBuffer.idl \ >Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 276929) >+++ Source/WebCore/Sources.txt (working copy) >@@ -1344,6 +1344,7 @@ html/canvas/OffscreenCanvasRenderingCont > html/canvas/PaintRenderingContext2D.cpp > html/canvas/Path2D.cpp > html/canvas/PlaceholderRenderingContext.cpp >+html/canvas/PredefinedColorSpace.cpp > html/canvas/WebGL2RenderingContext.cpp > html/canvas/WebGLBuffer.cpp > html/canvas/WebGLColorBufferFloat.cpp >@@ -3367,6 +3368,7 @@ JSPositionCallback.cpp > JSPositionErrorCallback.cpp > JSPositionOptions.cpp > JSPostMessageOptions.cpp >+JSPredefinedColorSpace.cpp > JSProcessingInstruction.cpp > JSProgressEvent.cpp > JSPromiseRejectionEvent.cpp >Index: Source/WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/WebCore/WebCore.xcodeproj/project.pbxproj (revision 276929) >+++ Source/WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -14315,6 +14315,10 @@ > BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScheduledAction.cpp; sourceTree = "<group>"; }; > BCA378BB0D15F64200B793D6 /* ScheduledAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScheduledAction.h; sourceTree = "<group>"; }; > BCA55912263DBD79007F19B3 /* PixelFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PixelFormat.h; sourceTree = "<group>"; }; >+ BCA5591A263F10B9007F19B3 /* PredefinedColorSpace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PredefinedColorSpace.h; sourceTree = "<group>"; }; >+ BCA5591C263F10B9007F19B3 /* PredefinedColorSpace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PredefinedColorSpace.idl; sourceTree = "<group>"; }; >+ BCA5591D263F10B9007F19B3 /* PredefinedColorSpace.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PredefinedColorSpace.cpp; sourceTree = "<group>"; }; >+ BCA5591F263F10F1007F19B3 /* CanvasRenderingContext2DSettings+ColorSpace.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "CanvasRenderingContext2DSettings+ColorSpace.idl"; sourceTree = "<group>"; }; > BCA83E360D7CDC4E003421A8 /* DataTransfer.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DataTransfer.idl; sourceTree = "<group>"; }; > BCA83E4D0D7CE1E9003421A8 /* JSDataTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataTransfer.cpp; sourceTree = "<group>"; }; > BCA83E4E0D7CE1E9003421A8 /* JSDataTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataTransfer.h; sourceTree = "<group>"; }; >@@ -20100,6 +20104,7 @@ > 3140C5221FDF318600D2A873 /* CanvasRenderingContext2DBase.h */, > BCE0490C263A2F1C009DCBB8 /* CanvasRenderingContext2DSettings.h */, > BCE0490E263A2F1C009DCBB8 /* CanvasRenderingContext2DSettings.idl */, >+ BCA5591F263F10F1007F19B3 /* CanvasRenderingContext2DSettings+ColorSpace.idl */, > 7C193BAD1F5E0EB30088F3E6 /* CanvasShadowStyles.idl */, > 7C193BB21F5E0EB60088F3E6 /* CanvasState.idl */, > 49484FBF102CF23C00187DD3 /* CanvasStyle.cpp */, >@@ -20186,6 +20191,9 @@ > 7C193BB41F5E0EB70088F3E6 /* Path2D.idl */, > 7C7903BA1F86FF3300463A70 /* PlaceholderRenderingContext.cpp */, > 7C7903BC1F86FF3400463A70 /* PlaceholderRenderingContext.h */, >+ BCA5591D263F10B9007F19B3 /* PredefinedColorSpace.cpp */, >+ BCA5591A263F10B9007F19B3 /* PredefinedColorSpace.h */, >+ BCA5591C263F10B9007F19B3 /* PredefinedColorSpace.idl */, > D3F3D35B1A69A5060059FC2B /* WebGL2RenderingContext.cpp */, > D3F3D35C1A69A5060059FC2B /* WebGL2RenderingContext.h */, > D3F3D35D1A69A5060059FC2B /* WebGL2RenderingContext.idl */, >Index: Source/WebCore/html/HTMLCanvasElement.cpp >=================================================================== >--- Source/WebCore/html/HTMLCanvasElement.cpp (revision 276929) >+++ Source/WebCore/html/HTMLCanvasElement.cpp (working copy) >@@ -608,7 +608,7 @@ void HTMLCanvasElement::reset() > IntSize newSize(w, h); > // If the size of an existing buffer matches, we can just clear it instead of reallocating. > // This optimization is only done for 2D canvases for now. >- if (m_hasCreatedImageBuffer && oldSize == newSize && m_context && m_context->is2d()) { >+ if (m_hasCreatedImageBuffer && oldSize == newSize && m_context && m_context->is2d() && m_context->colorSpace() == buffer()->colorSpace() && m_context->pixelFormat() == buffer()->pixelFormat()) { > if (!m_didClearImageBuffer) > clearImageBuffer(); > return; >@@ -943,7 +943,15 @@ void HTMLCanvasElement::createImageBuffe > auto renderingMode = shouldAccelerate(size()) ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; > // FIXME: Add a new setting for DisplayList drawing on canvas. > auto useDisplayList = m_usesDisplayListDrawing.valueOr(document().settings().displayListDrawingEnabled()) ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No; >- setImageBuffer(ImageBuffer::create(size(), renderingMode, useDisplayList, RenderingPurpose::Canvas, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8, hostWindow)); >+ >+ auto [colorSpace, pixelFormat] = [&] { >+ if (m_context) >+ return std::pair { m_context->colorSpace(), m_context->pixelFormat() }; >+ else >+ return std::pair { DestinationColorSpace::SRGB, PixelFormat::BGRA }; >+ }(); >+ >+ setImageBuffer(ImageBuffer::create(size(), renderingMode, useDisplayList, RenderingPurpose::Canvas, 1, colorSpace, pixelFormat, hostWindow)); > > if (buffer() && buffer()->drawingContext()) > buffer()->drawingContext()->setTracksDisplayListReplay(m_tracksDisplayListReplay); >Index: Source/WebCore/html/HTMLVideoElement.cpp >=================================================================== >--- Source/WebCore/html/HTMLVideoElement.cpp (revision 276929) >+++ Source/WebCore/html/HTMLVideoElement.cpp (working copy) >@@ -281,11 +281,11 @@ void HTMLVideoElement::mediaPlayerFirstV > renderer->updateFromElement(); > } > >-RefPtr<ImageBuffer> HTMLVideoElement::createBufferForPainting(const FloatSize& size, RenderingMode renderingMode) const >+RefPtr<ImageBuffer> HTMLVideoElement::createBufferForPainting(const FloatSize& size, RenderingMode renderingMode, DestinationColorSpace colorSpace, PixelFormat pixelFormat) const > { > auto* hostWindow = document().view() && document().view()->root() ? document().view()->root()->hostWindow() : nullptr; > auto shouldUseDisplayList = document().settings().displayListDrawingEnabled() ? ShouldUseDisplayList::Yes : ShouldUseDisplayList::No; >- return ImageBuffer::create(size, renderingMode, shouldUseDisplayList, RenderingPurpose::MediaPainting, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8, hostWindow); >+ return ImageBuffer::create(size, renderingMode, shouldUseDisplayList, RenderingPurpose::MediaPainting, 1, colorSpace, pixelFormat, hostWindow); > } > > void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& destRect) >Index: Source/WebCore/html/HTMLVideoElement.h >=================================================================== >--- Source/WebCore/html/HTMLVideoElement.h (revision 276929) >+++ Source/WebCore/html/HTMLVideoElement.h (working copy) >@@ -38,6 +38,8 @@ class ImageBuffer; > class RenderVideo; > class PictureInPictureObserver; > >+enum class DestinationColorSpace : uint8_t; >+enum class PixelFormat : uint8_t; > enum class RenderingMode : bool; > > class HTMLVideoElement final : public HTMLMediaElement, public Supplementable<HTMLVideoElement> { >@@ -70,7 +72,7 @@ public: > void webkitRequestFullscreen() override; > #endif > >- RefPtr<ImageBuffer> createBufferForPainting(const FloatSize&, RenderingMode) const; >+ RefPtr<ImageBuffer> createBufferForPainting(const FloatSize&, RenderingMode, DestinationColorSpace, PixelFormat) const; > > // Used by canvas to gain raw pixel access > void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&); >Index: Source/WebCore/html/ImageBitmap.cpp >=================================================================== >--- Source/WebCore/html/ImageBitmap.cpp (revision 276929) >+++ Source/WebCore/html/ImageBitmap.cpp (working copy) >@@ -502,7 +502,9 @@ void ImageBitmap::createPromise(ScriptEx > auto sourceRectangle = maybeSourceRectangle.releaseReturnValue(); > > auto outputSize = outputSizeForSourceRectangle(sourceRectangle, options); >- auto bitmapData = video->createBufferForPainting(outputSize, bufferRenderingMode); >+ >+ // FIXME: Add support for color spaces / pixel formats to ImageBitmap. >+ auto bitmapData = video->createBufferForPainting(outputSize, bufferRenderingMode, DestinationColorSpace::SRGB, PixelFormat::BGRA8); > if (!bitmapData) { > resolveWithBlankImageBuffer(scriptExecutionContext, !taintsOrigin(scriptExecutionContext.securityOrigin(), *video), WTFMove(promise)); > return; >Index: Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (working copy) >@@ -37,12 +37,14 @@ > #include "CSSPropertyNames.h" > #include "CSSPropertyParserHelpers.h" > #include "CSSPropertyParserWorkerSafe.h" >+#include "ColorSpace.h" > #include "Gradient.h" > #include "ImageBuffer.h" > #include "ImageData.h" > #include "InspectorInstrumentation.h" > #include "NodeRenderStyle.h" > #include "Path2D.h" >+#include "PixelFormat.h" > #include "RenderTheme.h" > #include "RenderWidget.h" > #include "ResourceLoadObserver.h" >@@ -211,7 +213,8 @@ Ref<TextMetrics> CanvasRenderingContext2 > return measureTextInternal(textRun); > } > >-auto CanvasRenderingContext2D::fontProxy() -> const FontProxy* { >+auto CanvasRenderingContext2D::fontProxy() -> const FontProxy* >+{ > // Intentionally don't update style here, because updating style can cause JS to run synchronously. > // This function is called in the middle of processing, and running arbitrary JS in the middle of processing can cause unexpected behavior. > // Instead, the relevant canvas entry points update style once when they begin running, and we won't touch the style after that. >@@ -243,4 +246,15 @@ void CanvasRenderingContext2D::drawTextI > drawTextUnchecked(textRun, x, y, fill, maxWidth); > } > >+PixelFormat CanvasRenderingContext2D::pixelFormat() const >+{ >+ // FIXME: Take m_settings.alpha into account here and add PixelFormat::BGRX8. >+ return PixelFormat::BGRA8; >+} >+ >+DestinationColorSpace CanvasRenderingContext2D::colorSpace() const >+{ >+ return toDestinationColorSpace(m_settings.colorSpace); >+} >+ > } // namespace WebCore >Index: Source/WebCore/html/canvas/CanvasRenderingContext2D.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2D.h (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2D.h (working copy) >@@ -61,6 +61,9 @@ private: > > bool is2d() const final { return true; } > const FontProxy* fontProxy() final; >+ PixelFormat pixelFormat() const final; >+ DestinationColorSpace colorSpace() const final; >+ > void setFontWithoutUpdatingStyle(const String&); > > void drawTextInternal(const String& text, float x, float y, bool fill, Optional<float> maxWidth = WTF::nullopt); >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp (working copy) >@@ -1643,7 +1643,7 @@ ExceptionOr<void> CanvasRenderingContext > repaintEntireCanvas = true; > } else if (state().globalComposite == CompositeOperator::Copy) { > if (&sourceCanvas == &canvasBase()) { >- if (auto copy = buffer->copyRectToBuffer(srcRect, DestinationColorSpace::SRGB, *c)) { >+ if (auto copy = buffer->copyRectToBuffer(srcRect, colorSpace(), *c)) { > clearCanvas(); > c->drawImageBuffer(*copy, dstRect, { { }, srcRect.size() }, { state().globalComposite, state().globalBlend }); > } >@@ -1829,7 +1829,7 @@ template<class T> IntRect CanvasRenderin > > RefPtr<ImageBuffer> CanvasRenderingContext2DBase::createCompositingBuffer(const IntRect& bufferRect) > { >- return ImageBuffer::create(bufferRect.size(), isAccelerated() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated, 1, DestinationColorSpace::SRGB, PixelFormat::BGRA8); >+ return ImageBuffer::create(bufferRect.size(), isAccelerated() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated, 1, colorSpace(), pixelFormat()); > } > > void CanvasRenderingContext2DBase::compositeBuffer(ImageBuffer& buffer, const IntRect& bufferRect, CompositeOperator op) >@@ -2026,7 +2026,7 @@ ExceptionOr<RefPtr<CanvasPattern>> Canva > #endif > > auto renderingMode = !drawingContext() || drawingContext()->isAcceleratedContext() ? RenderingMode::Accelerated : RenderingMode::Unaccelerated; >- auto imageBuffer = videoElement.createBufferForPainting(size(videoElement), renderingMode); >+ auto imageBuffer = videoElement.createBufferForPainting(size(videoElement), renderingMode, colorSpace(), pixelFormat()); > if (!imageBuffer) > return nullptr; > >@@ -2490,7 +2490,7 @@ void CanvasRenderingContext2DBase::drawT > } > }; > >- if (c->clipToDrawingCommands(maskRect, DestinationColorSpace::SRGB, WTFMove(paintMaskImage)) == GraphicsContext::ClipToDrawingCommandsResult::FailedToCreateImageBuffer) >+ if (c->clipToDrawingCommands(maskRect, colorSpace(), WTFMove(paintMaskImage)) == GraphicsContext::ClipToDrawingCommandsResult::FailedToCreateImageBuffer) > return; > > drawStyle.applyFillColor(*c); >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl (nonexistent) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DSettings+ColorSpace.idl (working copy) >@@ -0,0 +1,31 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+[ >+ EnabledBySetting=CanvasColorSpace >+] partial dictionary CanvasRenderingContext2DSettings { >+ PredefinedColorSpace colorSpace = "srgb"; >+}; >Index: Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext2DSettings.h (working copy) >@@ -25,10 +25,13 @@ > > #pragma once > >+#include "PredefinedColorSpace.h" >+ > namespace WebCore { > > struct CanvasRenderingContext2DSettings { > bool desynchronized { false }; >+ PredefinedColorSpace colorSpace { PredefinedColorSpace::SRGB }; > }; > > } // namespace WebCore >Index: Source/WebCore/html/canvas/CanvasRenderingContext.cpp >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext.cpp (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2009 Apple Inc. All rights reserved. >+ * Copyright (C) 2009-2021 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -28,11 +28,13 @@ > > #include "CachedImage.h" > #include "CanvasPattern.h" >+#include "ColorSpace.h" > #include "HTMLCanvasElement.h" > #include "HTMLImageElement.h" > #include "HTMLVideoElement.h" > #include "Image.h" > #include "ImageBitmap.h" >+#include "PixelFormat.h" > #include "SecurityOrigin.h" > #include <wtf/HashSet.h> > #include <wtf/IsoMallocInlines.h> >@@ -80,6 +82,16 @@ void CanvasRenderingContext::deref() > m_canvas.derefCanvasBase(); > } > >+PixelFormat CanvasRenderingContext::pixelFormat() const >+{ >+ return PixelFormat::BGRA8; >+} >+ >+DestinationColorSpace CanvasRenderingContext::colorSpace() const >+{ >+ return DestinationColorSpace::SRGB; >+} >+ > bool CanvasRenderingContext::wouldTaintOrigin(const CanvasPattern* pattern) > { > if (m_canvas.originClean() && pattern && !pattern->originClean()) >Index: Source/WebCore/html/canvas/CanvasRenderingContext.h >=================================================================== >--- Source/WebCore/html/canvas/CanvasRenderingContext.h (revision 276929) >+++ Source/WebCore/html/canvas/CanvasRenderingContext.h (working copy) >@@ -42,6 +42,8 @@ class HTMLVideoElement; > class ImageBitmap; > class TypedOMCSSImageValue; > class WebGLObject; >+enum class DestinationColorSpace : uint8_t; >+enum class PixelFormat : uint8_t; > > class CanvasRenderingContext : public ScriptWrappable { > WTF_MAKE_NONCOPYABLE(CanvasRenderingContext); >@@ -86,6 +88,9 @@ public: > virtual bool needsPreparationForDisplay() const { return false; } > virtual void prepareForDisplay() { } > >+ virtual PixelFormat pixelFormat() const; >+ virtual DestinationColorSpace colorSpace() const; >+ > protected: > explicit CanvasRenderingContext(CanvasBase&); > bool wouldTaintOrigin(const CanvasPattern*); >Index: Source/WebCore/html/canvas/PredefinedColorSpace.cpp >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpace.cpp (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpace.cpp (working copy) >@@ -0,0 +1,48 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PredefinedColorSpace.h" >+ >+#include "ColorSpace.h" >+ >+namespace WebCore { >+ >+DestinationColorSpace toDestinationColorSpace(PredefinedColorSpace colorSpace) >+{ >+ switch (colorSpace) { >+ case PredefinedColorSpace::SRGB: >+ return DestinationColorSpace::SRGB; >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ case PredefinedColorSpace::DisplayP3: >+ return DestinationColorSpace::DisplayP3; >+#endif >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return DestinationColorSpace::SRGB; >+} >+ >+} >Index: Source/WebCore/html/canvas/PredefinedColorSpace.h >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpace.h (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpace.h (working copy) >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/EnumTraits.h> >+ >+namespace WebCore { >+ >+enum class DestinationColorSpace : uint8_t; >+ >+enum class PredefinedColorSpace { >+ SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , DisplayP3 >+#endif >+}; >+ >+DestinationColorSpace toDestinationColorSpace(PredefinedColorSpace); >+ >+} >+ >+namespace WTF { >+ >+template<> struct EnumTraits<WebCore::PredefinedColorSpace> { >+ using values = EnumValues< >+ WebCore::PredefinedColorSpace, >+ WebCore::PredefinedColorSpace::SRGB >+#if ENABLE(DESTINATION_COLOR_SPACE_DISPLAY_P3) >+ , WebCore::PredefinedColorSpace::DisplayP3 >+#endif >+ >; >+}; >+ >+} // namespace WTF >Index: Source/WebCore/html/canvas/PredefinedColorSpace.idl >=================================================================== >--- Source/WebCore/html/canvas/PredefinedColorSpace.idl (nonexistent) >+++ Source/WebCore/html/canvas/PredefinedColorSpace.idl (working copy) >@@ -0,0 +1,32 @@ >+/* >+ * Copyright (C) 2021 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+// Based on the proposal from https://github.com/WICG/canvas-color-space/blob/main/CanvasColorSpaceProposal.md. >+enum PredefinedColorSpace { >+ "srgb" >+#if defined(ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3) && ENABLE_DESTINATION_COLOR_SPACE_DISPLAY_P3 >+ , "display-p3" >+#endif >+}; >Index: Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp >=================================================================== >--- Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp (revision 276929) >+++ Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp (working copy) >@@ -29,7 +29,9 @@ > > #if ENABLE(DATE_AND_TIME_INPUT_TYPES) > >+#include "EventNames.h" > #include "FontCascade.h" >+#include "KeyboardEvent.h" > #include "RenderBlock.h" > #include "RenderStyle.h" > #include <wtf/IsoMallocInlines.h> >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 276929) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,19 @@ >+2021-05-03 Sam Weinig <weinig@apple.com> >+ >+ Add preliminary support for specifying a color space for 2D canvas >+ https://bugs.webkit.org/show_bug.cgi?id=225286 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add basic tests for color space in canvas support. >+ >+ * fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled-expected.txt: Added. >+ * fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html: Added. >+ * fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled-expected.txt: Added. >+ * fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html: Added. >+ * fast/canvas/canvas-color-space-display-p3-expected.html: Added. >+ * fast/canvas/canvas-color-space-display-p3.html: Added. >+ > 2021-05-03 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (r274461): [macOS wk1] fast/repaint/canvas-object-fit.html is flakey text failing >Index: LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled-expected.txt >=================================================================== >--- LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled-expected.txt (nonexistent) >+++ LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled-expected.txt (working copy) >@@ -0,0 +1,12 @@ >+Test that the colorSpace member of CanvasRenderingContext2DSettings is unsupported when CanvasColorSpaceEnabled=false. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS testSettings.colorSpace is undefined. >+PASS testSettings.colorSpace is undefined. >+PASS testSettings.colorSpace is undefined. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >Index: LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html >=================================================================== >--- LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html (nonexistent) >+++ LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-disabled.html (working copy) >@@ -0,0 +1,23 @@ >+<!-- webkit-test-runner [ CanvasColorSpaceEnabled=false ] --> >+<html> >+ <script src="../../resources/js-test-pre.js"></script> >+</head> >+<body> >+<script> >+ description("Test that the colorSpace member of CanvasRenderingContext2DSettings is unsupported when CanvasColorSpaceEnabled=false."); >+ >+ function testColorSpaceUnsupported(settings, expectedColorSpace) { >+ let canvas = document.createElement("canvas"); >+ let context = canvas.getContext("2d", settings); >+ window.testSettings = context.getContextAttributes(); >+ shouldBeUndefined("testSettings.colorSpace"); >+ } >+ >+ testColorSpaceUnsupported(undefined); >+ testColorSpaceUnsupported({ colorSpace: "srgb" }); >+ testColorSpaceUnsupported({ colorSpace: "foo" }); >+</script> >+ >+<script src="../../resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled-expected.txt >=================================================================== >--- LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled-expected.txt (nonexistent) >+++ LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled-expected.txt (working copy) >@@ -0,0 +1,12 @@ >+Test that the colorSpace member of CanvasRenderingContext2DSettings is supported. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS testSettings.colorSpace is "srgb" >+PASS testSettings.colorSpace is "srgb" >+PASS document.createElement("canvas").getContext("2d", { colorSpace: "foo" }) threw exception TypeError: Type error. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >Index: LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html >=================================================================== >--- LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html (nonexistent) >+++ LayoutTests/fast/canvas/CanvasRenderingContext2DSettings-colorSpace-enabled.html (working copy) >@@ -0,0 +1,27 @@ >+<html> >+ <script src="../../resources/js-test-pre.js"></script> >+</head> >+<body> >+<script> >+ description("Test that the colorSpace member of CanvasRenderingContext2DSettings is supported."); >+ >+ function testColorSpace(settings, expectedColorSpace) { >+ let canvas = document.createElement("canvas"); >+ let context = canvas.getContext("2d", settings); >+ window.testSettings = context.getContextAttributes(); >+ shouldBeEqualToString("testSettings.colorSpace", "srgb"); >+ } >+ >+ // Test default value of colorSpace is "srgb". >+ testColorSpace(undefined, "srgb"); >+ >+ // Test setting colorSpace to "srgb" works. >+ testColorSpace({ colorSpace: "srgb" }, "srgb"); >+ >+ // Test setting colorSpace to an unsupported value. >+ shouldThrowErrorName(`document.createElement("canvas").getContext("2d", { colorSpace: "foo" })`, "TypeError") >+</script> >+ >+<script src="../../resources/js-test-post.js"></script> >+</body> >+</html> >Index: LayoutTests/fast/canvas/canvas-color-space-display-p3-expected.html >=================================================================== >--- LayoutTests/fast/canvas/canvas-color-space-display-p3-expected.html (nonexistent) >+++ LayoutTests/fast/canvas/canvas-color-space-display-p3-expected.html (working copy) >@@ -0,0 +1,7 @@ >+<style> >+ .ref { background-color: #009900; width: 100px; height: 100px; margin-bottom: 0; } >+</style> >+<body> >+ <p>This test passes if the square below looks to be all one color</p> >+ <div class="ref"> </div> >+</body> >Index: LayoutTests/fast/canvas/canvas-color-space-display-p3.html >=================================================================== >--- LayoutTests/fast/canvas/canvas-color-space-display-p3.html (nonexistent) >+++ LayoutTests/fast/canvas/canvas-color-space-display-p3.html (working copy) >@@ -0,0 +1,17 @@ >+<style> >+ .ref { background-color: #009900; width: 100px; height: 50px; margin-bottom: 0; } >+</style> >+<body> >+ <p>This test passes if the square below looks to be all one color</p> >+ <div class="ref"> </div> >+ <canvas id="test" width="100" height="50"></canvas> >+ <script> >+ let canvas = document.getElementById("test"); >+ let context = canvas.getContext("2d", { colorSpace: "display-p3" }); >+ >+ context.beginPath(); >+ context.rect(0, 0, 100, 50); >+ context.fillStyle = "color(display-p3 0.26374 0.59085 0.16434)"; >+ context.fill(); >+ </script> >+</body>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ews-feeder
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 225286
:
427564
|
427614
|
427615
|
427617
|
427628
|
427674
|
427770