Title: [234466] trunk
Revision
234466
Author
timo...@apple.com
Date
2018-08-01 12:07:42 -0700 (Wed, 01 Aug 2018)

Log Message

Hardcode some system colors to avoid fingerprinting exposure.
https://bugs.webkit.org/show_bug.cgi?id=188203
rdar://problem/42781630

Reviewed by Tim Horton.

Source/WebCore:

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().

LayoutTests:

* 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234465 => 234466)


--- trunk/LayoutTests/ChangeLog	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/ChangeLog	2018-08-01 19:07:42 UTC (rev 234466)
@@ -1,3 +1,18 @@
+2018-08-01  Timothy Hatcher  <timo...@apple.com>
+
+        Hardcode some system colors to avoid fingerprinting exposure.
+        https://bugs.webkit.org/show_bug.cgi?id=188203
+        rdar://problem/42781630
+
+        Reviewed by Tim Horton.
+
+        * 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-08-01  Alicia Boya GarcĂ­a  <ab...@igalia.com>
 
         [GTK] Unreviewed test gardening

Modified: trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt (234465 => 234466)


--- trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/fast/css/apple-system-control-colors-expected.txt	2018-08-01 19:07:42 UTC (rev 234466)
@@ -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)

Modified: trunk/LayoutTests/fast/css/test-setting-canvas-color.html (234465 => 234466)


--- trunk/LayoutTests/fast/css/test-setting-canvas-color.html	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/fast/css/test-setting-canvas-color.html	2018-08-01 19:07:42 UTC (rev 234466)
@@ -21,7 +21,7 @@
     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 @@
     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!");

Modified: trunk/LayoutTests/platform/mac/TestExpectations (234465 => 234466)


--- trunk/LayoutTests/platform/mac/TestExpectations	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2018-08-01 19:07:42 UTC (rev 234466)
@@ -1794,9 +1794,6 @@
 
 [ 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 ]
 

Modified: trunk/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt (234465 => 234466)


--- trunk/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/platform/mac/fast/css/apple-system-control-colors-expected.txt	2018-08-01 19:07:42 UTC (rev 234466)
@@ -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)

Modified: trunk/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt (234465 => 234466)


--- trunk/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/platform/mac-highsierra/fast/css/apple-system-control-colors-expected.txt	2018-08-01 19:07:42 UTC (rev 234466)
@@ -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)

Modified: trunk/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt (234465 => 234466)


--- trunk/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/LayoutTests/platform/mac-sierra/fast/css/apple-system-control-colors-expected.txt	2018-08-01 19:07:42 UTC (rev 234466)
@@ -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)

Modified: trunk/Source/WebCore/ChangeLog (234465 => 234466)


--- trunk/Source/WebCore/ChangeLog	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/Source/WebCore/ChangeLog	2018-08-01 19:07:42 UTC (rev 234466)
@@ -1,3 +1,19 @@
+2018-08-01  Timothy Hatcher  <timo...@apple.com>
+
+        Hardcode some system colors to avoid fingerprinting exposure.
+        https://bugs.webkit.org/show_bug.cgi?id=188203
+        rdar://problem/42781630
+
+        Reviewed by Tim Horton.
+
+        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-08-01  Eric Carlson  <eric.carl...@apple.com>
 
         [iOS] Remove the delay before setting audio session category added in r233535

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (234465 => 234466)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2018-08-01 19:07:42 UTC (rev 234466)
@@ -413,6 +413,10 @@
         Color systemLinkColor;
         Color systemActiveLinkColor;
         Color systemVisitedLinkColor;
+        Color systemFocusRingColor;
+        Color systemControlAccentColor;
+        Color systemSelectedTextBackgroundColor;
+        Color systemSelectedContentBackgroundColor;
 
         Color activeSelectionBackgroundColor;
         Color inactiveSelectionBackgroundColor;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (234465 => 234466)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-08-01 18:12:17 UTC (rev 234465)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2018-08-01 19:07:42 UTC (rev 234466)
@@ -550,7 +550,7 @@
     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 @@
         };
 
         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 @@
 
     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 @@
                 return @selector(textColor);
             case CSSValueGraytext:
                 return @selector(disabledControlTextColor);
-            case CSSValueHighlight:
-                return @selector(selectedTextBackgroundColor);
             case CSSValueHighlighttext:
                 return @selector(selectedTextColor);
             case CSSValueInactiveborder:
@@ -625,8 +654,6 @@
                 return @selector(highlightColor);
             case CSSValueThreedlightshadow:
                 return @selector(controlLightHighlightColor);
-            case CSSValueWebkitFocusRingColor:
-                return @selector(keyboardFocusIndicatorColor);
             case CSSValueWindow:
                 return @selector(windowBackgroundColor);
             case CSSValueWindowframe:
@@ -641,18 +668,6 @@
                 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 @@
 #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 @@
         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);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to