WebKit Bugzilla
Attachment 346254 Details for
Bug 188203
: Hardcode some system colors to avoid fingerprinting exposure
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188203-20180731205558.patch (text/plain), 17.86 KB, created by
Timothy Hatcher
on 2018-07-31 20:55:59 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2018-07-31 20:55:59 PDT
Size:
17.86 KB
patch
obsolete
>Subversion Revision: 234428 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b2be80101e53bbfe715badaa232ed109adfbbdac..46cbef239d82cb83f83e79df85b9a0dfff1ec5c3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2018-07-31 Timothy Hatcher <timothy@apple.com> >+ >+ Hardcode some system colors to avoid fingerprinting exposure. >+ https://bugs.webkit.org/show_bug.cgi?id=188203 >+ rdar://problem/42781630 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Passes existing tests with the hardcoded blue system appearance. >+ >+ * rendering/RenderTheme.h: >+ * rendering/RenderThemeMac.mm: >+ (WebCore::RenderThemeMac::systemColor const): >+ Adds special handling for some system colors. Fixes -apple-system-selected-text-background >+ to match the real selection color by using blendWithWhite(). >+ > 2018-07-31 Yusuke Suzuki <utatane.tea@gmail.com> > > Use static const global variable for TransformationMatrix instead of NeverDestroyed >diff --git a/Source/WebCore/rendering/RenderTheme.h b/Source/WebCore/rendering/RenderTheme.h >index 84d282da56f0772d34d922198c5cb340cf3534dc..5ef5bfc18671fa6dc96416a092eb326975de52b4 100644 >--- a/Source/WebCore/rendering/RenderTheme.h >+++ b/Source/WebCore/rendering/RenderTheme.h >@@ -413,6 +413,10 @@ protected: > Color systemLinkColor; > Color systemActiveLinkColor; > Color systemVisitedLinkColor; >+ Color systemFocusRingColor; >+ Color systemControlAccentColor; >+ Color systemSelectedTextBackgroundColor; >+ Color systemSelectedContentBackgroundColor; > > Color activeSelectionBackgroundColor; > Color inactiveSelectionBackgroundColor; >diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm >index 37665fd32d24762371bdc8209ce6c2e740e2f0aa..06c0c68adffdfb1fd304c5eba4fc2f039eec5372 100644 >--- a/Source/WebCore/rendering/RenderThemeMac.mm >+++ b/Source/WebCore/rendering/RenderThemeMac.mm >@@ -550,7 +550,7 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > auto& cache = colorCache(options); > > if (useSystemAppearance) { >- // Only use NSColor for links when the system appearance is desired. >+ // Special handling for links and other system colors when the system appearance is desired. > auto systemAppearanceColor = [] (Color& color, SEL selector) -> Color { > if (!color.isValid()) { > auto systemColor = wtfObjcMsgSend<NSColor *>([NSColor class], selector); >@@ -561,15 +561,48 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > }; > > switch (cssValueID) { >+ // Web views that want system appearance get the system version of link colors, which differ from the HTML spec. > case CSSValueWebkitLink: > if (forVisitedLink) > return systemAppearanceColor(cache.systemVisitedLinkColor, @selector(systemPurpleColor)); > return systemAppearanceColor(cache.systemLinkColor, @selector(linkColor)); >+ > case CSSValueWebkitActivelink: > // FIXME: Use a semantic system color for this, instead of systemRedColor. <rdar://problem/39256684> > return systemAppearanceColor(cache.systemActiveLinkColor, @selector(systemRedColor)); >+ >+ // The following colors would expose user appearance preferences to the web, and could be used for fingerprinting. >+ // These should only be available when the web view is wanting the system appearance. >+ case CSSValueWebkitFocusRingColor: >+ case CSSValueActiveborder: >+ return systemAppearanceColor(cache.systemFocusRingColor, @selector(keyboardFocusIndicatorColor)); >+ >+ case CSSValueAppleSystemControlAccent: >+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 >+ return systemAppearanceColor(cache.systemControlAccentColor, @selector(controlAccentColor)); >+#else >+ return systemAppearanceColor(cache.systemControlAccentColor, @selector(alternateSelectedControlColor)); >+#endif >+ >+ case CSSValueAppleSystemSelectedContentBackground: >+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 >+ return systemAppearanceColor(cache.systemSelectedContentBackgroundColor, @selector(selectedContentBackgroundColor)); >+#else >+ return systemAppearanceColor(cache.systemSelectedContentBackgroundColor, @selector(alternateSelectedControlColor)); >+#endif >+ >+ case CSSValueAppleSystemSelectedTextBackground: >+ case CSSValueHighlight: >+ // Can't use systemAppearanceColor() since blendWithWhite() needs called before caching as a semantic color. >+ if (!cache.systemSelectedTextBackgroundColor.isValid()) { >+ Color systemColor = semanticColorFromNSColor([NSColor selectedTextBackgroundColor]); >+ cache.systemSelectedTextBackgroundColor = Color(systemColor.blendWithWhite().rgb(), Color::Semantic); >+ } >+ >+ return cache.systemSelectedTextBackgroundColor; >+ > default: >- // Handle non-link colors below, with the regular cache. >+ // Handle other system colors below, that don't need special system appearance handling. > break; > } > } else if (forVisitedLink && cssValueID == CSSValueWebkitLink) { >@@ -580,11 +613,9 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > > ASSERT(!forVisitedLink); > >- return cache.systemStyleColors.ensure(cssValueID, [this, cssValueID, options] () -> Color { >+ return cache.systemStyleColors.ensure(cssValueID, [this, cssValueID, options, &localAppearance] () -> Color { > auto selectCocoaColor = [cssValueID] () -> SEL { > switch (cssValueID) { >- case CSSValueActiveborder: >- return @selector(keyboardFocusIndicatorColor); > case CSSValueActivecaption: > return @selector(windowFrameTextColor); > case CSSValueAppworkspace: >@@ -599,8 +630,6 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > return @selector(textColor); > case CSSValueGraytext: > return @selector(disabledControlTextColor); >- case CSSValueHighlight: >- return @selector(selectedTextBackgroundColor); > case CSSValueHighlighttext: > return @selector(selectedTextColor); > case CSSValueInactiveborder: >@@ -625,8 +654,6 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > return @selector(highlightColor); > case CSSValueThreedlightshadow: > return @selector(controlLightHighlightColor); >- case CSSValueWebkitFocusRingColor: >- return @selector(keyboardFocusIndicatorColor); > case CSSValueWindow: > return @selector(windowBackgroundColor); > case CSSValueWindowframe: >@@ -641,18 +668,6 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > return @selector(controlBackgroundColor); > case CSSValueAppleSystemAlternateSelectedText: > return @selector(alternateSelectedControlTextColor); >- case CSSValueAppleSystemControlAccent: >-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 >- return @selector(controlAccentColor); >-#else >- return @selector(alternateSelectedControlColor); >-#endif >- case CSSValueAppleSystemSelectedContentBackground: >-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 >- return @selector(selectedContentBackgroundColor); >-#else >- return @selector(alternateSelectedControlColor); >-#endif > case CSSValueAppleSystemUnemphasizedSelectedContentBackground: > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 > return @selector(unemphasizedSelectedContentBackgroundColor); >@@ -667,8 +682,6 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > #else > return @selector(textColor); > #endif >- case CSSValueAppleSystemSelectedTextBackground: >- return @selector(selectedTextBackgroundColor); > case CSSValueAppleSystemUnemphasizedSelectedTextBackground: > #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 > return @selector(unemphasizedSelectedTextBackgroundColor); >@@ -748,6 +761,31 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O > case CSSValueMenu: > return menuBackgroundColor(); > >+ case CSSValueWebkitFocusRingColor: >+ case CSSValueActiveborder: >+ // Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting. >+ if (localAppearance.usingDarkAppearance()) >+ return Color(0x4C1AA9FF, Color::Semantic); >+ return Color(0x3F0067F4, Color::Semantic); >+ >+ case CSSValueAppleSystemControlAccent: >+ // Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting. >+ // Same color in light and dark appearances. >+ return Color(0xFF007AFF, Color::Semantic); >+ >+ case CSSValueAppleSystemSelectedContentBackground: >+ // Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting. >+ if (localAppearance.usingDarkAppearance()) >+ return Color(0xFF0058D0, Color::Semantic); >+ return Color(0xFF0063E1, Color::Semantic); >+ >+ case CSSValueHighlight: >+ case CSSValueAppleSystemSelectedTextBackground: >+ // Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting. >+ if (localAppearance.usingDarkAppearance()) >+ return Color(0xCC0F3C6E, Color::Semantic); >+ return Color(0x9980BCFE, Color::Semantic); >+ > #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300 > case CSSValueAppleSystemFindHighlightBackground: > return platformActiveTextSearchHighlightColor(options); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index a9ef7687588152174a06b5cb6d6f90b5a9c47a22..6298ccbbe593744b98072817dba91529215a6804 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2018-07-31 Timothy Hatcher <timothy@apple.com> >+ >+ Hardcode some system colors to avoid fingerprinting exposure. >+ https://bugs.webkit.org/show_bug.cgi?id=188203 >+ rdar://problem/42781630 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/css/apple-system-control-colors-expected.txt: Updated. >+ * fast/css/test-setting-canvas-color.html: Fixed for colors with alpha. >+ * platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt: >+ * platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt: Updated. >+ * platform/mac/TestExpectations: Removed fast/css/test-setting-canvas-color.html. >+ * platform/mac/fast/css/apple-system-control-colors-expected.txt: Updated. >+ > 2018-07-31 Ryan Haddad <ryanhaddad@apple.com> > > Layout Test media/video-add-autoplay-user-gesture.html is flaky. >diff --git a/LayoutTests/fast/css/apple-system-control-colors-expected.txt b/LayoutTests/fast/css/apple-system-control-colors-expected.txt >index bfdf27016aba6d61c714ecee50f57f60e8d2e88d..427a7a809fa452268b1edfa1731d9039eeca4e7a 100644 >--- a/LayoutTests/fast/css/apple-system-control-colors-expected.txt >+++ b/LayoutTests/fast/css/apple-system-control-colors-expected.txt >@@ -9,7 +9,7 @@ > -apple-system-unemphasized-selected-content-background : rgb(212, 212, 212) > -apple-system-selected-text : rgb(0, 0, 0) > -apple-system-unemphasized-selected-text : rgb(0, 0, 0) >--apple-system-selected-text-background : rgb(181, 213, 255) >+-apple-system-selected-text-background : rgba(128, 188, 254, 0.6) > -apple-system-unemphasized-selected-text-background : rgb(212, 212, 212) > -apple-system-placeholder-text : rgba(0, 0, 0, 0.247059) > -apple-system-find-highlight-background : rgb(255, 255, 0) >diff --git a/LayoutTests/fast/css/test-setting-canvas-color.html b/LayoutTests/fast/css/test-setting-canvas-color.html >index bfc684cbdd9ad6dd6d91f4968ed181bca2873453..6434cc8a159cd2b07b327d96f269c83ed15b1067 100644 >--- a/LayoutTests/fast/css/test-setting-canvas-color.html >+++ b/LayoutTests/fast/css/test-setting-canvas-color.html >@@ -21,7 +21,7 @@ function shouldSuccessfullyParse(color) { > ctx.fillStyle = "#f00"; > ctx.fillStyle = color; > // Check that there is no red. >- if (ctx.fillStyle.match(/^#(?!(FF0000|ff0000|f00)$)/)) >+ if (ctx.fillStyle.match(/^#(?!(FF0000|ff0000|f00)$)/) || ctx.fillStyle !== "rgb(255, 0, 0)") > testPassed("Setting color to " + color + " was successfully set."); > else > testFailed("Setting color to " + color + " was not set but should!"); >@@ -31,7 +31,7 @@ function shouldNotSuccessfullyParse(color) { > ctx.fillStyle = "#0f0"; > ctx.fillStyle = color; > // Check that the color is still green. >- if (ctx.fillStyle.match(/^#(00FF00|00ff00|0f0)$/)) >+ if (ctx.fillStyle.match(/^#(00FF00|00ff00|0f0)$/) || ctx.fillStyle === "rgb(0, 255, 0)") > testPassed("Setting color to " + color + " was not set (as expected)."); > else > testFailed("Setting color to " + color + " was successfully set but should not!"); >diff --git a/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt b/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt >index bfdf27016aba6d61c714ecee50f57f60e8d2e88d..8c144e3c88c78032ce30ff3ce808b371193d95b8 100644 >--- a/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt >+++ b/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt >@@ -2,14 +2,14 @@ > -apple-system-text-background : rgb(255, 255, 255) > -apple-system-control-background : rgb(255, 255, 255) > -apple-system-alternate-selected-text : rgb(255, 255, 255) >--apple-system-control-accent : rgb(0, 105, 217) >+-apple-system-control-accent : rgb(0, 122, 255) > -apple-system-even-alternating-content-background : rgb(255, 255, 255) > -apple-system-odd-alternating-content-background : rgb(245, 245, 245) >--apple-system-selected-content-background : rgb(0, 105, 217) >+-apple-system-selected-content-background : rgb(0, 99, 225) > -apple-system-unemphasized-selected-content-background : rgb(212, 212, 212) > -apple-system-selected-text : rgb(0, 0, 0) > -apple-system-unemphasized-selected-text : rgb(0, 0, 0) >--apple-system-selected-text-background : rgb(181, 213, 255) >+-apple-system-selected-text-background : rgba(128, 188, 254, 0.6) > -apple-system-unemphasized-selected-text-background : rgb(212, 212, 212) > -apple-system-placeholder-text : rgba(0, 0, 0, 0.247059) > -apple-system-find-highlight-background : rgb(255, 255, 0) >diff --git a/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt b/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt >index bfdf27016aba6d61c714ecee50f57f60e8d2e88d..8c144e3c88c78032ce30ff3ce808b371193d95b8 100644 >--- a/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt >+++ b/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt >@@ -2,14 +2,14 @@ > -apple-system-text-background : rgb(255, 255, 255) > -apple-system-control-background : rgb(255, 255, 255) > -apple-system-alternate-selected-text : rgb(255, 255, 255) >--apple-system-control-accent : rgb(0, 105, 217) >+-apple-system-control-accent : rgb(0, 122, 255) > -apple-system-even-alternating-content-background : rgb(255, 255, 255) > -apple-system-odd-alternating-content-background : rgb(245, 245, 245) >--apple-system-selected-content-background : rgb(0, 105, 217) >+-apple-system-selected-content-background : rgb(0, 99, 225) > -apple-system-unemphasized-selected-content-background : rgb(212, 212, 212) > -apple-system-selected-text : rgb(0, 0, 0) > -apple-system-unemphasized-selected-text : rgb(0, 0, 0) >--apple-system-selected-text-background : rgb(181, 213, 255) >+-apple-system-selected-text-background : rgba(128, 188, 254, 0.6) > -apple-system-unemphasized-selected-text-background : rgb(212, 212, 212) > -apple-system-placeholder-text : rgba(0, 0, 0, 0.247059) > -apple-system-find-highlight-background : rgb(255, 255, 0) >diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations >index 208080d5652d342b3a5f44498969d7332f0f104a..8e3d39557c6619a7f55737a906e28eb4810de919 100644 >--- a/LayoutTests/platform/mac/TestExpectations >+++ b/LayoutTests/platform/mac/TestExpectations >@@ -1794,9 +1794,6 @@ webkit.org/b/187393 imported/w3c/web-platform-tests/2dcontext/imagebitmap/create > > [ Mojave+ ] http/tests/cookies/same-site [ Pass ] > >-# <rdar://problem/39118706> REGRESSION (Mojave): LayoutTest fast/css/test-setting-canvas-color.html is failing >-[ Mojave+ ] fast/css/test-setting-canvas-color.html [ Failure ] >- > # <rdar://problem/36639117> REGRESSION (Mojave): LayoutTest svg/custom/subpaths-moveto-only-rendering.svg is failing > [ Mojave+ ] svg/custom/subpaths-moveto-only-rendering.svg [ Failure ] > >diff --git a/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt b/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt >index 28c4ac6aa233bb892a280d168a8c60e4f120f2c5..f913ab66fcf0688fb887844b47a6bdf10bcd4645 100644 >--- a/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt >+++ b/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt >@@ -9,7 +9,7 @@ > -apple-system-unemphasized-selected-content-background : rgb(220, 220, 220) > -apple-system-selected-text : rgb(0, 0, 0) > -apple-system-unemphasized-selected-text : rgb(0, 0, 0) >--apple-system-selected-text-background : rgb(179, 215, 255) >+-apple-system-selected-text-background : rgba(128, 188, 254, 0.6) > -apple-system-unemphasized-selected-text-background : rgb(220, 220, 220) > -apple-system-placeholder-text : rgba(0, 0, 0, 0.247059) > -apple-system-find-highlight-background : rgb(255, 255, 0)
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 188203
:
346186
|
346194
|
346196
|
346209
|
346210
|
346218
|
346219
|
346221
| 346254