Diff
Modified: trunk/LayoutTests/ChangeLog (238000 => 238001)
--- trunk/LayoutTests/ChangeLog 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/LayoutTests/ChangeLog 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1,3 +1,16 @@
+2018-11-08 Timothy Hatcher <[email protected]>
+
+ Add experimental support for a `supported-color-schemes` CSS property.
+ https://bugs.webkit.org/show_bug.cgi?id=191319
+ rdar://problem/45852261
+
+ Reviewed by Dean Jackson.
+
+ * css-dark-mode/parse-supported-color-schemes-expected.txt: Added.
+ * css-dark-mode/parse-supported-color-schemes.html: Added.
+ * css-dark-mode/supported-color-schemes-css-expected.txt: Added.
+ * css-dark-mode/supported-color-schemes-css.html: Added.
+
2018-11-08 Per Arne Vollan <[email protected]>
[Sierra Release WK2] Layout Test media/track/track-cue-css.html is a flaky failure
Added: trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes-expected.txt (0 => 238001)
--- trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes-expected.txt (rev 0)
+++ trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes-expected.txt 2018-11-08 21:57:40 UTC (rev 238001)
@@ -0,0 +1,4 @@
+
+PASS Test valid values
+PASS Test invalid values
+
Added: trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes.html (0 => 238001)
--- trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes.html (rev 0)
+++ trunk/LayoutTests/css-dark-mode/parse-supported-color-schemes.html 2018-11-08 21:57:40 UTC (rev 238001)
@@ -0,0 +1,128 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src=""
+<script src=""
+
+<style>
+#testAuto {
+ supported-color-schemes: auto;
+}
+
+#testOnly {
+ supported-color-schemes: only;
+}
+
+#testLight {
+ supported-color-schemes: light;
+}
+
+#testDark {
+ supported-color-schemes: dark;
+}
+
+#testLightDark {
+ supported-color-schemes: light dark;
+}
+
+#testDarkLight {
+ supported-color-schemes: dark light;
+}
+
+#testLightDarkOnly {
+ supported-color-schemes: light dark only;
+}
+
+#testOnlyDark {
+ supported-color-schemes: only dark;
+}
+
+#testLightOnlyDark {
+ supported-color-schemes: light only dark;
+}
+
+#testLightUnknown {
+ supported-color-schemes: light foo;
+}
+
+#testUnknownDarkOnly {
+ supported-color-schemes: bar dark only;
+}
+
+#testLightUnknownOnly {
+ supported-color-schemes: light baz only;
+}
+
+#testInvalidLightAuto {
+ supported-color-schemes: light auto;
+}
+
+#testInvalidAutoDark {
+ supported-color-schemes: auto dark;
+}
+
+#testInvalidLightDarkLight {
+ supported-color-schemes: light dark light;
+}
+
+#testInvalidNumber {
+ supported-color-schemes: 42;
+}
+
+#testInvalidString {
+ supported-color-schemes: "foo";
+}
+
+#testInvalidLightString {
+ supported-color-schemes: light "foo";
+}
+</style>
+
+<div id="testAuto"></div>
+<div id="testOnly"></div>
+<div id="testLight"></div>
+<div id="testDark"></div>
+<div id="testLightDark"></div>
+<div id="testDarkLight"></div>
+<div id="testLightDarkOnly"></div>
+<div id="testOnlyDark"></div>
+<div id="testLightOnlyDark"></div>
+<div id="testLightUnknown"></div>
+<div id="testUnknownDarkOnly"></div>
+
+<div id="testInvalidLightAuto"></div>
+<div id="testInvalidAutoDark"></div>
+<div id="testInvalidLightDarkLight"></div>
+<div id="testInvalidNumber"></div>
+<div id="testInvalidString"></div>
+<div id="testInvalidLightString"></div>
+
+<script>
+function test_prop(id, property, expected) {
+ assert_equals(window.getComputedStyle(document.getElementById(id)).getPropertyValue(property), expected);
+}
+
+test(function() {
+ test_prop("testAuto", "supported-color-schemes", "auto");
+ test_prop("testOnly", "supported-color-schemes", "light only");
+ test_prop("testLight", "supported-color-schemes", "light");
+ test_prop("testDark", "supported-color-schemes", "dark");
+ test_prop("testLightDark", "supported-color-schemes", "light dark");
+ test_prop("testDarkLight", "supported-color-schemes", "light dark");
+ test_prop("testLightDarkOnly", "supported-color-schemes", "light dark only");
+ test_prop("testOnlyDark", "supported-color-schemes", "dark only");
+ test_prop("testLightOnlyDark", "supported-color-schemes", "light dark only");
+ test_prop("testLightUnknown", "supported-color-schemes", "light");
+ test_prop("testUnknownDarkOnly", "supported-color-schemes", "dark only");
+}, "Test valid values");
+
+test(function() {
+ test_prop("testInvalidLightAuto", "supported-color-schemes", "auto");
+ test_prop("testInvalidAutoDark", "supported-color-schemes", "auto");
+ test_prop("testInvalidLightDarkLight", "supported-color-schemes", "auto");
+ test_prop("testInvalidNumber", "supported-color-schemes", "auto");
+ test_prop("testInvalidString", "supported-color-schemes", "auto");
+ test_prop("testInvalidLightString", "supported-color-schemes", "auto");
+}, "Test invalid values");
+</script>
Added: trunk/LayoutTests/css-dark-mode/supported-color-schemes-css-expected.txt (0 => 238001)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-css-expected.txt (rev 0)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-css-expected.txt 2018-11-08 21:57:40 UTC (rev 238001)
@@ -0,0 +1,28 @@
+
+PASS Element colors are correct in light color scheme with only light supported color scheme
+PASS Dark color scheme enabled
+PASS Element colors are correct in dark color scheme with only light supported color scheme
+PASS Light color scheme enabled
+PASS Supported color schemes changed to light and dark
+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
+PASS Light color scheme enabled
+PASS Supported color schemes changed to dark
+PASS Element colors are correct in light color scheme with only dark supported color scheme
+PASS Dark color scheme enabled
+PASS Element colors are correct in dark color scheme with only dark supported color scheme
+PASS Supported color schemes changed to light and a bogus value
+PASS Element colors are correct in dark color scheme with only light supported color scheme
+PASS Supported color schemes changed to auto value
+PASS Element colors are correct in dark color scheme with implicit light supported color scheme
+PASS Supported color schemes changed to light and dark via <meta> element
+PASS Element colors are correct in dark color scheme with light and dark supported color scheme via <meta> element
+PASS Supported color schemes changed to light value
+PASS Element colors are correct in dark color scheme with explicit light, overriding <meta> element
+PASS Remove test meta element
+PASS Supported color schemes changed to light and dark
+PASS Element colors are correct in dark color scheme with light and dark supported color scheme
+PASS Supported color schemes changed to a bogus value and dark
+PASS Element colors are correct in dark color scheme with dark supported color scheme
+
Added: trunk/LayoutTests/css-dark-mode/supported-color-schemes-css.html (0 => 238001)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-css.html (rev 0)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-css.html 2018-11-08 21:57:40 UTC (rev 238001)
@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src=""
+<script src=""
+
+<style>
+#test1 {
+ 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 only light supported color scheme");
+
+test(function() {
+ if (window.internals)
+ internals.settings.setUseDarkAppearance(true);
+}, "Dark color scheme enabled");
+
+test(function() {
+ // The semantic text color should be black, and not change.
+ test_color_is_black("test1");
+}, "Element colors are correct in dark color scheme with only light supported color scheme");
+
+test(function() {
+ if (window.internals)
+ internals.settings.setUseDarkAppearance(false);
+}, "Light color scheme enabled");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "light dark");
+}, "Supported color schemes changed to light and dark");
+
+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");
+
+test(function() {
+ if (window.internals)
+ internals.settings.setUseDarkAppearance(false);
+}, "Light color scheme enabled");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "dark");
+}, "Supported color schemes changed to dark");
+
+test(function() {
+ // The semantic text color should be white.
+ test_color_is_white("test1");
+}, "Element colors are correct in light color scheme with only 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 still.
+ test_color_is_white("test1");
+}, "Element colors are correct in dark color scheme with only dark supported color scheme");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "light foo");
+}, "Supported color schemes changed to light and a bogus value");
+
+test(function() {
+ // The semantic text color should be black again.
+ test_color_is_black("test1");
+}, "Element colors are correct in dark color scheme with only light supported color scheme");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "auto");
+}, "Supported color schemes changed to auto value");
+
+test(function() {
+ // The semantic text color should be black still.
+ test_color_is_black("test1");
+}, "Element colors are correct in dark color scheme with implicit light supported color scheme");
+
+test(function() {
+ let meta = document.createElement("meta");
+ meta.id = "test-meta";
+ meta.name = "supported-color-schemes";
+ meta.content = "light dark";
+ document.head.appendChild(meta);
+}, "Supported color schemes changed to light and dark via <meta> element");
+
+test(function() {
+ // The semantic text color should be white now.
+ test_color_is_white("test1");
+}, "Element colors are correct in dark color scheme with light and dark supported color scheme via <meta> element");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "light");
+}, "Supported color schemes changed to light value");
+
+test(function() {
+ // The semantic text color should be black again.
+ test_color_is_black("test1");
+}, "Element colors are correct in dark color scheme with explicit light, overriding <meta> element");
+
+test(function() {
+ document.getElementById("test-meta").remove();
+}, "Remove test meta element");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "light dark");
+}, "Supported color schemes changed to light and dark");
+
+test(function() {
+ // The semantic text color should be white now.
+ test_color_is_white("test1");
+}, "Element colors are correct in dark color scheme with light and dark supported color scheme");
+
+test(function() {
+ document.body.style.setProperty("supported-color-schemes", "foo dark");
+}, "Supported color schemes changed to a bogus value and dark");
+
+test(function() {
+ // The semantic text color should be white still.
+ test_color_is_white("test1");
+}, "Element colors are correct in dark color scheme with dark supported color scheme");
+</script>
Modified: trunk/Source/WebCore/ChangeLog (238000 => 238001)
--- trunk/Source/WebCore/ChangeLog 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/ChangeLog 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1,3 +1,106 @@
+2018-11-08 Timothy Hatcher <[email protected]>
+
+ Add experimental support for a `supported-color-schemes` CSS property.
+ https://bugs.webkit.org/show_bug.cgi?id=191319
+ rdar://problem/45852261
+
+ Reviewed by Dean Jackson.
+
+ Tests: css-dark-mode/parse-supported-color-schemes.html
+ css-dark-mode/supported-color-schemes-css.html
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::valueForPropertyinStyle):
+ * css/CSSProperties.json:
+ * css/CSSValueKeywords.in:
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::updateSupportedColorSchemes):
+ (WebCore::StyleBuilderConverter::convertSupportedColorSchemes):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::colorFromPrimitiveValue const):
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeSupportedColorSchemes):
+ (WebCore::CSSPropertyParser::parseSingleValue):
+ * dom/Document.cpp:
+ (WebCore::Document::resetLinkColor):
+ (WebCore::Document::resetVisitedLinkColor):
+ (WebCore::Document::resetActiveLinkColor):
+ (WebCore::Document::processSupportedColorSchemes):
+ (WebCore::Document::useDarkAppearance const):
+ (WebCore::Document::styleColorOptions const):
+ * dom/Document.h:
+ * editing/cocoa/WebContentReaderCocoa.mm:
+ (WebCore::createFragment):
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::drawFocusIfNeededInternal):
+ * inspector/InspectorOverlay.cpp:
+ (WebCore::InspectorOverlay::paint):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::useDarkAppearance const):
+ (WebCore::FrameView::paintScrollCorner):
+ * platform/mac/DragImageMac.mm:
+ (WebCore::createDragImageForLink):
+ * rendering/InlineFlowBox.cpp:
+ (WebCore::InlineFlowBox::paintBoxDecorations):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintPlatformDocumentMarker):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::paintRootBoxFillLayers):
+ (WebCore::RenderBox::paintBackground):
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::selectionColor const):
+ (WebCore::RenderElement::selectionBackgroundColor const):
+ (WebCore::RenderElement::paintFocusRing):
+ * rendering/RenderImage.cpp:
+ (WebCore::RenderImage::paintAreaElementFocusRing):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::paintContents):
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::paintContents):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::paintItemForeground):
+ (WebCore::RenderListBox::paintItemBackground):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::useDarkAppearance const):
+ (WebCore::RenderObject::styleColorOptions const):
+ * rendering/RenderObject.h:
+ * rendering/RenderTableCell.cpp:
+ (WebCore::RenderTableCell::paintBackgroundsBehindCell):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::paint):
+ * rendering/RenderTheme.h:
+ (WebCore::RenderTheme::usingDarkAppearance const): Deleted.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::documentViewFor const):
+ (WebCore::RenderThemeMac::adjustMenuListStyle const):
+ (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary):
+ (WebCore::RenderThemeMac::paintSliderThumb):
+ (WebCore::RenderThemeMac::usingDarkAppearance const): Deleted.
+ * rendering/style/RenderStyle.h:
+ (WebCore::RenderStyle::supportedColorSchemes const):
+ (WebCore::RenderStyle::setSupportedColorSchemes):
+ (WebCore::RenderStyle::initialSupportedColorSchemes):
+ * rendering/style/RenderStyleConstants.h:
+ * rendering/style/StyleRareInheritedData.cpp:
+ (WebCore::StyleRareInheritedData::StyleRareInheritedData):
+ (WebCore::StyleRareInheritedData::operator== const):
+ * rendering/style/StyleRareInheritedData.h:
+ * rendering/style/StyleSupportedColorSchemes.h: Added.
+ (WebCore::StyleSupportedColorSchemes::StyleSupportedColorSchemes):
+ (WebCore::StyleSupportedColorSchemes::operator== const):
+ (WebCore::StyleSupportedColorSchemes::operator!= const):
+ (WebCore::StyleSupportedColorSchemes::isAuto const):
+ (WebCore::StyleSupportedColorSchemes::isOnly const):
+ (WebCore::StyleSupportedColorSchemes::colorSchemes const):
+ (WebCore::StyleSupportedColorSchemes::add):
+ (WebCore::StyleSupportedColorSchemes::contains const):
+ (WebCore::StyleSupportedColorSchemes::setAllowsTransformations):
+ (WebCore::StyleSupportedColorSchemes::allowsTransformations const):
+ * svg/graphics/SVGImage.cpp:
+ (WebCore::SVGImage::draw):
+
2018-11-08 Joseph Pecoraro <[email protected]>
Web Inspector: Restrict domains at the target level instead of only at the window level
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238000 => 238001)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-11-08 21:57:40 UTC (rev 238001)
@@ -625,6 +625,7 @@
1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0106FF192594DF008A4201 /* InlineTextBoxStyle.h */; };
1C0939EB1A13E12900B788E5 /* CachedSVGFont.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0939E91A13E12900B788E5 /* CachedSVGFont.h */; };
1C09D0591E31C6A900725F18 /* libPAL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C09D0501E31C32900725F18 /* libPAL.a */; };
+ 1C0AA16D21940DC800896829 /* StyleSupportedColorSchemes.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C0AA16A21940DC700896829 /* StyleSupportedColorSchemes.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C12AC2B1EE778AE0079E0A0 /* FontFamilySpecificationCoreText.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C12AC291EE778AE0079E0A0 /* FontFamilySpecificationCoreText.h */; settings = {ATTRIBUTES = (Private, ); }; };
1C18DA59181AF6A500C4EF22 /* TextPainter.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C18DA57181AF6A500C4EF22 /* TextPainter.h */; };
1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6374,6 +6375,7 @@
1C0939E81A13E12900B788E5 /* CachedSVGFont.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedSVGFont.cpp; sourceTree = "<group>"; };
1C0939E91A13E12900B788E5 /* CachedSVGFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedSVGFont.h; sourceTree = "<group>"; };
1C09D04B1E31C32800725F18 /* PAL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PAL.xcodeproj; path = PAL/PAL.xcodeproj; sourceTree = "<group>"; };
+ 1C0AA16A21940DC700896829 /* StyleSupportedColorSchemes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleSupportedColorSchemes.h; sourceTree = "<group>"; };
1C12AC281EE778AE0079E0A0 /* FontFamilySpecificationCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontFamilySpecificationCoreText.cpp; sourceTree = "<group>"; };
1C12AC291EE778AE0079E0A0 /* FontFamilySpecificationCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontFamilySpecificationCoreText.h; sourceTree = "<group>"; };
1C12AC2C1EE779950079E0A0 /* FontDescriptionCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontDescriptionCocoa.cpp; sourceTree = "<group>"; };
@@ -24691,6 +24693,7 @@
F47A5E3A195B8C8A00483100 /* StyleScrollSnapPoints.cpp */,
F47A5E3B195B8C8A00483100 /* StyleScrollSnapPoints.h */,
9D63800F1AF16E160031A15C /* StyleSelfAlignmentData.h */,
+ 1C0AA16A21940DC700896829 /* StyleSupportedColorSchemes.h */,
BC5EB5E60E81BFEF00B25965 /* StyleSurroundData.cpp */,
BC5EB5E40E81BF6D00B25965 /* StyleSurroundData.h */,
BC5EB80D0E81F2CE00B25965 /* StyleTransformData.cpp */,
@@ -31095,6 +31098,7 @@
A8EA800C0A19516E00A8EF5F /* StyleSheet.h in Headers */,
E4F9EEF3156DA00700D23E7E /* StyleSheetContents.h in Headers */,
A8EA800A0A19516E00A8EF5F /* StyleSheetList.h in Headers */,
+ 1C0AA16D21940DC800896829 /* StyleSupportedColorSchemes.h in Headers */,
BC5EB5E50E81BF6D00B25965 /* StyleSurroundData.h in Headers */,
BC5EB8100E81F2CE00B25965 /* StyleTransformData.h in Headers */,
E4DEAA1817A93DC3000E0430 /* StyleTreeResolver.h in Headers */,
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (238000 => 238001)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -448,6 +448,9 @@
CSSPropertyStrokeMiterlimit,
CSSPropertyStrokeOpacity,
CSSPropertyStrokeWidth,
+#if ENABLE(DARK_MODE_CSS)
+ CSSPropertySupportedColorSchemes,
+#endif
CSSPropertyAlignmentBaseline,
CSSPropertyBaselineShift,
CSSPropertyDominantBaseline,
@@ -3969,6 +3972,27 @@
return cssValuePool.createValue(style.applePayButtonType());
#endif
+#if ENABLE(DARK_MODE_CSS)
+ case CSSPropertySupportedColorSchemes: {
+ if (!RuntimeEnabledFeatures::sharedFeatures().darkModeCSSEnabled())
+ return nullptr;
+
+ auto supportedColorSchemes = style.supportedColorSchemes();
+ if (supportedColorSchemes.isAuto())
+ return cssValuePool.createIdentifierValue(CSSValueAuto);
+
+ auto list = CSSValueList::createSpaceSeparated();
+ if (supportedColorSchemes.contains(ColorSchemes::Light))
+ list->append(cssValuePool.createIdentifierValue(CSSValueLight));
+ if (supportedColorSchemes.contains(ColorSchemes::Dark))
+ list->append(cssValuePool.createIdentifierValue(CSSValueDark));
+ if (!supportedColorSchemes.allowsTransformations())
+ list->append(cssValuePool.createIdentifierValue(CSSValueOnly));
+ ASSERT(list->length());
+ return WTFMove(list);
+ }
+#endif
+
/* Individual properties not part of the spec */
case CSSPropertyBackgroundRepeatX:
case CSSPropertyBackgroundRepeatY:
Modified: trunk/Source/WebCore/css/CSSProperties.json (238000 => 238001)
--- trunk/Source/WebCore/css/CSSProperties.json 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/CSSProperties.json 2018-11-08 21:57:40 UTC (rev 238001)
@@ -5712,6 +5712,22 @@
},
"status": "non-standard"
},
+ "supported-color-schemes": {
+ "inherited": true,
+ "values": [
+ "auto",
+ "light",
+ "dark",
+ "only"
+ ],
+ "codegen-properties": {
+ "converter": "SupportedColorSchemes",
+ "enable-if": "ENABLE_DARK_MODE_CSS"
+ },
+ "status": {
+ "status": "non-standard"
+ }
+ },
"order": {
"codegen-properties": {
"aliases": [
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (238000 => 238001)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1384,6 +1384,11 @@
light
dark
// no-preference
+
+// supported-color-schemes
+only
+// light
+// dark
#endif
// auto-repeat
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (238000 => 238001)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -77,6 +77,9 @@
template<CSSPropertyID> static NinePieceImage convertBorderMask(StyleResolver&, CSSValue&);
template<CSSPropertyID> static RefPtr<StyleImage> convertStyleImage(StyleResolver&, CSSValue&);
static TransformOperations convertTransform(StyleResolver&, const CSSValue&);
+#if ENABLE(DARK_MODE_CSS)
+ static StyleSupportedColorSchemes convertSupportedColorSchemes(StyleResolver&, const CSSValue&);
+#endif
static String convertString(StyleResolver&, const CSSValue&);
static String convertStringOrAuto(StyleResolver&, const CSSValue&);
static String convertStringOrNone(StyleResolver&, const CSSValue&);
@@ -165,6 +168,10 @@
static Length parseSnapCoordinate(StyleResolver&, const CSSValue&);
#endif
+#if ENABLE(DARK_MODE_CSS)
+ static void updateSupportedColorSchemes(const CSSPrimitiveValue&, StyleSupportedColorSchemes&);
+#endif
+
static Length convertTo100PercentMinusLength(const Length&);
template<CSSValueID, CSSValueID> static Length convertPositionComponent(StyleResolver&, const CSSPrimitiveValue&);
@@ -453,6 +460,48 @@
return operations;
}
+#if ENABLE(DARK_MODE_CSS)
+inline void StyleBuilderConverter::updateSupportedColorSchemes(const CSSPrimitiveValue& primitiveValue, StyleSupportedColorSchemes& supportedColorSchemes)
+{
+ ASSERT(primitiveValue.isValueID());
+
+ switch (primitiveValue.valueID()) {
+ case CSSValueAuto:
+ supportedColorSchemes = StyleSupportedColorSchemes();
+ break;
+ case CSSValueOnly:
+ supportedColorSchemes.setAllowsTransformations(false);
+ break;
+ case CSSValueLight:
+ supportedColorSchemes.add(ColorSchemes::Light);
+ break;
+ case CSSValueDark:
+ supportedColorSchemes.add(ColorSchemes::Dark);
+ break;
+ default:
+ // Unknown identifiers are allowed and ignored.
+ break;
+ }
+}
+
+inline StyleSupportedColorSchemes StyleBuilderConverter::convertSupportedColorSchemes(StyleResolver&, const CSSValue& value)
+{
+ StyleSupportedColorSchemes supportedColorSchemes;
+
+ if (is<CSSValueList>(value)) {
+ for (auto& currentValue : downcast<CSSValueList>(value))
+ updateSupportedColorSchemes(downcast<CSSPrimitiveValue>(currentValue.get()), supportedColorSchemes);
+ } else if (is<CSSPrimitiveValue>(value))
+ updateSupportedColorSchemes(downcast<CSSPrimitiveValue>(value), supportedColorSchemes);
+
+ // If the value was just "only", that is synonymous for "only light".
+ if (supportedColorSchemes.isOnly())
+ supportedColorSchemes.add(ColorSchemes::Light);
+
+ return supportedColorSchemes;
+}
+#endif
+
inline String StyleBuilderConverter::convertString(StyleResolver&, const CSSValue& value)
{
return downcast<CSSPrimitiveValue>(value).stringValue();
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (238000 => 238001)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1841,7 +1841,7 @@
case CSSValueWebkitActivelink:
return document().activeLinkColor();
case CSSValueWebkitFocusRingColor:
- return RenderTheme::focusRingColor(document().styleColorOptions());
+ return RenderTheme::focusRingColor(document().styleColorOptions(m_state.style()));
case CSSValueCurrentcolor:
// Color is an inherited property so depending on it effectively makes the property inherited.
// FIXME: Setting the flag as a side effect of calling this function is a bit oblique. Can we do better?
@@ -1848,7 +1848,7 @@
m_state.style()->setHasExplicitlyInheritedProperties();
return m_state.style()->color();
default:
- return StyleColor::colorFromKeyword(identifier, document().styleColorOptions());
+ return StyleColor::colorFromKeyword(identifier, document().styleColorOptions(m_state.style()));
}
}
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (238000 => 238001)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -3747,7 +3747,51 @@
list->append(CSSValuePool::singleton().createIdentifierValue(leftRightValueID));
return list;
}
-
+
+#if ENABLE(DARK_MODE_CSS)
+
+static RefPtr<CSSValue> consumeSupportedColorSchemes(CSSParserTokenRange& range)
+{
+ if (isAuto(range.peek().id()))
+ return consumeIdent(range);
+
+ Vector<CSSValueID, 3> identifiers;
+
+ while (!range.atEnd()) {
+ if (range.peek().type() != IdentToken)
+ return nullptr;
+
+ CSSValueID id = range.peek().id();
+
+ switch (id) {
+ case CSSValueAuto:
+ // Auto is only allowed as a single value, and was handled earlier.
+ // Don't allow it in the list.
+ return nullptr;
+
+ case CSSValueOnly:
+ case CSSValueLight:
+ case CSSValueDark:
+ if (!identifiers.appendIfNotContains(id))
+ return nullptr;
+ break;
+
+ default:
+ // Unknown identifiers are allowed and ignored.
+ break;
+ }
+
+ range.consumeIncludingWhitespace();
+ }
+
+ RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ for (auto id : identifiers)
+ list->append(CSSValuePool::singleton().createIdentifierValue(id));
+ return list;
+}
+
+#endif
+
#if ENABLE(DASHBOARD_SUPPORT)
static RefPtr<CSSValue> consumeWebkitDashboardRegion(CSSParserTokenRange& range, CSSParserMode mode)
@@ -4289,6 +4333,12 @@
return consumeWebkitAspectRatio(m_range);
case CSSPropertyWebkitTextEmphasisPosition:
return consumeTextEmphasisPosition(m_range);
+#if ENABLE(DARK_MODE_CSS)
+ case CSSPropertySupportedColorSchemes:
+ if (!RuntimeEnabledFeatures::sharedFeatures().darkModeCSSEnabled())
+ return nullptr;
+ return consumeSupportedColorSchemes(m_range);
+#endif
#if ENABLE(DASHBOARD_SUPPORT)
case CSSPropertyWebkitDashboardRegion:
return consumeWebkitDashboardRegion(m_range, m_context.mode);
Modified: trunk/Source/WebCore/dom/Document.cpp (238000 => 238001)
--- trunk/Source/WebCore/dom/Document.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -817,17 +817,17 @@
void Document::resetLinkColor()
{
- m_linkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions());
+ m_linkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions(nullptr));
}
void Document::resetVisitedLinkColor()
{
- m_visitedLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions() | StyleColor::Options::ForVisitedLink);
+ m_visitedLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitLink, styleColorOptions(nullptr) | StyleColor::Options::ForVisitedLink);
}
void Document::resetActiveLinkColor()
{
- m_activeLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitActivelink, styleColorOptions());
+ m_activeLinkColor = StyleColor::colorFromKeyword(CSSValueWebkitActivelink, styleColorOptions(nullptr));
}
DOMImplementation& Document::implementation()
@@ -3590,18 +3590,34 @@
void Document::processSupportedColorSchemes(const String& colorSchemes)
{
OptionSet<ColorSchemes> supportedColorSchemes;
+ bool allowsTransformations = true;
+ bool autoEncountered = false;
- processColorSchemes(colorSchemes, [&supportedColorSchemes](StringView key) {
+ processColorSchemes(colorSchemes, [&](StringView key) {
+ if (equalLettersIgnoringASCIICase(key, "auto")) {
+ supportedColorSchemes = { };
+ allowsTransformations = true;
+ autoEncountered = true;
+ return;
+ }
+
+ if (autoEncountered)
+ return;
+
if (equalLettersIgnoringASCIICase(key, "light"))
supportedColorSchemes.add(ColorSchemes::Light);
else if (equalLettersIgnoringASCIICase(key, "dark"))
supportedColorSchemes.add(ColorSchemes::Dark);
+ else if (equalLettersIgnoringASCIICase(key, "only"))
+ allowsTransformations = false;
});
- if (supportedColorSchemes.isEmpty())
+ // If the value was just "only", that is synonymous for "only light".
+ if (supportedColorSchemes.isEmpty() && !allowsTransformations)
supportedColorSchemes.add(ColorSchemes::Light);
m_supportedColorSchemes = supportedColorSchemes;
+ m_allowsColorSchemeTransformations = allowsTransformations;
if (auto* page = this->page())
page->updateStyleAfterChangeInEnvironment();
@@ -7281,11 +7297,23 @@
return useSystemAppearance;
}
-bool Document::useDarkAppearance() const
+bool Document::useDarkAppearance(const RenderStyle* style) const
{
#if ENABLE(DARK_MODE_CSS)
- if (m_supportedColorSchemes.contains(ColorSchemes::Dark) && !m_supportedColorSchemes.contains(ColorSchemes::Light))
+ OptionSet<ColorSchemes> supportedColorSchemes;
+
+ // Use the style's supported color schemes, if supplied.
+ if (style)
+ supportedColorSchemes = style->supportedColorSchemes().colorSchemes();
+
+ // Fallback to the document's supported color schemes if style was empty (auto).
+ if (supportedColorSchemes.isEmpty())
+ supportedColorSchemes = m_supportedColorSchemes;
+
+ if (supportedColorSchemes.contains(ColorSchemes::Dark) && !supportedColorSchemes.contains(ColorSchemes::Light))
return true;
+#else
+ UNUSED_PARAM(style);
#endif
bool pageUsesDarkAppearance = false;
@@ -7296,21 +7324,19 @@
return pageUsesDarkAppearance;
#if ENABLE(DARK_MODE_CSS)
- if (m_supportedColorSchemes.contains(ColorSchemes::Dark))
+ if (supportedColorSchemes.contains(ColorSchemes::Dark))
return pageUsesDarkAppearance;
-
- ASSERT(m_supportedColorSchemes.contains(ColorSchemes::Light));
#endif
return false;
}
-OptionSet<StyleColor::Options> Document::styleColorOptions() const
+OptionSet<StyleColor::Options> Document::styleColorOptions(const RenderStyle* style) const
{
OptionSet<StyleColor::Options> options;
if (useSystemAppearance())
options.add(StyleColor::Options::UseSystemAppearance);
- if (useDarkAppearance())
+ if (useDarkAppearance(style))
options.add(StyleColor::Options::UseDarkAppearance);
return options;
}
Modified: trunk/Source/WebCore/dom/Document.h (238000 => 238001)
--- trunk/Source/WebCore/dom/Document.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/dom/Document.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -578,9 +578,9 @@
float deviceScaleFactor() const;
WEBCORE_EXPORT bool useSystemAppearance() const;
- WEBCORE_EXPORT bool useDarkAppearance() const;
+ WEBCORE_EXPORT bool useDarkAppearance(const RenderStyle*) const;
- OptionSet<StyleColor::Options> styleColorOptions() const;
+ OptionSet<StyleColor::Options> styleColorOptions(const RenderStyle*) const;
WEBCORE_EXPORT Ref<Range> createRange();
@@ -901,11 +901,6 @@
void processReferrerPolicy(const String& policy, ReferrerPolicySource);
#if ENABLE(DARK_MODE_CSS)
- enum class ColorSchemes : uint8_t {
- Light = 1 << 0,
- Dark = 1 << 1
- };
-
void processSupportedColorSchemes(const String& colorSchemes);
#endif
@@ -1772,7 +1767,8 @@
HashSet<SVGUseElement*> m_svgUseElements;
#if ENABLE(DARK_MODE_CSS)
- OptionSet<ColorSchemes> m_supportedColorSchemes { ColorSchemes::Light };
+ OptionSet<ColorSchemes> m_supportedColorSchemes;
+ bool m_allowsColorSchemeTransformations { true };
#endif
#if ENABLE(DASHBOARD_SUPPORT)
Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (238000 => 238001)
--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm 2018-11-08 21:57:40 UTC (rev 238001)
@@ -50,6 +50,7 @@
#import "MIMETypeRegistry.h"
#import "Page.h"
#import "PublicURLManager.h"
+#import "RenderView.h"
#import "RuntimeEnabledFeatures.h"
#import "SerializedAttachmentData.h"
#import "Settings.h"
@@ -133,7 +134,9 @@
Document& document = *frame.document();
#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
+ auto* view = frame.view();
+ auto* renderView = view ? view->renderView() : nullptr;
+ LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
#endif
NSArray *subresources = nil;
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (238000 => 238001)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -86,7 +86,7 @@
auto* context = drawingContext();
if (!element.focused() || !state().hasInvertibleTransform || path.isEmpty() || !element.isDescendantOf(canvas()) || !context)
return;
- context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document().styleColorOptions()));
+ context->drawFocusRing(path, 1, 1, RenderTheme::focusRingColor(element.document().styleColorOptions(canvas().computedStyle())));
}
String CanvasRenderingContext2D::font() const
Modified: trunk/Source/WebCore/inspector/InspectorOverlay.cpp (238000 => 238001)
--- trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/inspector/InspectorOverlay.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -180,12 +180,13 @@
if (!shouldShowOverlay())
return;
+ GraphicsContextStateSaver stateSaver(context);
+ FrameView* view = overlayPage()->mainFrame().view();
+
#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(m_page.mainFrame().document()->useDarkAppearance());
+ LocalDefaultSystemAppearance localAppearance(view->renderView()->useDarkAppearance());
#endif
- GraphicsContextStateSaver stateSaver(context);
- FrameView* view = overlayPage()->mainFrame().view();
view->updateLayoutAndStyleIfNeededRecursive();
view->paint(context, IntRect(0, 0, view->width(), view->height()));
}
Modified: trunk/Source/WebCore/page/FrameView.cpp (238000 => 238001)
--- trunk/Source/WebCore/page/FrameView.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/page/FrameView.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -2046,9 +2046,7 @@
bool FrameView::useDarkAppearance() const
{
- ASSERT(frame().document());
- auto& document = *frame().document();
- return document.useDarkAppearance();
+ return renderView()->useDarkAppearance();
}
bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
@@ -3911,8 +3909,7 @@
#if PLATFORM(MAC)
// If dark appearance is used or the overlay style is light (because of a dark page background), set the dark apppearance.
// Keep this in sync with ScrollAnimatorMac's effectiveAppearanceForScrollerImp:.
- auto* document = frame().document();
- bool useDarkAppearance = (document && document->useDarkAppearance()) || scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
+ bool useDarkAppearance = renderView()->useDarkAppearance() || scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
#endif
Modified: trunk/Source/WebCore/platform/mac/DragImageMac.mm (238000 => 238001)
--- trunk/Source/WebCore/platform/mac/DragImageMac.mm 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/platform/mac/DragImageMac.mm 2018-11-08 21:57:40 UTC (rev 238001)
@@ -300,7 +300,7 @@
{
LinkImageLayout layout(url, title);
- LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance());
+ LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance(element.computedStyle()));
auto imageSize = layout.boundingRect.size();
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1372,7 +1372,7 @@
Color color = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
CompositeOperator compositeOp = CompositeSourceOver;
- if (renderer().document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && renderer().theme().usingDarkAppearance(renderer()))
+ if (renderer().document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && renderer().useDarkAppearance())
compositeOp = CompositeDestinationOut;
color = lineStyle.colorByApplyingColorFilter(color);
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -716,7 +716,7 @@
auto bounds = calculateDocumentMarkerBounds(markedText);
auto lineStyleForMarkedTextType = [&]() -> DocumentMarkerLineStyle {
- bool shouldUseDarkAppearance = renderer().document().useDarkAppearance();
+ bool shouldUseDarkAppearance = renderer().useDarkAppearance();
switch (markedText.type) {
case MarkedText::SpellingError:
return { DocumentMarkerLineStyle::Mode::Spelling, shouldUseDarkAppearance };
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1207,7 +1207,7 @@
auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
CompositeOperator compositeOp = CompositeSourceOver;
- if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && theme().usingDarkAppearance(*this))
+ if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && useDarkAppearance())
compositeOp = CompositeDestinationOut;
paintFillLayers(paintInfo, style.colorByApplyingColorFilter(color), style.backgroundLayers(), view().backgroundRect(), BackgroundBleedNone, compositeOp, rootBackgroundRenderer);
@@ -1341,7 +1341,7 @@
Color backgroundColor = style().visitedDependentColor(CSSPropertyBackgroundColor);
CompositeOperator compositeOp = CompositeSourceOver;
- if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(backgroundColor) && theme().usingDarkAppearance(*this))
+ if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(backgroundColor) && useDarkAppearance())
compositeOp = CompositeDestinationOut;
paintFillLayers(paintInfo, style().colorByApplyingColorFilter(backgroundColor), style().backgroundLayers(), paintRect, bleedAvoidance, compositeOp);
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1374,8 +1374,8 @@
}
if (frame().selection().isFocusedAndActive())
- return theme().activeSelectionForegroundColor(document().styleColorOptions());
- return theme().inactiveSelectionForegroundColor(document().styleColorOptions());
+ return theme().activeSelectionForegroundColor(styleColorOptions());
+ return theme().inactiveSelectionForegroundColor(styleColorOptions());
}
std::unique_ptr<RenderStyle> RenderElement::selectionPseudoStyle() const
@@ -1409,15 +1409,15 @@
return Color();
if (frame().selection().shouldShowBlockCursor() && frame().selection().isCaret())
- return theme().transformSelectionBackgroundColor(style().visitedDependentColorWithColorFilter(CSSPropertyColor), document().styleColorOptions());
+ return theme().transformSelectionBackgroundColor(style().visitedDependentColorWithColorFilter(CSSPropertyColor), styleColorOptions());
std::unique_ptr<RenderStyle> pseudoStyle = selectionPseudoStyle();
if (pseudoStyle && pseudoStyle->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor).isValid())
- return theme().transformSelectionBackgroundColor(pseudoStyle->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor), document().styleColorOptions());
+ return theme().transformSelectionBackgroundColor(pseudoStyle->visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor), styleColorOptions());
if (frame().selection().isFocusedAndActive())
- return theme().activeSelectionBackgroundColor(document().styleColorOptions());
- return theme().inactiveSelectionBackgroundColor(document().styleColorOptions());
+ return theme().activeSelectionBackgroundColor(styleColorOptions());
+ return theme().inactiveSelectionBackgroundColor(styleColorOptions());
}
bool RenderElement::getLeadingCorner(FloatPoint& point, bool& insideFixed) const
@@ -1838,9 +1838,9 @@
for (auto rect : pixelSnappedFocusRingRects)
path.addRect(rect);
}
- paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(document().styleColorOptions()));
+ paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(styleColorOptions()));
} else
- paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(document().styleColorOptions()));
+ paintInfo.context().drawFocusRing(pixelSnappedFocusRingRects, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(styleColorOptions()));
if (needsRepaint)
page().focusController().setFocusedElementNeedsRepaint();
#else
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -574,7 +574,7 @@
#if PLATFORM(MAC)
bool needsRepaint;
- paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(document().styleColorOptions()));
+ paintInfo.context().drawFocusRing(path, page().focusController().timeSinceFocusWasSet().seconds(), needsRepaint, RenderTheme::focusRingColor(styleColorOptions()));
if (needsRepaint)
page().focusController().setFocusedElementNeedsRepaint();
#else
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -2541,7 +2541,7 @@
#endif
#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(renderer().document().useDarkAppearance());
+ LocalDefaultSystemAppearance localAppearance(renderer().useDarkAppearance());
#endif
// The dirtyRect is in the coords of the painting root.
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -2782,7 +2782,7 @@
void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintBehavior)
{
#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(m_renderView.document().useDarkAppearance());
+ LocalDefaultSystemAppearance localAppearance(m_renderView.useDarkAppearance());
#endif
IntRect pixelSnappedRectForIntegralPositionedItems = snappedIntRect(LayoutRect(clip));
Modified: trunk/Source/WebCore/rendering/RenderListBox.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderListBox.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderListBox.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -428,10 +428,10 @@
Color textColor = itemStyle.visitedDependentColorWithColorFilter(CSSPropertyColor);
if (isOptionElement && downcast<HTMLOptionElement>(*listItemElement).selected()) {
if (frame().selection().isFocusedAndActive() && document().focusedElement() == &selectElement())
- textColor = theme().activeListBoxSelectionForegroundColor(document().styleColorOptions());
+ textColor = theme().activeListBoxSelectionForegroundColor(styleColorOptions());
// Honor the foreground color for disabled items
else if (!listItemElement->isDisabledFormControl() && !selectElement().isDisabledFormControl())
- textColor = theme().inactiveListBoxSelectionForegroundColor(document().styleColorOptions());
+ textColor = theme().inactiveListBoxSelectionForegroundColor(styleColorOptions());
}
paintInfo.context().setFillColor(textColor);
@@ -461,9 +461,9 @@
Color backColor;
if (is<HTMLOptionElement>(*listItemElement) && downcast<HTMLOptionElement>(*listItemElement).selected()) {
if (frame().selection().isFocusedAndActive() && document().focusedElement() == &selectElement())
- backColor = theme().activeListBoxSelectionBackgroundColor(document().styleColorOptions());
+ backColor = theme().activeListBoxSelectionBackgroundColor(styleColorOptions());
else
- backColor = theme().inactiveListBoxSelectionBackgroundColor(document().styleColorOptions());
+ backColor = theme().inactiveListBoxSelectionBackgroundColor(styleColorOptions());
} else
backColor = itemStyle.visitedDependentColorWithColorFilter(CSSPropertyBackgroundColor);
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1801,6 +1801,16 @@
return SetCursorBasedOnStyle;
}
+bool RenderObject::useDarkAppearance() const
+{
+ return document().useDarkAppearance(&style());
+}
+
+OptionSet<StyleColor::Options> RenderObject::styleColorOptions() const
+{
+ return document().styleColorOptions(&style());
+}
+
bool RenderObject::canUpdateSelectionOnRootLineBoxes()
{
if (needsLayout())
Modified: trunk/Source/WebCore/rendering/RenderObject.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderObject.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -176,6 +176,9 @@
return locateEnclosingFragmentedFlow();
}
+ WEBCORE_EXPORT bool useDarkAppearance() const;
+ OptionSet<StyleColor::Options> styleColorOptions() const;
+
#ifndef NDEBUG
void setHasAXObject(bool flag) { m_hasAXObject = flag; }
bool hasAXObject() const { return m_hasAXObject; }
Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderTableCell.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1289,7 +1289,7 @@
CompositeOperator compositeOp = CompositeSourceOver;
Color color = style.visitedDependentColor(CSSPropertyBackgroundColor);
- if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && theme().usingDarkAppearance(*this))
+ if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && useDarkAppearance())
compositeOp = CompositeDestinationOut;
color = style.colorByApplyingColorFilter(color);
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -318,7 +318,7 @@
case ButtonPart:
case InnerSpinButtonPart:
updateControlStatesForRenderer(box, controlStates);
- Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.document().useSystemAppearance(), box.document().useDarkAppearance());
+ Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.document().useSystemAppearance(), box.useDarkAppearance());
return false;
default:
break;
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -261,8 +261,6 @@
virtual void paintSystemPreviewBadge(Image&, const PaintInfo&, const FloatRect&);
#endif
- virtual bool usingDarkAppearance(const RenderObject&) const { return false; }
-
protected:
virtual FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
virtual void updateCachedSystemFontDescription(CSSValueID systemFontID, FontCascadeDescription&) const = 0;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -174,8 +174,6 @@
bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&) final;
#endif
- bool usingDarkAppearance(const RenderObject&) const final;
-
private:
String fileListNameForWidth(const FileList*, const FontCascade&, int width, bool multipleFilesAllowed) const final;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (238000 => 238001)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2018-11-08 21:57:40 UTC (rev 238001)
@@ -297,7 +297,7 @@
NSView *RenderThemeMac::documentViewFor(const RenderObject& o) const
{
- LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
+ LocalDefaultSystemAppearance localAppearance(o.useDarkAppearance());
ControlStates states(extractControlStatesForRenderer(o));
return ThemeMac::ensuredView(&o.view().frameView(), states);
}
@@ -1713,7 +1713,7 @@
// Set the foreground color to black or gray when we have the aqua look.
Color c = Color::darkGray;
if (e) {
- OptionSet<StyleColor::Options> options = e->document().styleColorOptions();
+ OptionSet<StyleColor::Options> options = e->document().styleColorOptions(&style);
c = !e->isDisabledFormControl() ? systemColor(CSSValueButtontext, options) : systemColor(CSSValueGraytext, options);
}
style.setColor(c);
@@ -1800,7 +1800,7 @@
void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
{
- LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(renderer));
+ LocalDefaultSystemAppearance localAppearance(renderer.useDarkAppearance());
bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto() == OutlineIsAuto::On;
bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || renderer.page().pageScaleFactor() != 1;
bool shouldDrawCell = true;
@@ -1882,7 +1882,7 @@
? sliderThumbVertical()
: sliderThumbHorizontal();
- LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
+ LocalDefaultSystemAppearance localAppearance(o.useDarkAppearance());
LocalCurrentGraphicsContext localContext(paintInfo.context());
@@ -2994,11 +2994,6 @@
#endif // ENABLE(ATTACHMENT_ELEMENT)
-bool RenderThemeMac::usingDarkAppearance(const RenderObject& o) const
-{
- return o.document().useDarkAppearance();
-}
-
} // namespace WebCore
#endif // PLATFORM(MAC)
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -84,6 +84,10 @@
#include "TextSizeAdjustment.h"
#endif
+#if ENABLE(DARK_MODE_CSS)
+#include "StyleSupportedColorSchemes.h"
+#endif
+
#define SET_VAR(group, variable, value) do { \
if (!compareEqual(group->variable, value)) \
group.access().variable = value; \
@@ -632,6 +636,10 @@
RubyPosition rubyPosition() const { return static_cast<RubyPosition>(m_rareInheritedData->rubyPosition); }
+#if ENABLE(DARK_MODE_CSS)
+ StyleSupportedColorSchemes supportedColorSchemes() const { return m_rareInheritedData->supportedColorSchemes; }
+#endif
+
TextOrientation textOrientation() const { return static_cast<TextOrientation>(m_rareInheritedData->textOrientation); }
ObjectFit objectFit() const { return static_cast<ObjectFit>(m_rareNonInheritedData->objectFit); }
@@ -1165,6 +1173,10 @@
void setRubyPosition(RubyPosition position) { SET_VAR(m_rareInheritedData, rubyPosition, static_cast<unsigned>(position)); }
+#if ENABLE(DARK_MODE_CSS)
+ void setSupportedColorSchemes(StyleSupportedColorSchemes supported) { SET_VAR(m_rareInheritedData, supportedColorSchemes, supported); }
+#endif
+
void setFilter(const FilterOperations& ops) { SET_NESTED_VAR(m_rareNonInheritedData, filter, operations, ops); }
void setAppleColorFilter(const FilterOperations& ops) { SET_NESTED_VAR(m_rareInheritedData, appleColorFilter, operations, ops); }
@@ -1578,6 +1590,10 @@
static QuotesData* initialQuotes() { return nullptr; }
static const AtomicString& initialContentAltText() { return emptyAtom(); }
+#if ENABLE(DARK_MODE_CSS)
+ static StyleSupportedColorSchemes initialSupportedColorSchemes() { return { }; }
+#endif
+
#if ENABLE(CSS3_TEXT)
static TextIndentLine initialTextIndentLine() { return TextIndentLine::FirstLine; }
static TextIndentType initialTextIndentType() { return TextIndentType::Normal; }
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1018,6 +1018,15 @@
InterCharacter
};
+#if ENABLE(DARK_MODE_CSS)
+enum class ColorSchemes : uint8_t {
+ Light = 1 << 0,
+ Dark = 1 << 1
+};
+
+static const size_t ColorSchemesBits = 2;
+#endif
+
static const size_t GridAutoFlowBits = 4;
enum InternalGridAutoFlowAlgorithm {
InternalAutoFlowAlgorithmSparse = 1 << 0,
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp (238000 => 238001)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -31,6 +31,7 @@
#include "StyleCustomPropertyData.h"
#include "StyleFilterData.h"
#include "StyleImage.h"
+#include "StyleSupportedColorSchemes.h"
#include <wtf/PointerComparison.h>
namespace WebCore {
@@ -67,6 +68,10 @@
Color tapHighlightColor;
#endif
+#if ENABLE(DARK_MODE_CSS)
+ StyleSupportedColorSchemes supportedColorSchemes;
+#endif
+
void* customPropertyDataRefs[1];
};
@@ -153,6 +158,9 @@
#if ENABLE(TOUCH_EVENTS)
, tapHighlightColor(RenderStyle::initialTapHighlightColor())
#endif
+#if ENABLE(DARK_MODE_CSS)
+ , supportedColorSchemes(RenderStyle::initialSupportedColorSchemes())
+#endif
{
}
@@ -251,6 +259,9 @@
#if ENABLE(TOUCH_EVENTS)
, tapHighlightColor(o.tapHighlightColor)
#endif
+#if ENABLE(DARK_MODE_CSS)
+ , supportedColorSchemes(o.supportedColorSchemes)
+#endif
{
}
@@ -297,6 +308,9 @@
#if ENABLE(TEXT_AUTOSIZING)
&& textSizeAdjust == o.textSizeAdjust
#endif
+#if ENABLE(DARK_MODE_CSS)
+ && supportedColorSchemes == o.supportedColorSchemes
+#endif
&& userSelect == o.userSelect
&& speakAs == o.speakAs
&& hyphens == o.hyphens
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (238000 => 238001)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -37,6 +37,10 @@
#include "TextSizeAdjustment.h"
#endif
+#if ENABLE(DARK_MODE_CSS)
+#include "StyleSupportedColorSchemes.h"
+#endif
+
namespace WebCore {
class CursorList;
@@ -181,6 +185,10 @@
Color tapHighlightColor;
#endif
+#if ENABLE(DARK_MODE_CSS)
+ StyleSupportedColorSchemes supportedColorSchemes;
+#endif
+
private:
StyleRareInheritedData();
StyleRareInheritedData(const StyleRareInheritedData&);
Added: trunk/Source/WebCore/rendering/style/StyleSupportedColorSchemes.h (0 => 238001)
--- trunk/Source/WebCore/rendering/style/StyleSupportedColorSchemes.h (rev 0)
+++ trunk/Source/WebCore/rendering/style/StyleSupportedColorSchemes.h 2018-11-08 21:57:40 UTC (rev 238001)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(DARK_MODE_CSS)
+
+#include "RenderStyleConstants.h"
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+
+class StyleSupportedColorSchemes {
+public:
+ StyleSupportedColorSchemes() { }
+
+ StyleSupportedColorSchemes(const StyleSupportedColorSchemes& other)
+ : m_colorSchemes(other.m_colorSchemes)
+ , m_allowsTransformations(other.m_allowsTransformations)
+ { }
+
+ StyleSupportedColorSchemes(OptionSet<ColorSchemes> colorSchemes, bool allowsTransformations)
+ : m_colorSchemes(colorSchemes)
+ , m_allowsTransformations(allowsTransformations)
+ { }
+
+ bool operator==(const StyleSupportedColorSchemes& other) const
+ {
+ return m_colorSchemes == other.m_colorSchemes && m_allowsTransformations == other.m_allowsTransformations;
+ }
+
+ bool operator!=(const StyleSupportedColorSchemes& other) const { return !(*this == other); }
+
+ bool isAuto() const { return m_colorSchemes.isEmpty() && m_allowsTransformations; }
+ bool isOnly() const { return m_colorSchemes.isEmpty() && !m_allowsTransformations; }
+
+ OptionSet<ColorSchemes> colorSchemes() const { return m_colorSchemes; }
+
+ void add(ColorSchemes colorScheme) { m_colorSchemes.add(colorScheme); }
+ bool contains(ColorSchemes colorScheme) const { return m_colorSchemes.contains(colorScheme); }
+
+ void setAllowsTransformations(bool allow) { m_allowsTransformations = allow; }
+ bool allowsTransformations() const { return m_allowsTransformations; }
+
+private:
+ OptionSet<ColorSchemes> m_colorSchemes;
+ bool m_allowsTransformations { true };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(DARK_MODE_CSS)
Modified: trunk/Source/WebCore/svg/graphics/SVGImage.cpp (238000 => 238001)
--- trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebCore/svg/graphics/SVGImage.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -47,6 +47,7 @@
#include "PageConfiguration.h"
#include "RenderSVGRoot.h"
#include "RenderStyle.h"
+#include "RenderView.h"
#include "SVGDocument.h"
#include "SVGFEImageElement.h"
#include "SVGForeignObjectElement.h"
@@ -324,8 +325,7 @@
}
#if PLATFORM(MAC)
- auto* document = m_page->mainFrame().document();
- LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
+ LocalDefaultSystemAppearance localAppearance(view->renderView()->useDarkAppearance());
#endif
view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect)));
Modified: trunk/Source/WebKit/ChangeLog (238000 => 238001)
--- trunk/Source/WebKit/ChangeLog 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebKit/ChangeLog 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1,3 +1,16 @@
+2018-11-08 Timothy Hatcher <[email protected]>
+
+ Add experimental support for a `supported-color-schemes` CSS property.
+ https://bugs.webkit.org/show_bug.cgi?id=191319
+ rdar://problem/45852261
+
+ Reviewed by Dean Jackson.
+
+ * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+ (WebKit::InjectedBundleRangeHandle::renderedImage):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::drawRect):
+
2018-11-08 Eric Carlson <[email protected]>
[MediaStream] Use DeviceIdHashSaltStorage to generate device ID hash salt
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (238000 => 238001)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -41,6 +41,7 @@
#include <WebCore/JSRange.h>
#include <WebCore/Page.h>
#include <WebCore/Range.h>
+#include <WebCore/RenderView.h>
#include <WebCore/VisibleSelection.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
@@ -124,7 +125,8 @@
return nullptr;
#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(ownerDocument.useDarkAppearance());
+ RenderView* renderView = frameView->renderView();
+ LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
#endif
Ref<Frame> protector(*frame);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (238000 => 238001)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-11-08 21:57:40 UTC (rev 238001)
@@ -1556,8 +1556,8 @@
void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
{
#if PLATFORM(MAC)
- auto* document = m_mainFrame->coreFrame()->document();
- LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
+ RenderView* renderView = m_page->mainFrame().view()->renderView();
+ LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
#endif
GraphicsContextStateSaver stateSaver(graphicsContext);
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm (238000 => 238001)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2018-11-08 21:46:51 UTC (rev 238000)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm 2018-11-08 21:57:40 UTC (rev 238001)
@@ -92,10 +92,6 @@
#import "WebUIKitDelegate.h"
#endif
-#if PLATFORM(MAC)
-#import <WebCore/LocalDefaultSystemAppearance.h>
-#endif
-
using namespace WebCore;
using namespace HTMLNames;
@@ -477,10 +473,6 @@
void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
{
-#if PLATFORM(MAC)
- LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
-#endif
-
static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];
NSArray *subresources;
DOMDocumentFragment* fragment = [string _documentFromRange:NSMakeRange(0, [string length])