Expose more system colors via CSS
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 04:04:57 +0000 (04:04 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 04:04:57 +0000 (04:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183764
<rdar://problem/36975898>

Reviewed by Tim Horton.

Test: fast/css/apple-system-control-colors.html

Expose Apple specific system colors via CSS.

* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::systemColor const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229880 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/fast/css/apple-system-control-colors-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/apple-system-control-colors.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/rendering/RenderThemeMac.mm

diff --git a/LayoutTests/fast/css/apple-system-control-colors-expected.txt b/LayoutTests/fast/css/apple-system-control-colors-expected.txt
new file mode 100644 (file)
index 0000000..492e8a5
--- /dev/null
@@ -0,0 +1,9 @@
+-apple-system-header-text : rgb(0, 0, 0)
+-apple-system-text-background : rgb(255, 255, 255)
+-apple-system-alternate-selected-text : rgb(255, 255, 255)
+-apple-system-label : rgb(0, 0, 0)
+-apple-system-secondary-label : rgb(0, 0, 0)
+-apple-system-tertiary-label : rgb(0, 0, 0)
+-apple-system-quaternary-label : rgb(0, 0, 0)
+-apple-system-grid : rgb(204, 204, 204)
+current-color with inherited -apple-system-label : rgb(0, 0, 0)
diff --git a/LayoutTests/fast/css/apple-system-control-colors.html b/LayoutTests/fast/css/apple-system-control-colors.html
new file mode 100644 (file)
index 0000000..d72c3cf
--- /dev/null
@@ -0,0 +1,32 @@
+<script>
+    
+    if (window.testRunner)
+        window.testRunner.dumpAsText();
+    
+    window.addEventListener("load", run, false);
+    
+    function run() {
+        var divs = document.querySelectorAll("div");
+        for (var i = 0; i < divs.length; i++) {
+            var div = divs[i];
+            var span = div.querySelector("span");
+            div.innerHTML += " : " + window.getComputedStyle(span).backgroundColor;
+        }
+    }
+</script>
+<style>
+    .swatch {
+        display: inline-block;
+        width: 40px;
+        height: 40px;
+    }
+</style>
+<div><span class="swatch" style="background-color: -apple-system-header-text"></span>-apple-system-header-text</div>
+<div><span class="swatch" style="background-color: -apple-system-text-background"></span>-apple-system-text-background</div>
+<div><span class="swatch" style="background-color: -apple-system-alternate-selected-text"></span>-apple-system-alternate-selected-text</div>
+<div><span class="swatch" style="background-color: -apple-system-label"></span>-apple-system-label</div>
+<div><span class="swatch" style="background-color: -apple-system-secondary-label"></span>-apple-system-secondary-label</div>
+<div><span class="swatch" style="background-color: -apple-system-tertiary-label"></span>-apple-system-tertiary-label</div>
+<div><span class="swatch" style="background-color: -apple-system-quaternary-label"></span>-apple-system-quaternary-label</div>
+<div><span class="swatch" style="background-color: -apple-system-grid"></span>-apple-system-grid</div>
+<div style="color: -apple-system-label"><span class="swatch" style="background-color: currentcolor;"></span>current-color with inherited -apple-system-label</div>
index c855714..ec639e1 100644 (file)
@@ -1,3 +1,18 @@
+2018-03-22  Megan Gardner  <megan_gardner@apple.com>
+
+        Expose more system colors via CSS
+        https://bugs.webkit.org/show_bug.cgi?id=183764
+        <rdar://problem/36975898>
+
+        Reviewed by Tim Horton.
+
+        Test: fast/css/apple-system-control-colors.html
+
+        Expose Apple specific system colors via CSS.
+
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::systemColor const):
+
 2018-03-22  Nan Wang  <n_wang@apple.com>
 
         AX: Web table row count is incorrect when role row is added to <tr> in DOM
index 352a0df..1433444 100644 (file)
@@ -222,6 +222,14 @@ threedshadow
 window
 windowframe
 windowtext
+-apple-system-header-text
+-apple-system-text-background
+-apple-system-alternate-selected-text
+-apple-system-label
+-apple-system-secondary-label
+-apple-system-tertiary-label
+-apple-system-quaternary-label
+-apple-system-grid
 -apple-wireless-playback-target-active
 -apple-system-blue
 -apple-system-brown
index 7c1c943..d0aa053 100644 (file)
@@ -550,6 +550,22 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, bool useSystemAppearanc
                 return @selector(windowFrameColor);
             case CSSValueWindowtext:
                 return @selector(windowFrameTextColor);
+            case CSSValueAppleSystemHeaderText:
+                return @selector(headerTextColor);
+            case CSSValueAppleSystemTextBackground:
+                return @selector(textBackgroundColor);
+            case CSSValueAppleSystemAlternateSelectedText:
+                return @selector(alternateSelectedControlTextColor);
+            case CSSValueAppleSystemLabel:
+                return @selector(labelColor);
+            case CSSValueAppleSystemSecondaryLabel:
+                return @selector(secondaryLabelColor);
+            case CSSValueAppleSystemTertiaryLabel:
+                return @selector(tertiaryLabelColor);
+            case CSSValueAppleSystemQuaternaryLabel:
+                return @selector(quaternaryLabelColor);
+            case CSSValueAppleSystemGrid:
+                return @selector(gridColor);
             case CSSValueAppleWirelessPlaybackTargetActive:
                 return @selector(systemBlueColor);
             case CSSValueAppleSystemBlue: