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-229024-20210819090658.patch (text/plain), 50.83 KB, created by
Cameron McCormack (:heycam)
on 2021-08-18 16:07:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Cameron McCormack (:heycam)
Created:
2021-08-18 16:07:00 PDT
Size:
50.83 KB
patch
obsolete
>Subversion Revision: 281067 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 08510ffef5e8fc15ca8b92164ee6dac08c88649b..f71522ae9e28ca1c8015112353557a21562bbefa 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,73 @@ >+2021-08-16 Cameron McCormack <heycam@apple.com> >+ >+ Preserve color space when getting current color in DisplayList::DrawGlyphsRecorder >+ https://bugs.webkit.org/show_bug.cgi?id=229024 >+ <rdar://problem/81828477> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When GPU canvas is enabled, DrawGlyphsRecorder records the text fill, >+ stroke, and shadow colors by getting them from the context using >+ CGGStateGetFillColor etc. This is done so that color glyphs have each >+ part painted in the right color. But the current conversion from >+ CGColor to WebCore::Color lossily converts to sRGB. So we need to get >+ the color space and color components from the CGColor and preserve them. >+ >+ The existing Color(CGColorRef) constructor is replaced by two >+ constructor functions, createAndPreserveColorSpace and >+ roundAndClampToSRGBALossy, so the conversion behavior is clear at call >+ sites. createAndPreserveColorSpace will match the CGColor's color >+ space to one of the predefined spaces that WebCore::Color can >+ represent. If it's some other color space, we convert to XYZ (on >+ platforms where that's available), since that will result in the least >+ loss, or to sRGB (on platforms where XYZ is not available). >+ >+ CGColorSpaceEqualToColorSpace, which is used when determining the >+ CGColor's color space, is not very expensive, but it will do more than a >+ pointer comparison in case we pass in two CGColorSpaceRefs that are >+ equivalent but not the same pointer value. Since our new >+ colorSpaceForCGColorSpace function will be used with CGColors that have >+ been set WebCore during canvas drawing, we will get back the same >+ pointers that we have cached in sRGBColorSpaceRef(), >+ displayP3ColorSpaceRef(), etc. If calling CGColorSpaceEqualToColorSpace >+ on all our supported color spaces turns out to be too expensive, we >+ could start by doing a pointer comparison on each before calling >+ CGColorSpaceEqualToColorSpace. >+ >+ The way colorSpaceForCGColorSpace is written we could end up >+ instantiating all of our supported color spaces, if an author used an >+ XYZ color when drawing text (the last color profile we check). We >+ could try harder to avoid doing this if it's important. >+ >+ Tests: imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html >+ imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html >+ imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html >+ >+ * page/CaptionUserPreferencesMediaAF.cpp: >+ (WebCore::CaptionUserPreferencesMediaAF::captionsWindowCSS const): >+ (WebCore::CaptionUserPreferencesMediaAF::captionsBackgroundCSS const): >+ (WebCore::CaptionUserPreferencesMediaAF::captionsTextColor const): >+ * platform/graphics/Color.h: >+ (WebCore::Color::createAndPreserveColorSpace): >+ (WebCore::Color::createAndConvertToSRGBA): >+ * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: >+ (WebCore::PlatformCALayerCocoa::backgroundColor const): >+ * platform/graphics/ca/cocoa/WebTiledBackingLayer.mm: >+ (-[WebTiledBackingLayer setBorderColor:]): >+ * platform/graphics/cg/ColorCG.cpp: >+ (WebCore::roundAndClampToSRGBALossy): >+ (WebCore::Color::createAndConvertToSRGBA): >+ (WebCore::Color::createAndPreserveColorSpace): >+ (WebCore::platformConvertColorComponents): >+ * platform/graphics/cg/ColorSpaceCG.cpp: >+ (WebCore::colorSpaceForCGColorSpace): >+ * platform/graphics/cg/ColorSpaceCG.h: >+ * platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp: >+ (WebCore::DisplayList::DrawGlyphsRecorder::updateShadow): >+ (WebCore::DisplayList::DrawGlyphsRecorder::recordDrawGlyphs): >+ * platform/ios/PlatformPasteboardIOS.mm: >+ (WebCore::PlatformPasteboard::color): >+ > 2021-08-15 Simon Fraser <simon.fraser@apple.com> > > [LFC Display] Make Display::ImageBox a CachedImageClient to get image repaint working >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 345a8aa887063fc48209afbb3ffa7e0fa83e0e61..2ee01e446762d16fccd6b65abc06f039077d35d7 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,23 @@ >+2021-08-18 Cameron McCormack <heycam@apple.com> >+ >+ Preserve color space when getting current color in DisplayList::DrawGlyphsRecorder >+ https://bugs.webkit.org/show_bug.cgi?id=229024 >+ <rdar://problem/81828477> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Change existing CGColor -> WebCore::Color conversions to be explicit >+ about lossily converting to sRGB. >+ >+ * UIProcess/API/Cocoa/WKWebView.mm: >+ (-[WKWebView setUnderPageBackgroundColor:]): >+ * UIProcess/API/Cocoa/_WKApplicationManifest.mm: >+ (-[_WKApplicationManifest initWithCoder:]): >+ * UIProcess/mac/WebPageProxyMac.mm: >+ (WebKit::WebPageProxy::platformUnderPageBackgroundColor const): >+ * WebProcess/Plugins/PDF/PDFPlugin.mm: >+ (WebKit::PDFPlugin::PDFPlugin): >+ > 2021-08-15 David Kilzer <ddkilzer@apple.com> > > Bug 229112: ThreadSanitizer: data races of WTF::String in WebResourceLoadStatisticsStore >diff --git a/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp b/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp >index d10e3351f33e407bda253c7eed3a1468a2bc2d4e..0ba1c8b121273fd39d7691dc82c2432633bb6083 100644 >--- a/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp >+++ b/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp >@@ -317,7 +317,7 @@ String CaptionUserPreferencesMediaAF::captionsWindowCSS() const > MACaptionAppearanceBehavior behavior; > RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyWindowColor(kMACaptionAppearanceDomainUser, &behavior)); > >- Color windowColor(color.get()); >+ Color windowColor(roundAndClampToSRGBALossy(color.get())); > if (!windowColor.isValid()) > windowColor = Color::transparentBlack; > >@@ -342,7 +342,7 @@ String CaptionUserPreferencesMediaAF::captionsBackgroundCSS() const > MACaptionAppearanceBehavior behavior; > > RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyBackgroundColor(kMACaptionAppearanceDomainUser, &behavior)); >- Color backgroundColor(color.get()); >+ Color backgroundColor(roundAndClampToSRGBALossy(color.get())); > if (!backgroundColor.isValid()) > backgroundColor = defaultBackgroundColor; > >@@ -356,7 +356,8 @@ String CaptionUserPreferencesMediaAF::captionsBackgroundCSS() const > Color CaptionUserPreferencesMediaAF::captionsTextColor(bool& important) const > { > MACaptionAppearanceBehavior behavior; >- Color textColor = adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior)).get(); >+ RetainPtr<CGColorRef> color = adoptCF(MACaptionAppearanceCopyForegroundColor(kMACaptionAppearanceDomainUser, &behavior)).get(); >+ Color textColor(roundAndClampToSRGBALossy(color.get())); > if (!textColor.isValid()) { > // This default value must be the same as the one specified in mediaControls.css for -webkit-media-text-track-container. > textColor = Color::white; >diff --git a/Source/WebCore/platform/graphics/Color.h b/Source/WebCore/platform/graphics/Color.h >index 02ee0b68b291a64357f779817ab636b1783f7398..578556e7af9dd6dc205d8f4229a31a502e58d350 100644 >--- a/Source/WebCore/platform/graphics/Color.h >+++ b/Source/WebCore/platform/graphics/Color.h >@@ -150,7 +150,7 @@ public: > #endif > > #if USE(CG) >- WEBCORE_EXPORT Color(CGColorRef, OptionSet<Flags> = { }); >+ WEBCORE_EXPORT static Color createAndPreserveColorSpace(CGColorRef, OptionSet<Flags> = { }); > #endif > > #if PLATFORM(WIN) >@@ -207,6 +207,10 @@ private: > }; > Color(Ref<OutOfLineComponents>&&, ColorSpace, OptionSet<Flags> = { }); > >+#if USE(CG) >+ WEBCORE_EXPORT static Color createAndConvertToSRGBA(CGColorRef, OptionSet<Flags> = { }); >+#endif >+ > enum class FlagsIncludingPrivate : uint8_t { > Semantic = static_cast<uint8_t>(Flags::Semantic), > UseColorFunctionSerialization = static_cast<uint8_t>(Flags::UseColorFunctionSerialization), >@@ -268,6 +272,7 @@ bool outOfLineComponentssEqualIgnoringSemanticColor(const Color&, const Color&); > #if USE(CG) > WEBCORE_EXPORT CGColorRef cachedCGColor(const Color&); > WEBCORE_EXPORT ColorComponents<float, 4> platformConvertColorComponents(ColorSpace, ColorComponents<float, 4>, const DestinationColorSpace&); >+WEBCORE_EXPORT std::optional<SRGBA<uint8_t>> roundAndClampToSRGBALossy(CGColorRef); > #endif > > WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const Color&); >diff --git a/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm b/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm >index 02a26d57b55ecade43c5f2ee395f8332926879a9..2d2871677a177bbe6f48788ed843e1f55ade6a0f 100644 >--- a/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm >+++ b/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm >@@ -820,7 +820,7 @@ void PlatformCALayerCocoa::setMagnificationFilter(FilterType value) > > Color PlatformCALayerCocoa::backgroundColor() const > { >- return [m_layer backgroundColor]; >+ return roundAndClampToSRGBALossy([m_layer backgroundColor]); > } > > void PlatformCALayerCocoa::setBackgroundColor(const Color& value) >diff --git a/Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.mm b/Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.mm >index 827b93148bae376eb52e807517eb14ee145ae448..0c71d438ee43593516093f83ac1b4a74213f280d 100644 >--- a/Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.mm >+++ b/Source/WebCore/platform/graphics/ca/cocoa/WebTiledBackingLayer.mm >@@ -147,7 +147,7 @@ - (void)invalidate > > - (void)setBorderColor:(CGColorRef)borderColor > { >- _tileController->setTileDebugBorderColor(WebCore::Color(borderColor)); >+ _tileController->setTileDebugBorderColor(WebCore::roundAndClampToSRGBALossy(borderColor)); > } > > - (void)setBorderWidth:(CGFloat)borderWidth >diff --git a/Source/WebCore/platform/graphics/cg/ColorCG.cpp b/Source/WebCore/platform/graphics/cg/ColorCG.cpp >index dabc7e773400550451f2704e11c818fcc6d2c852..7a92d85c1e1b3e8f2685ce71014d24c90b1e8180 100644 >--- a/Source/WebCore/platform/graphics/cg/ColorCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ColorCG.cpp >@@ -54,9 +54,10 @@ RetainPtr<CGColorRef> TinyLRUCachePolicy<WebCore::Color, RetainPtr<CGColorRef>>: > > namespace WebCore { > >-static std::optional<SRGBA<uint8_t>> roundAndClampToSRGBALossy(CGColorRef color) >+std::optional<SRGBA<uint8_t>> roundAndClampToSRGBALossy(CGColorRef color) > { >- // FIXME: ExtendedColor - needs to handle color spaces. >+ // FIXME: Interpreting components of a color in an arbitrary color space >+ // as sRGB could be wrong, not just lossy. > > if (!color) > return std::nullopt; >@@ -87,9 +88,52 @@ static std::optional<SRGBA<uint8_t>> roundAndClampToSRGBALossy(CGColorRef color) > return convertColor<SRGBA<uint8_t>>(makeFromComponentsClamping<SRGBA<float>>(r, g, b, a )); > } > >-Color::Color(CGColorRef color, OptionSet<Flags> flags) >- : Color(roundAndClampToSRGBALossy(color), flags) >+Color Color::createAndConvertToSRGBA(CGColorRef color, OptionSet<Flags> flags) > { >+ auto sourceCGColorSpace = CGColorGetColorSpace(color); >+#if HAVE(CORE_GRAPHICS_XYZ_COLOR_SPACE) >+ auto destinationCGColorSpace = xyzColorSpaceRef(); >+ auto destinationColorSpace = ColorSpace::XYZ_D50; >+#else >+ auto destinationCGColorSpace = sRGBColorSpaceRef(); >+ auto destinationColorSpace = ColorSpace::SRGB; >+#endif >+ ASSERT(CGColorSpaceGetNumberOfComponents(destinationCGColorSpace) == 3); >+ >+ auto sourceComponents = CGColorGetComponents(color); >+ CGFloat destinationComponents[3] { }; >+ >+ auto transform = adoptCF(CGColorTransformCreate(destinationCGColorSpace, nullptr)); >+ auto result = CGColorTransformConvertColorComponents(transform.get(), sourceCGColorSpace, kCGRenderingIntentDefault, sourceComponents, destinationComponents); >+ ASSERT_UNUSED(result, result); >+ >+ float a = destinationComponents[0]; >+ float b = destinationComponents[1]; >+ float c = destinationComponents[2]; >+ float alpha = CGColorGetAlpha(color); >+ >+ return Color(OutOfLineComponents::create({ a, b, c, alpha }), destinationColorSpace, flags); >+} >+ >+Color Color::createAndPreserveColorSpace(CGColorRef color, OptionSet<Flags> flags) >+{ >+ if (!color) >+ return Color(); >+ >+ size_t numComponents = CGColorGetNumberOfComponents(color); >+ auto colorSpace = colorSpaceForCGColorSpace(CGColorGetColorSpace(color)); >+ >+ if (numComponents != 4 || !colorSpace) >+ return createAndConvertToSRGBA(color, flags); >+ >+ const CGFloat* components = CGColorGetComponents(color); >+ >+ float a = components[0]; >+ float b = components[1]; >+ float c = components[2]; >+ float alpha = components[3]; >+ >+ return Color(OutOfLineComponents::create({ a, b, c, alpha }), *colorSpace, flags); > } > > static std::pair<CGColorSpaceRef, ColorComponents<float, 4>> convertToCGCompatibleComponents(ColorSpace colorSpace, ColorComponents<float, 4> components) >@@ -181,6 +225,7 @@ ColorComponents<float, 4> platformConvertColorComponents(ColorSpace inputColorSp > auto transform = adoptCF(CGColorTransformCreate(outputColorSpace.platformColorSpace(), nullptr)); > auto result = CGColorTransformConvertColorComponents(transform.get(), cgInputColorSpace, kCGRenderingIntentDefault, sourceComponents, destinationComponents); > ASSERT_UNUSED(result, result); >+ // FIXME: CGColorTransformConvertColorComponents doesn't copy over any alpha component. > return { static_cast<float>(destinationComponents[0]), static_cast<float>(destinationComponents[1]), static_cast<float>(destinationComponents[2]), static_cast<float>(destinationComponents[3]) }; > } > >diff --git a/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp b/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp >index 1491e41b90ce9ddc6e78eebca208ef38f7b2ac8a..8c81c10f78165307e9ed2358c6d0735b84492d6b 100644 >--- a/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/ColorSpaceCG.cpp >@@ -108,6 +108,46 @@ CGColorSpaceRef xyzColorSpaceRef() > } > #endif > >+std::optional<ColorSpace> colorSpaceForCGColorSpace(CGColorSpaceRef colorSpace) >+{ >+ if (CGColorSpaceEqualToColorSpace(colorSpace, sRGBColorSpaceRef())) >+ return ColorSpace::SRGB; >+ >+#if HAVE(CORE_GRAPHICS_ADOBE_RGB_1998_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, adobeRGB1998ColorSpaceRef())) >+ return ColorSpace::A98RGB; >+#endif >+ >+#if HAVE(CORE_GRAPHICS_DISPLAY_P3_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, displayP3ColorSpaceRef())) >+ return ColorSpace::DisplayP3; >+#endif >+ >+ // FIXME: labColorSpaceRef() not implemented. >+ >+#if HAVE(CORE_GRAPHICS_LINEAR_SRGB_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, linearSRGBColorSpaceRef())) >+ return ColorSpace::LinearSRGB; >+#endif >+ >+#if HAVE(CORE_GRAPHICS_ROMMRGB_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, ROMMRGBColorSpaceRef())) >+ return ColorSpace::ProPhotoRGB; >+#endif >+ >+#if HAVE(CORE_GRAPHICS_ITUR_2020_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, ITUR_2020ColorSpaceRef())) >+ return ColorSpace::Rec2020; >+#endif >+ >+#if HAVE(CORE_GRAPHICS_XYZ_COLOR_SPACE) >+ if (CGColorSpaceEqualToColorSpace(colorSpace, xyzColorSpaceRef())) >+ return ColorSpace::XYZ_D50; >+#endif >+ >+ return std::nullopt; >+} >+ > } > > #endif // USE(CG) >diff --git a/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h b/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h >index db60410e6d473aca7ea7a194cc78c964c98ba373..032930f52b81567f5d9eaa96dd51377ccd578e5c 100644 >--- a/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h >+++ b/Source/WebCore/platform/graphics/cg/ColorSpaceCG.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "ColorSpace.h" >+#include <optional> > > typedef struct CGColorSpace *CGColorSpaceRef; > >@@ -65,6 +66,8 @@ WEBCORE_EXPORT CGColorSpaceRef ROMMRGBColorSpaceRef(); > WEBCORE_EXPORT CGColorSpaceRef xyzColorSpaceRef(); > #endif > >+std::optional<ColorSpace> colorSpaceForCGColorSpace(CGColorSpaceRef); >+ > static inline CGColorSpaceRef cachedNullableCGColorSpace(ColorSpace colorSpace) > { > switch (colorSpace) { >diff --git a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >index bee194d533a1903d634d692d5633d7333263061c..a1be3cdb93ab40bdceb0e99eb8bada35ba7745cf 100644 >--- a/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >+++ b/Source/WebCore/platform/graphics/displaylists/DisplayListDrawGlyphsRecorderCoreText.cpp >@@ -261,7 +261,8 @@ void DrawGlyphsRecorder::updateShadow(CGStyleRef style) > const auto& shadowStyle = *static_cast<const CGShadowStyle*>(CGStyleGetData(style)); > auto rad = deg2rad(shadowStyle.azimuth - 180); > auto shadowOffset = FloatSize(std::cos(rad), std::sin(rad)) * shadowStyle.height; >- updateShadow(shadowOffset, shadowStyle.radius, CGStyleGetColor(style), ShadowsIgnoreTransforms::Yes); >+ auto shadowColor = CGStyleGetColor(style); >+ updateShadow(shadowOffset, shadowStyle.radius, Color::createAndPreserveColorSpace(shadowColor), ShadowsIgnoreTransforms::Yes); > } > > void DrawGlyphsRecorder::recordBeginLayer(CGRenderingStateRef, CGGStateRef gstate, CGRect) >@@ -330,8 +331,10 @@ void DrawGlyphsRecorder::recordDrawGlyphs(CGRenderingStateRef, CGGStateRef gstat > ctmFixup = AffineTransform(); > m_owner.concatCTM(ctmFixup); > >- updateFillColor(CGGStateGetFillColor(gstate)); >- updateStrokeColor(CGGStateGetStrokeColor(gstate)); >+ auto fillColor = CGGStateGetFillColor(gstate); >+ auto strokeColor = CGGStateGetStrokeColor(gstate); >+ updateFillColor(Color::createAndPreserveColorSpace(fillColor)); >+ updateStrokeColor(Color::createAndPreserveColorSpace(strokeColor)); > updateShadow(CGGStateGetStyle(gstate)); > > m_owner.appendDrawGlyphsItemWithCachedFont(*m_originalFont, glyphs, computeAdvancesFromPositions(positions, count, currentTextMatrix).data(), count, currentTextMatrix.mapPoint(positions[0]), m_smoothingMode); >diff --git a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >index df596efaeef3d5f97157a91a989d099cbc105d2a..640a4526c57aeee1f912de7f563e6373126f13fe 100644 >--- a/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >+++ b/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm >@@ -315,7 +315,7 @@ Color PlatformPasteboard::color() > { > NSData *data = [m_pasteboard dataForPasteboardType:UIColorPboardType]; > UIColor *uiColor = [NSKeyedUnarchiver unarchivedObjectOfClass:PAL::getUIColorClass() fromData:data error:nil]; >- return Color(uiColor.CGColor); >+ return roundAndClampToSRGBALossy(uiColor.CGColor); > } > > URL PlatformPasteboard::url() >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index 5479918a28e05b9b7f02907e44ee0718758b3302..136d005c99e76ae285fed7bc1a4fe979eb724710 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -1344,7 +1344,7 @@ static const Vector<CSSValueSystemColorInformation>& cssValueSystemColorInformat > static inline std::optional<Color> systemColorFromCSSValueSystemColorInformation(CSSValueSystemColorInformation systemColorInformation, bool useDarkAppearance) > { > if (auto color = wtfObjCMsgSend<UIColor *>(PAL::getUIColorClass(), systemColorInformation.selector)) { >- Color systemColor = { color.CGColor, Color::Flags::Semantic }; >+ Color systemColor(roundAndClampToSRGBALossy(color.CGColor), Color::Flags::Semantic); > > if (systemColorInformation.opacity < 1.0f) > systemColor = systemColor.colorWithAlphaMultipliedBy(systemColorInformation.opacity); >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >index cdcd397ad85ccfb7bb1fd0e5e38ed28e92e7324d..f2c9bae18608501fa2c25e1086d8f84aa02dc7fb 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm >@@ -1784,7 +1784,7 @@ - (CocoaColor *)underPageBackgroundColor > > - (void)setUnderPageBackgroundColor:(CocoaColor *)underPageBackgroundColorOverride > { >- _page->setUnderPageBackgroundColorOverride(underPageBackgroundColorOverride.CGColor); >+ _page->setUnderPageBackgroundColorOverride(WebCore::roundAndClampToSRGBALossy(underPageBackgroundColorOverride.CGColor)); > } > > + (BOOL)automaticallyNotifiesObserversOfUnderPageBackgroundColor >diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm >index b562fa4a083af598f67739b5b69b90659671b362..35c225f3cd6789ae2043f961e9005c534ebe4fd8 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifest.mm >@@ -67,7 +67,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder > URL(scopeURL), > static_cast<WebCore::ApplicationManifest::Display>(display), > URL(startURL), >- WebCore::Color(themeColor.CGColor), >+ WebCore::roundAndClampToSRGBALossy(themeColor.CGColor), > }; > > API::Object::constructInWrapper<API::ApplicationManifest>(self, WTFMove(coreApplicationManifest)); >diff --git a/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm b/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm >index 1f0dafcd8fa868cd124690ca7ecc7cbf4c8a11ee..f8157df568ad4ec49c341204d00cb86041c5db47 100644 >--- a/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm >+++ b/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm >@@ -481,7 +481,7 @@ enum class AllowPageBackgroundColorOverride : bool { No, Yes }; > static WebCore::Color baseScrollViewBackgroundColor(WKWebView *webView, AllowPageBackgroundColorOverride allowPageBackgroundColorOverride) > { > if (webView->_customContentView) >- return [webView->_customContentView backgroundColor].CGColor; >+ return WebCore::roundAndClampToSRGBALossy([webView->_customContentView backgroundColor].CGColor); > > if (webView->_gestureController) { > WebCore::Color color = webView->_gestureController->backgroundColorForCurrentSnapshot(); >@@ -507,11 +507,11 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView, AllowPageBac > WebCore::Color color = baseScrollViewBackgroundColor(webView, allowPageBackgroundColorOverride); > > if (!color.isValid() && webView->_contentView) >- color = [webView->_contentView backgroundColor].CGColor; >+ color = WebCore::roundAndClampToSRGBALossy([webView->_contentView backgroundColor].CGColor); > > if (!color.isValid()) { > #if HAVE(OS_DARK_MODE_SUPPORT) >- color = UIColor.systemBackgroundColor.CGColor; >+ color = WebCore::roundAndClampToSRGBALossy(UIColor.systemBackgroundColor.CGColor); > #else > color = WebCore::Color::white; > #endif >diff --git a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >index 1bd33065f10c170d066ccb7a6f6a5c5e863188df..94e23cda488957707ba3d04fe7b89b5bc5eda10f 100644 >--- a/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >+++ b/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm >@@ -1020,7 +1020,7 @@ void PageClientImpl::runModalJavaScriptDialog(CompletionHandler<void()>&& callba > > WebCore::Color PageClientImpl::contentViewBackgroundColor() > { >- return [m_contentView backgroundColor].CGColor; >+ return WebCore::roundAndClampToSRGBALossy([m_contentView backgroundColor].CGColor); > } > > void PageClientImpl::requestScrollToRect(const FloatRect& targetRect, const FloatPoint& origin) >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index c9396678299e264bd1296772257c7d3aaee026cd..1f122ea741f79c5402282ad58655ec75bfa19203 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -3635,7 +3635,8 @@ - (void)_setFontSizeForWebView:(CGFloat)fontSize sender:(id)sender > > - (void)_setTextColorForWebView:(UIColor *)color sender:(id)sender > { >- _page->executeEditCommand("ForeColor"_s, WebCore::serializationForHTML(WebCore::Color(color.CGColor))); >+ WebCore::Color textColor(WebCore::roundAndClampToSRGBALossy(color.CGColor)); >+ _page->executeEditCommand("ForeColor"_s, WebCore::serializationForHTML(textColor)); > } > > - (void)toggleStrikeThroughForWebView:(id)sender >@@ -4876,7 +4877,7 @@ - (void)updateFocusedElementValue:(NSString *)value > > - (void)updateFocusedElementValueAsColor:(UIColor *)value > { >- WebCore::Color color(value.CGColor); >+ WebCore::Color color(WebCore::roundAndClampToSRGBALossy(value.CGColor)); > String valueAsString = WebCore::serializationForHTML(color); > > _page->setFocusedElementValue(_focusedElementInformation.elementContext, valueAsString); >diff --git a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >index 555317f730ef40a06f906d42b69f4036d7f03d9a..09d4cff2289586571b0e2b2d2bcc99083e8d8c27 100644 >--- a/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >+++ b/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm >@@ -1565,9 +1565,9 @@ Color WebPageProxy::platformUnderPageBackgroundColor() const > return contentViewBackgroundColor; > > #if HAVE(OS_DARK_MODE_SUPPORT) >- return UIColor.systemBackgroundColor.CGColor; >+ return WebCore::roundAndClampToSRGBALossy(UIColor.systemBackgroundColor.CGColor); > #else >- return UIColor.whiteColor.CGColor; >+ return WebCore::Color::white; > #endif > } > >diff --git a/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm >index be144bb37d93129f3a86437351b988bbf55518a6..7200e9606602c6dece3dd6c854b78e4cba61265f 100644 >--- a/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm >+++ b/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm >@@ -728,9 +728,9 @@ void WebPageProxy::changeUniversalAccessZoomFocus(const WebCore::IntRect& viewRe > Color WebPageProxy::platformUnderPageBackgroundColor() const > { > #if ENABLE(DARK_MODE_CSS) >- return NSColor.controlBackgroundColor.CGColor; >+ return WebCore::roundAndClampToSRGBALossy(NSColor.controlBackgroundColor.CGColor); > #else >- return NSColor.whiteColor.CGColor; >+ return WebCore::Color::white; > #endif > } > >diff --git a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >index 77426b7cdd63c2e70764f14f8057845ad572d09e..5eda376acd4f8f202cadedf406b3ab8e46908e19 100644 >--- a/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >+++ b/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm >@@ -624,7 +624,7 @@ inline PDFPlugin::PDFPlugin(WebFrame& frame) > auto* document = frame.coreFrame()->document(); > > // FIXME: <rdar://problem/75332948> get the background color from PDFKit instead of hardcoding it >- document->bodyOrFrameset()->setInlineStyleProperty(WebCore::CSSPropertyBackgroundColor, WebCore::serializationForHTML([CocoaColor grayColor].CGColor)); >+ document->bodyOrFrameset()->setInlineStyleProperty(WebCore::CSSPropertyBackgroundColor, WebCore::serializationForHTML(WebCore::roundAndClampToSRGBALossy([CocoaColor grayColor].CGColor))); > } > > if (supportsForms()) { >diff --git a/Source/WebKitLegacy/mac/WebView/WebFrame.mm b/Source/WebKitLegacy/mac/WebView/WebFrame.mm >index 0d7f0d2846a8bff9905bdf4747fa90731204247b..43102069e2446b3d50616dde4099f7cd8d0fb72a 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebFrame.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebFrame.mm >@@ -443,7 +443,7 @@ - (void)_updateBackgroundAndUpdatesWhileOffscreen > WebCore::Color color = WebCore::colorFromNSColor([backgroundColor colorUsingColorSpaceName:NSDeviceRGBColorSpace]); > ALLOW_DEPRECATED_DECLARATIONS_END > #else >- WebCore::Color color = WebCore::Color(backgroundColor); >+ WebCore::Color color(WebCore::roundAndClampToSRGBALossy(backgroundColor)); > #endif > view->setBaseBackgroundColor(color); > view->setShouldUpdateWhileOffscreen([webView shouldUpdateWhileOffscreen]); >@@ -1388,7 +1388,7 @@ - (NSRect)rectForScrollToVisible > > - (void)setCaretColor:(CGColorRef)color > { >- WebCore::Color qColor = color ? WebCore::Color(color) : WebCore::Color::black; >+ WebCore::Color qColor = color ? WebCore::Color(WebCore::roundAndClampToSRGBALossy(color)) : WebCore::Color::black; > WebCore::Frame *frame = core(self); > frame->selection().setCaretColor(qColor); > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index d67638d3f3142e8cc6189a5e16b33e2c2b3ea2c8..49d48ab3a0031446c617271b3788e4c358ea3be2 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,17 @@ >+2021-08-18 Cameron McCormack <heycam@apple.com> >+ >+ Preserve color space when getting current color in DisplayList::DrawGlyphsRecorder >+ https://bugs.webkit.org/show_bug.cgi?id=229024 >+ <rdar://problem/81828477> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Change existing CGColor -> WebCore::Color conversions to be explicit >+ about lossily converting to sRGB. >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm: >+ (TEST): >+ > 2021-08-13 Jonathan Bedard <jbedard@apple.com> > > [webkitscmpy] Fix SVN relative URL parsing >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm >index 7a6be09a31751ebcd4c0f7a037d216e8e9d95589..46ec4befb3b208777f6617ff5e649ebeed1271a6 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/SampledPageTopColor.mm >@@ -149,7 +149,7 @@ TEST(SampledPageTopColor, SolidColor) > EXPECT_NULL([webView _sampledPageTopColor]); > > waitForSampledPageTopColorToChangeForHTML(webView.get(), createHTMLGradientWithColorStops("right"_s, { "red"_s, "red"_s })); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::red); > } > > TEST(SampledPageTopColor, DifferentColorsWithoutOutlierBelowMaxDifference) >@@ -301,7 +301,7 @@ TEST(SampledPageTopColor, HitTestHTMLCanvasWithoutRenderingContext) > EXPECT_NULL([webView _sampledPageTopColor]); > > waitForSampledPageTopColorToChangeForHTML(webView.get(), @"<body style='margin: 0'><canvas style='width: 100%; height: 100%; background-color: red'></canvas>Test"); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::red); > } > > TEST(SampledPageTopColor, HitTestHTMLCanvasWithRenderingContext) >@@ -328,7 +328,7 @@ TEST(SampledPageTopColor, HitTestBeforeCSSTransition) > EXPECT_NULL([webView _sampledPageTopColor]); > > waitForSampledPageTopColorToChangeForHTML(webView.get(), @"<body style='margin: 0; transition: background-color 1s'>Test"); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::white); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::white); > } > > TEST(SampledPageTopColor, HitTestDuringCSSTransition) >@@ -360,7 +360,7 @@ TEST(SampledPageTopColor, HitTestAfterCSSTransition) > // Not setting this until now prevents the sampling logic from running because without it the page isn't considered contentful. > [webView objectByEvaluatingJavaScript:@"document.body.textContent = 'Test'"]; > waitForSampledPageTopColorToChange(webView.get()); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::red); > } > > TEST(SampledPageTopColor, HitTestBeforeCSSAnimation) >@@ -369,7 +369,7 @@ TEST(SampledPageTopColor, HitTestBeforeCSSAnimation) > EXPECT_NULL([webView _sampledPageTopColor]); > > waitForSampledPageTopColorToChangeForHTML(webView.get(), @"<style>@keyframes changeBackgroundRed { to { background-color: red; } }</style><body style='margin: 0; animation: changeBackgroundRed 1s forwards paused'>Test"); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::white); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::white); > } > > TEST(SampledPageTopColor, HitTestDuringCSSAnimation) >@@ -399,7 +399,7 @@ TEST(SampledPageTopColor, HitTestAfterCSSAnimation) > // Not setting this until now prevents the sampling logic from running because without it the page isn't considered contentful. > [webView objectByEvaluatingJavaScript:@"document.body.textContent = 'Test'"]; > waitForSampledPageTopColorToChange(webView.get()); >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::red); > } > > TEST(SampledPageTopColor, HitTestCSSPointerEventsNone) >@@ -408,7 +408,7 @@ TEST(SampledPageTopColor, HitTestCSSPointerEventsNone) > EXPECT_NULL([webView _sampledPageTopColor]); > > [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body style='margin: 0'><div style='width: 100%; height: 100%; background-color: red; pointer-events: none'></div>Test"]; >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::red); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::red); > } > > // FIXME: <https://webkit.org/b/225167> (Sampled Page Top Color: hook into painting logic instead of taking snapshots) >@@ -443,13 +443,13 @@ TEST(SampledPageTopColor, MainDocumentChange) > }]); > > [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body>Test"]; >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::white); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::white); > EXPECT_EQ(notificationCount, 1UL); > > notificationCount = 0; > > [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body>Test"]; >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::white); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::white); > // Depending on timing, a notification can be sent for when the main document changes and then > // when the new main document renders or both can be coalesced if rendering is fast enough. > EXPECT_TRUE(notificationCount == 0 || notificationCount == 2); >@@ -469,6 +469,6 @@ TEST(SampledPageTopColor, MainDocumentChange) > notificationCount = 0; > > [webView synchronouslyLoadHTMLStringAndWaitUntilAllImmediateChildFramesPaint:@"<body>Test"]; >- EXPECT_EQ(WebCore::Color([webView _sampledPageTopColor].CGColor), WebCore::Color::white); >+ EXPECT_EQ(WebCore::roundAndClampToSRGBALossy([webView _sampledPageTopColor].CGColor), WebCore::Color::white); > EXPECT_EQ(notificationCount, 1UL); > } >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 9d927f1265a373cbff5d166e29c1d1682fd64760..6de3eef927598133e778b0da9e7d23cfb2c5177b 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,22 @@ >+2021-08-16 Cameron McCormack <heycam@apple.com> >+ >+ Preserve color space when getting current color in DisplayListDrawGlyphsRecorder. >+ https://bugs.webkit.org/show_bug.cgi?id=229024 >+ <rdar://problem/81828477> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add tests for calling fillText() and strokeText() with a display-p3 >+ color for fillStyle, strokeStyle, and shadowColor, on a display-p3 canvas. >+ >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText-expected.txt: Added. >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html: Added. >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow-expected.txt: Added. >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html: Added. >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText-expected.txt: Added. >+ * web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html: Added. >+ * web-platform-tests/html/canvas/tools/yaml/element/color_space.yaml: >+ > 2021-08-13 Chris Dumez <cdumez@apple.com> > > Add Cross-Origin-Embedder-Policy support for Blob URLs >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..3d896afd8650fa93bf422a60e7074f4479cd93be >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText-expected.txt >@@ -0,0 +1,6 @@ >+2d.color.space.p3.fillText >+Test if fillText can be used with a solid display-p3 color >+Actual output: >+ >+PASS Test if fillText can be used with a solid display-p3 color >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html >new file mode 100644 >index 0000000000000000000000000000000000000000..5c1a6008755ff6c2947bb6b679e1a99a775b48c3 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.html >@@ -0,0 +1,59 @@ >+<!DOCTYPE html> >+<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> >+<title>Canvas test: 2d.color.space.p3.fillText</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="/html/canvas/resources/canvas-tests.js"></script> >+<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> >+<body class="show_output"> >+ >+<h1>2d.color.space.p3.fillText</h1> >+<p class="desc">Test if fillText can be used with a solid display-p3 color</p> >+ >+ >+<p class="output">Actual output:</p> >+<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> >+ >+<ul id="d"></ul> >+<script> >+var t = async_test("Test if fillText can be used with a solid display-p3 color"); >+_addTest(function(canvas, ctx) { >+ >+deferTest(); >+ >+const fullRedInP3 = [255, 0, 0, 255]; >+const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+canvas.width = 100; >+canvas.height = 100; >+ >+let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+document.fonts.add(f); >+f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.fillStyle = "#f00"; >+ ctx.fillText("A", 0, 50); >+ >+ ctx.fillStyle = "black"; >+ ctx.fillStyle = "color(display-p3 100% 0 0)"; >+ ctx.fillText("A", 50, 50); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+}); >+ >+ >+}, {colorSpace: "display-p3"}); >+</script> >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8d03a8a1a5cdb0cd5cb0fe5acc4df41196d463ce >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow-expected.txt >@@ -0,0 +1,6 @@ >+2d.color.space.p3.fillText.shadow >+Test if fillText can be used with a display-p3 shadow color >+Actual output: >+ >+PASS Test if fillText can be used with a display-p3 shadow color >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html >new file mode 100644 >index 0000000000000000000000000000000000000000..3bb74c6ae4aba54f7cc0e46ecdac1cfcd938d00b >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.fillText.shadow.html >@@ -0,0 +1,63 @@ >+<!DOCTYPE html> >+<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> >+<title>Canvas test: 2d.color.space.p3.fillText.shadow</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="/html/canvas/resources/canvas-tests.js"></script> >+<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> >+<body class="show_output"> >+ >+<h1>2d.color.space.p3.fillText.shadow</h1> >+<p class="desc">Test if fillText can be used with a display-p3 shadow color</p> >+ >+ >+<p class="output">Actual output:</p> >+<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> >+ >+<ul id="d"></ul> >+<script> >+var t = async_test("Test if fillText can be used with a display-p3 shadow color"); >+_addTest(function(canvas, ctx) { >+ >+deferTest(); >+ >+const fullRedInP3 = [255, 0, 0, 255]; >+const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+canvas.width = 100; >+canvas.height = 100; >+ >+let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+document.fonts.add(f); >+f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.fillStyle = "black"; >+ ctx.shadowBlur = 4; >+ ctx.shadowOffsetX = 0; >+ ctx.shadowOffsetY = 50; >+ ctx.shadowColor = "#f00"; >+ ctx.fillText("A", 0, 0); >+ >+ ctx.shadowColor = "black"; >+ ctx.shadowColor = "color(display-p3 100% 0 0)"; >+ ctx.fillText("A", 50, 0); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+}); >+ >+ >+}, {colorSpace: "display-p3"}); >+</script> >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..4f3447a8217b9bd1a1f4dd6ee3b089d69a560c75 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText-expected.txt >@@ -0,0 +1,6 @@ >+2d.color.space.p3.strokeText >+Test if strokeText can be used with a solid display-p3 color >+Actual output: >+ >+PASS Test if strokeText can be used with a solid display-p3 color >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html >new file mode 100644 >index 0000000000000000000000000000000000000000..c38084a44490bed59ceddaae9002467a1254dafa >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/wide-gamut-canvas/2d.color.space.p3.strokeText.html >@@ -0,0 +1,60 @@ >+<!DOCTYPE html> >+<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> >+<title>Canvas test: 2d.color.space.p3.strokeText</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script src="/html/canvas/resources/canvas-tests.js"></script> >+<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> >+<body class="show_output"> >+ >+<h1>2d.color.space.p3.strokeText</h1> >+<p class="desc">Test if strokeText can be used with a solid display-p3 color</p> >+ >+ >+<p class="output">Actual output:</p> >+<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> >+ >+<ul id="d"></ul> >+<script> >+var t = async_test("Test if strokeText can be used with a solid display-p3 color"); >+_addTest(function(canvas, ctx) { >+ >+deferTest(); >+ >+const fullRedInP3 = [255, 0, 0, 255]; >+const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+canvas.width = 100; >+canvas.height = 100; >+ >+let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+document.fonts.add(f); >+f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.strokeStyle = "#f00"; >+ ctx.lineWidth = 20; >+ ctx.strokeText("A", 0, 50); >+ >+ ctx.strokeStyle = "black"; >+ ctx.strokeStyle = "color(display-p3 100% 0 0)"; >+ ctx.strokeText("A", 50, 50); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+}); >+ >+ >+}, {colorSpace: "display-p3"}); >+</script> >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/tools/yaml/element/color_space.yaml b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/tools/yaml/element/color_space.yaml >index e64d6fb9777dc0c59d66f4bbb60915957266c369..936210727e1c921de0a3350a3a23600a85c41ba2 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/html/canvas/tools/yaml/element/color_space.yaml >+++ b/LayoutTests/imported/w3c/web-platform-tests/html/canvas/tools/yaml/element/color_space.yaml >@@ -175,3 +175,131 @@ > assert_array_approx_equals(actualPixels, expectedPixels, 2); > }); > image.src = canvas.toDataURL(); >+ >+- name: 2d.color.space.p3.fillText >+ testing: >+ - 2d.color.space.p3.and.uint8 >+ desc: Test if fillText can be used with a solid display-p3 color >+ attributes: | >+ {colorSpace: "display-p3"} >+ code: | >+ deferTest(); >+ >+ const fullRedInP3 = [255, 0, 0, 255]; >+ const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+ canvas.width = 100; >+ canvas.height = 100; >+ >+ let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+ document.fonts.add(f); >+ f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.fillStyle = "#f00"; >+ ctx.fillText("A", 0, 50); >+ >+ ctx.fillStyle = "black"; >+ ctx.fillStyle = "color(display-p3 100% 0 0)"; >+ ctx.fillText("A", 50, 50); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+ }); >+ >+- name: 2d.color.space.p3.strokeText >+ testing: >+ - 2d.color.space.p3.and.uint8 >+ desc: Test if strokeText can be used with a solid display-p3 color >+ attributes: | >+ {colorSpace: "display-p3"} >+ code: | >+ deferTest(); >+ >+ const fullRedInP3 = [255, 0, 0, 255]; >+ const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+ canvas.width = 100; >+ canvas.height = 100; >+ >+ let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+ document.fonts.add(f); >+ f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.strokeStyle = "#f00"; >+ ctx.lineWidth = 20; >+ ctx.strokeText("A", 0, 50); >+ >+ ctx.strokeStyle = "black"; >+ ctx.strokeStyle = "color(display-p3 100% 0 0)"; >+ ctx.strokeText("A", 50, 50); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+ }); >+ >+- name: 2d.color.space.p3.fillText.shadow >+ testing: >+ - 2d.color.space.p3.and.uint8 >+ desc: Test if fillText can be used with a display-p3 shadow color >+ attributes: | >+ {colorSpace: "display-p3"} >+ code: | >+ deferTest(); >+ >+ const fullRedInP3 = [255, 0, 0, 255]; >+ const sRGBRedInP3 = [234, 51, 35, 255]; >+ >+ canvas.width = 100; >+ canvas.height = 100; >+ >+ let f = new FontFace("Ahem", "url(/fonts/Ahem.ttf)"); >+ document.fonts.add(f); >+ f.load().then(function() { >+ t.step(function() { >+ ctx.font = "40px Ahem"; >+ >+ ctx.fillStyle = "black"; >+ ctx.shadowBlur = 4; >+ ctx.shadowOffsetX = 0; >+ ctx.shadowOffsetY = 50; >+ ctx.shadowColor = "#f00"; >+ ctx.fillText("A", 0, 0); >+ >+ ctx.shadowColor = "black"; >+ ctx.shadowColor = "color(display-p3 100% 0 0)"; >+ ctx.fillText("A", 50, 0); >+ >+ let pixels = ctx.getImageData(0, 0, canvas.width, canvas.height, { colorSpace: "display-p3" }).data; >+ let pixelAt = function(x, y) { >+ let offset = (y * canvas.width + x) * 4; >+ return [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]]; >+ }; >+ >+ assert_array_equals(pixelAt(25, 25), sRGBRedInP3); >+ assert_array_equals(pixelAt(75, 25), fullRedInP3); >+ >+ t.done(); >+ }); >+ });
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 229024
:
435651
|
435653
|
435752
|
435754
|
435811
|
435915
|
436126