WebKit Bugzilla
Attachment 346210 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-20180731151908.patch (text/plain), 14.64 KB, created by
Timothy Hatcher
on 2018-07-31 15:19:08 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Timothy Hatcher
Created:
2018-07-31 15:19:08 PDT
Size:
14.64 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..327b5312d4b0bd4c636dd4f3aad1a24f467284a4 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+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: >+ * platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt: >+ * platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt: >+ * platform/mac/fast/css/apple-system-control-colors-expected.txt: >+ Update results for -apple-system-selected-text-background now that it has alpha. >+ > 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/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..427a7a809fa452268b1edfa1731d9039eeca4e7a 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 >@@ -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/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..427a7a809fa452268b1edfa1731d9039eeca4e7a 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 >@@ -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/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