- Revision
- 238138
- Author
- timo...@apple.com
- Date
- 2018-11-13 10:44:25 -0800 (Tue, 13 Nov 2018)
Log Message
Treat supported-color-schemes as the second highest priority property.
https://bugs.webkit.org/show_bug.cgi?id=191556
rdar://problem/46000076
Reviewed by Dean Jackson.
Source/WebCore:
Test: css-dark-mode/supported-color-schemes-priority.html
* css/CSSProperties.json: Make supported-color-schemes high-priority and add a comment.
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyMatchedProperties): Manually handle supported-color-schemes
after -webkit-ruby-position, before other properties, so it can affect resolved colors.
LayoutTests:
* css-dark-mode/supported-color-schemes-priority-expected.txt: Added.
* css-dark-mode/supported-color-schemes-priority.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (238137 => 238138)
--- trunk/LayoutTests/ChangeLog 2018-11-13 18:43:17 UTC (rev 238137)
+++ trunk/LayoutTests/ChangeLog 2018-11-13 18:44:25 UTC (rev 238138)
@@ -1,3 +1,14 @@
+2018-11-13 Timothy Hatcher <timo...@apple.com>
+
+ Treat supported-color-schemes as the second highest priority property.
+ https://bugs.webkit.org/show_bug.cgi?id=191556
+ rdar://problem/46000076
+
+ Reviewed by Dean Jackson.
+
+ * css-dark-mode/supported-color-schemes-priority-expected.txt: Added.
+ * css-dark-mode/supported-color-schemes-priority.html: Added.
+
2018-11-13 Youenn Fablet <you...@apple.com>
Refresh WPT webrtc tests to ToT
Added: trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority-expected.txt (0 => 238138)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority-expected.txt (rev 0)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority-expected.txt 2018-11-13 18:44:25 UTC (rev 238138)
@@ -0,0 +1,5 @@
+
+PASS Element colors are correct in light color scheme with light and dark supported color scheme
+PASS Dark color scheme enabled
+PASS Element colors are correct in dark color scheme with light and dark supported color scheme
+
Added: trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority.html (0 => 238138)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority.html (rev 0)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-priority.html 2018-11-13 18:44:25 UTC (rev 238138)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src=""
+<script src=""
+
+<style>
+#test1 {
+ supported-color-schemes: light dark;
+ color: text;
+}
+</style>
+
+<div id="test1"></div>
+
+<script>
+function test_prop(id, prop, expected) {
+ assert_equals(window.getComputedStyle(document.getElementById(id)).getPropertyValue(prop), expected);
+}
+
+function test_color_is_white(id) {
+ test_prop("test1", "color", "rgb(255, 255, 255)");
+}
+
+function test_color_is_black(id) {
+ test_prop("test1", "color", "rgb(0, 0, 0)");
+}
+
+test(function() {
+ // The semantic text color should be black.
+ test_color_is_black("test1");
+}, "Element colors are correct in light color scheme with light and dark supported color scheme");
+
+test(function() {
+ if (window.internals)
+ internals.settings.setUseDarkAppearance(true);
+}, "Dark color scheme enabled");
+
+test(function() {
+ // The semantic text color should be white.
+ test_color_is_white("test1");
+}, "Element colors are correct in dark color scheme with light and dark supported color scheme");
+</script>
Modified: trunk/Source/WebCore/ChangeLog (238137 => 238138)
--- trunk/Source/WebCore/ChangeLog 2018-11-13 18:43:17 UTC (rev 238137)
+++ trunk/Source/WebCore/ChangeLog 2018-11-13 18:44:25 UTC (rev 238138)
@@ -1,3 +1,18 @@
+2018-11-13 Timothy Hatcher <timo...@apple.com>
+
+ Treat supported-color-schemes as the second highest priority property.
+ https://bugs.webkit.org/show_bug.cgi?id=191556
+ rdar://problem/46000076
+
+ Reviewed by Dean Jackson.
+
+ Test: css-dark-mode/supported-color-schemes-priority.html
+
+ * css/CSSProperties.json: Make supported-color-schemes high-priority and add a comment.
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::applyMatchedProperties): Manually handle supported-color-schemes
+ after -webkit-ruby-position, before other properties, so it can affect resolved colors.
+
2018-11-13 Charlie Turner <ctur...@igalia.com>
[EME][GStreamer] Make CDMInstance's available in decryptors, and factor out some EME utility classes.
Modified: trunk/Source/WebCore/css/CSSProperties.json (238137 => 238138)
--- trunk/Source/WebCore/css/CSSProperties.json 2018-11-13 18:43:17 UTC (rev 238137)
+++ trunk/Source/WebCore/css/CSSProperties.json 2018-11-13 18:44:25 UTC (rev 238138)
@@ -5722,7 +5722,9 @@
],
"codegen-properties": {
"converter": "SupportedColorSchemes",
- "enable-if": "ENABLE_DARK_MODE_CSS"
+ "comment": "This is the second highest priority property, to ensure that its value can be checked when resolving colors.",
+ "enable-if": "ENABLE_DARK_MODE_CSS",
+ "high-priority": true
},
"status": {
"status": "non-standard"
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (238137 => 238138)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2018-11-13 18:43:17 UTC (rev 238137)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2018-11-13 18:44:25 UTC (rev 238138)
@@ -1379,6 +1379,11 @@
applyCascadedProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition, applyState);
adjustStyleForInterCharacterRuby();
+#if ENABLE(DARK_MODE_CSS)
+ // Supported color schemes can affect resolved colors, so we need to apply that property before any color properties.
+ applyCascadedProperties(CSSPropertySupportedColorSchemes, CSSPropertySupportedColorSchemes, applyState);
+#endif
+
applyCascadedProperties(firstCSSProperty, lastHighPriorityProperty, applyState);
// If our font got dirtied, update it now.
@@ -1398,12 +1403,16 @@
cascade.addImportantMatches(matchResult, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
cascade.addImportantMatches(matchResult, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
-
ApplyCascadedPropertyState applyState { this, &cascade, &matchResult };
applyCascadedProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition, applyState);
adjustStyleForInterCharacterRuby();
+#if ENABLE(DARK_MODE_CSS)
+ // Supported color schemes can affect resolved colors, so we need to apply that property before any color properties.
+ applyCascadedProperties(CSSPropertySupportedColorSchemes, CSSPropertySupportedColorSchemes, applyState);
+#endif
+
applyCascadedProperties(firstCSSProperty, lastHighPriorityProperty, applyState);
// If the effective zoom value changes, we can't use the matched properties cache. Start over.