Add <meta name="supported-color-schemes"> to control what color schemes the page...
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 21:53:55 +0000 (21:53 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Oct 2018 21:53:55 +0000 (21:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190526
rdar://problem/45230140

Reviewed by Dean Jackson.

Source/WebCore:

Test: css-dark-mode/supported-color-schemes.html

* dom/Document.cpp:
(WebCore::isColorSchemeSeparator): Added.
(WebCore::processColorSchemes): Added.
(WebCore::Document::processSupportedColorSchemes): Added.
(WebCore::Document::useDarkAppearance const): Take system appearance and document's
suppoerted color shcemes into account.
* dom/Document.h:
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::createFragment): Update use of LocalDefaultSystemAppearance.
* html/HTMLMetaElement.cpp:
(WebCore::HTMLMetaElement::process): Added supported-color-schemes behind runtime feature check.
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::paint): Update use of LocalDefaultSystemAppearance.
* platform/mac/DragImageMac.mm:
(WebCore::createDragImageForLink): Update use of LocalDefaultSystemAppearance.
* platform/mac/LocalDefaultSystemAppearance.h:
* platform/mac/LocalDefaultSystemAppearance.mm:
(WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
Drop the need for useSystemAppearance. This is accounted for in Document::useDarkAppearance.
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::paint): Update use of LocalDefaultSystemAppearance.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintContents): Update use of LocalDefaultSystemAppearance.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::paintContents): Update use of LocalDefaultSystemAppearance.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::paint): Use document instead of page.
* rendering/RenderThemeCocoa.mm:
(WebCore::RenderThemeCocoa::drawLineForDocumentMarker): Update use of LocalDefaultSystemAppearance.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::documentViewFor const): Update use of LocalDefaultSystemAppearance.
(WebCore::RenderThemeMac::platformActiveSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::transformSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::supportsSelectionForegroundColors const): Ditto.
(WebCore::RenderThemeMac::platformActiveSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveListBoxSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveListBoxSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformInactiveListBoxSelectionForegroundColor const): Ditto.
(WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Ditto.
(WebCore::RenderThemeMac::colorCache const): Ditto.
(WebCore::RenderThemeMac::systemColor const): Ditto.
(WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Ditto.
(WebCore::RenderThemeMac::paintSliderThumb): Ditto.
(WebCore::RenderThemeMac::usingDarkAppearance const): No need to limit to macOS here.
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::draw): Update use of LocalDefaultSystemAppearance.

Source/WebKit:

* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView drawRect:]): Update use of LocalDefaultSystemAppearance.
* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::paintControlForLayerInContext): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::drawRect): Ditto.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebEditorClient.mm:
(_WebCreateFragment): Update use of LocalDefaultSystemAppearance.

LayoutTests:

* css-dark-mode/supported-color-schemes-expected.txt: Added.
* css-dark-mode/supported-color-schemes.html: Added.

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

28 files changed:
LayoutTests/ChangeLog
LayoutTests/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
LayoutTests/css-dark-mode/supported-color-schemes.html [new file with mode: 0644]
LayoutTests/platform/mac-highsierra/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/css-dark-mode/supported-color-schemes-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/html/HTMLMetaElement.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/platform/mac/DragImageMac.mm
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.h
Source/WebCore/platform/mac/LocalDefaultSystemAppearance.mm
Source/WebCore/platform/mac/ThemeMac.mm
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderThemeCocoa.mm
Source/WebCore/rendering/RenderThemeMac.mm
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WKPrintingView.mm
Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm

index bbd97cb..9f6b5ab 100644 (file)
@@ -1,3 +1,14 @@
+2018-10-16  Timothy Hatcher  <timothy@apple.com>
+
+        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
+        https://bugs.webkit.org/show_bug.cgi?id=190526
+        rdar://problem/45230140
+
+        Reviewed by Dean Jackson.
+
+        * css-dark-mode/supported-color-schemes-expected.txt: Added.
+        * css-dark-mode/supported-color-schemes.html: Added.
+
 2018-10-16  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Canvas: capture previously saved states and add them to the recording payload
diff --git a/LayoutTests/css-dark-mode/supported-color-schemes-expected.txt b/LayoutTests/css-dark-mode/supported-color-schemes-expected.txt
new file mode 100644 (file)
index 0000000..0a51dca
--- /dev/null
@@ -0,0 +1,23 @@
+
+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 empty 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 
+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 
+
diff --git a/LayoutTests/css-dark-mode/supported-color-schemes.html b/LayoutTests/css-dark-mode/supported-color-schemes.html
new file mode 100644 (file)
index 0000000..0127a31
--- /dev/null
@@ -0,0 +1,129 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<style>
+#test1 {
+    color: text;
+}
+</style>
+
+<meta id="meta" name="supported-color-schemes" content="light">
+
+<div id="test1"></div>
+
+<script>
+function test_prop(id, prop, expected) {
+    assert_equals(window.getComputedStyle(document.getElementById(id)).getPropertyValue(prop).trim(), 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.getElementById("meta").content = "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.getElementById("meta").content = "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.getElementById("meta").content = "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.getElementById("meta").content = "";
+}, "Supported color schemes changed to empty 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() {
+    document.getElementById("meta").content = "   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.getElementById("meta").content = ", 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>
diff --git a/LayoutTests/platform/mac-highsierra/css-dark-mode/supported-color-schemes-expected.txt b/LayoutTests/platform/mac-highsierra/css-dark-mode/supported-color-schemes-expected.txt
new file mode 100644 (file)
index 0000000..96f9086
--- /dev/null
@@ -0,0 +1,23 @@
+
+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 
+FAIL Element colors are correct in dark color scheme with light and dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Light color scheme enabled 
+PASS Supported color schemes changed to dark 
+FAIL Element colors are correct in light color scheme with only dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Dark color scheme enabled 
+FAIL Element colors are correct in dark color scheme with only dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+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 empty 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 
+FAIL Element colors are correct in dark color scheme with light and dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Supported color schemes changed to a bogus value and dark 
+FAIL Element colors are correct in dark color scheme with dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+
diff --git a/LayoutTests/platform/mac-sierra/css-dark-mode/supported-color-schemes-expected.txt b/LayoutTests/platform/mac-sierra/css-dark-mode/supported-color-schemes-expected.txt
new file mode 100644 (file)
index 0000000..96f9086
--- /dev/null
@@ -0,0 +1,23 @@
+
+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 
+FAIL Element colors are correct in dark color scheme with light and dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Light color scheme enabled 
+PASS Supported color schemes changed to dark 
+FAIL Element colors are correct in light color scheme with only dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Dark color scheme enabled 
+FAIL Element colors are correct in dark color scheme with only dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+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 empty 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 
+FAIL Element colors are correct in dark color scheme with light and dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+PASS Supported color schemes changed to a bogus value and dark 
+FAIL Element colors are correct in dark color scheme with dark supported color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)"
+
index e3d1359..43dfff0 100644 (file)
@@ -1,3 +1,63 @@
+2018-10-16  Timothy Hatcher  <timothy@apple.com>
+
+        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
+        https://bugs.webkit.org/show_bug.cgi?id=190526
+        rdar://problem/45230140
+
+        Reviewed by Dean Jackson.
+
+        Test: css-dark-mode/supported-color-schemes.html
+
+        * dom/Document.cpp:
+        (WebCore::isColorSchemeSeparator): Added.
+        (WebCore::processColorSchemes): Added.
+        (WebCore::Document::processSupportedColorSchemes): Added.
+        (WebCore::Document::useDarkAppearance const): Take system appearance and document's
+        suppoerted color shcemes into account.
+        * dom/Document.h:
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::createFragment): Update use of LocalDefaultSystemAppearance.
+        * html/HTMLMetaElement.cpp:
+        (WebCore::HTMLMetaElement::process): Added supported-color-schemes behind runtime feature check.
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::paint): Update use of LocalDefaultSystemAppearance.
+        * platform/mac/DragImageMac.mm:
+        (WebCore::createDragImageForLink): Update use of LocalDefaultSystemAppearance.
+        * platform/mac/LocalDefaultSystemAppearance.h:
+        * platform/mac/LocalDefaultSystemAppearance.mm:
+        (WebCore::LocalDefaultSystemAppearance::LocalDefaultSystemAppearance):
+        Drop the need for useSystemAppearance. This is accounted for in Document::useDarkAppearance.
+        * platform/mac/ThemeMac.mm:
+        (WebCore::ThemeMac::paint): Update use of LocalDefaultSystemAppearance.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintContents): Update use of LocalDefaultSystemAppearance.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::paintContents): Update use of LocalDefaultSystemAppearance.
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::paint): Use document instead of page.
+        * rendering/RenderThemeCocoa.mm:
+        (WebCore::RenderThemeCocoa::drawLineForDocumentMarker): Update use of LocalDefaultSystemAppearance.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::documentViewFor const): Update use of LocalDefaultSystemAppearance.
+        (WebCore::RenderThemeMac::platformActiveSelectionBackgroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformInactiveSelectionBackgroundColor const): Ditto.
+        (WebCore::RenderThemeMac::transformSelectionBackgroundColor const): Ditto.
+        (WebCore::RenderThemeMac::supportsSelectionForegroundColors const): Ditto.
+        (WebCore::RenderThemeMac::platformActiveSelectionForegroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformInactiveSelectionForegroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformActiveListBoxSelectionBackgroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformActiveListBoxSelectionForegroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformInactiveListBoxSelectionForegroundColor const): Ditto.
+        (WebCore::RenderThemeMac::platformActiveTextSearchHighlightColor const): Ditto.
+        (WebCore::RenderThemeMac::colorCache const): Ditto.
+        (WebCore::RenderThemeMac::systemColor const): Ditto.
+        (WebCore::RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary): Ditto.
+        (WebCore::RenderThemeMac::paintSliderThumb): Ditto.
+        (WebCore::RenderThemeMac::usingDarkAppearance const): No need to limit to macOS here.
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::draw): Update use of LocalDefaultSystemAppearance.
+
 2018-10-16  Rob Buis  <rbuis@igalia.com>
 
         Remove superfluous VIDEO build guard
index 4ec008e..582c394 100644 (file)
@@ -3556,6 +3556,54 @@ void Document::updateViewportArguments()
     }
 }
 
+#if ENABLE(DARK_MODE_CSS)
+static bool isColorSchemeSeparator(UChar character)
+{
+    return isASCIISpace(character) || character == ',';
+}
+
+static void processColorSchemes(StringView colorSchemes, const WTF::Function<void(StringView key)>& callback)
+{
+    unsigned length = colorSchemes.length();
+    for (unsigned i = 0; i < length; ) {
+        // Skip to first non-separator.
+        while (i < length && isColorSchemeSeparator(colorSchemes[i]))
+            ++i;
+        unsigned keyBegin = i;
+
+        // Skip to first separator.
+        while (i < length && !isColorSchemeSeparator(colorSchemes[i]))
+            ++i;
+        unsigned keyEnd = i;
+
+        if (keyBegin == keyEnd)
+            continue;
+
+        callback(colorSchemes.substring(keyBegin, keyEnd - keyBegin));
+    }
+}
+
+void Document::processSupportedColorSchemes(const String& colorSchemes)
+{
+    OptionSet<ColorSchemes> supportedColorSchemes;
+
+    processColorSchemes(colorSchemes, [&supportedColorSchemes](StringView key) {
+        if (equalLettersIgnoringASCIICase(key, "light"))
+            supportedColorSchemes.add(ColorSchemes::Light);
+        else if (equalLettersIgnoringASCIICase(key, "dark"))
+            supportedColorSchemes.add(ColorSchemes::Dark);
+    });
+
+    if (supportedColorSchemes.isEmpty())
+        supportedColorSchemes.add(ColorSchemes::Light);
+
+    m_supportedColorSchemes = supportedColorSchemes;
+
+    if (auto* page = this->page())
+        page->updateStyleAfterChangeInEnvironment();
+}
+#endif
+
 #if PLATFORM(IOS)
 
 void Document::processFormatDetection(const String& features)
@@ -7211,10 +7259,26 @@ bool Document::useSystemAppearance() const
 
 bool Document::useDarkAppearance() const
 {
-    bool useDarkAppearance = false;
+#if ENABLE(DARK_MODE_CSS)
+    if (m_supportedColorSchemes.contains(ColorSchemes::Dark) && !m_supportedColorSchemes.contains(ColorSchemes::Light))
+        return true;
+#endif
+
+    bool pageUsesDarkAppearance = false;
     if (Page* documentPage = page())
-        useDarkAppearance = documentPage->useDarkAppearance();
-    return useDarkAppearance;
+        pageUsesDarkAppearance = documentPage->useDarkAppearance();
+
+    if (useSystemAppearance())
+        return pageUsesDarkAppearance;
+
+#if ENABLE(DARK_MODE_CSS)
+    if (m_supportedColorSchemes.contains(ColorSchemes::Dark))
+        return pageUsesDarkAppearance;
+
+    ASSERT(m_supportedColorSchemes.contains(ColorSchemes::Light));
+#endif
+
+    return false;
 }
 
 OptionSet<StyleColor::Options> Document::styleColorOptions() const
index cc0ade8..5e44874 100644 (file)
@@ -572,8 +572,8 @@ public:
 
     float deviceScaleFactor() const;
 
-    bool useSystemAppearance() const;
-    bool useDarkAppearance() const;
+    WEBCORE_EXPORT bool useSystemAppearance() const;
+    WEBCORE_EXPORT bool useDarkAppearance() const;
 
     OptionSet<StyleColor::Options> styleColorOptions() const;
 
@@ -895,6 +895,15 @@ public:
     void updateViewportArguments();
     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
+
     // Returns the owning element in the parent document.
     // Returns 0 if this is the top level document.
     HTMLFrameOwnerElement* ownerElement() const;
@@ -1751,6 +1760,10 @@ private:
     std::unique_ptr<SVGDocumentExtensions> m_svgExtensions;
     HashSet<SVGUseElement*> m_svgUseElements;
 
+#if ENABLE(DARK_MODE_CSS)
+    OptionSet<ColorSchemes> m_supportedColorSchemes { ColorSchemes::Light };
+#endif
+
 #if ENABLE(DASHBOARD_SUPPORT)
     Vector<AnnotatedRegionValue> m_annotatedRegions;
     bool m_hasAnnotatedRegions { false };
index c5a88f3..1c80793 100644 (file)
@@ -132,8 +132,7 @@ static FragmentAndResources createFragment(Frame& frame, NSAttributedString *str
     Document& document = *frame.document();
 
 #if PLATFORM(MAC)
-    auto* page = frame.page();
-    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
 #endif
 
     NSArray *subresources = nil;
index 0acebca..79bc87d 100644 (file)
@@ -91,6 +91,10 @@ void HTMLMetaElement::process()
         document().processViewport(contentValue, ViewportArguments::ViewportMeta);
     else if (RuntimeEnabledFeatures::sharedFeatures().disabledAdaptationsMetaTagEnabled() && equalLettersIgnoringASCIICase(name(), "disabled-adaptations"))
         document().processDisabledAdaptations(contentValue);
+#if ENABLE(DARK_MODE_CSS)
+    else if (RuntimeEnabledFeatures::sharedFeatures().darkModeCSSEnabled() && equalLettersIgnoringASCIICase(name(), "supported-color-schemes"))
+        document().processSupportedColorSchemes(contentValue);
+#endif
 #if PLATFORM(IOS)
     else if (equalLettersIgnoringASCIICase(name(), "format-detection"))
         document().processFormatDetection(contentValue);
index 1725e93..d5def90 100644 (file)
@@ -181,7 +181,7 @@ void InspectorOverlay::paint(GraphicsContext& context)
         return;
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(m_page.useSystemAppearance(), m_page.useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(m_page.mainFrame().document()->useDarkAppearance());
 #endif
 
     GraphicsContextStateSaver stateSaver(context);
index 201cb33..11cda24 100644 (file)
@@ -300,9 +300,7 @@ DragImageRef createDragImageForLink(Element& element, URL& url, const String& ti
 {
     LinkImageLayout layout(url, title);
 
-    Page* page = element.document().page();
-
-    LocalDefaultSystemAppearance localAppearance(true, page ? page->useDarkAppearance() : false);
+    LocalDefaultSystemAppearance localAppearance(element.document().useDarkAppearance());
 
     auto imageSize = layout.boundingRect.size();
 #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
index ef65be0..1cb1b2b 100644 (file)
@@ -40,7 +40,7 @@ class LocalDefaultSystemAppearance {
     WTF_MAKE_NONCOPYABLE(LocalDefaultSystemAppearance);
 
 public:
-    WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDarkAppearance);
+    WEBCORE_EXPORT LocalDefaultSystemAppearance(bool useDarkAppearance);
     WEBCORE_EXPORT ~LocalDefaultSystemAppearance();
 
     bool usingDarkAppearance() const
index 1d5f7e1..6b6821e 100644 (file)
 
 namespace WebCore {
 
-LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useSystemAppearance, bool useDarkAppearance)
+LocalDefaultSystemAppearance::LocalDefaultSystemAppearance(bool useDarkAppearance)
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
     m_savedSystemAppearance = [NSAppearance currentAppearance];
-    m_usingDarkAppearance = useSystemAppearance && useDarkAppearance;
+    m_usingDarkAppearance = useDarkAppearance;
 
     [NSAppearance setCurrentAppearance:[NSAppearance appearanceNamed:m_usingDarkAppearance ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua]];
 #else
-    UNUSED_PARAM(useSystemAppearance);
     UNUSED_PARAM(useDarkAppearance);
 #endif
 }
index 3473426..955d693 100644 (file)
@@ -907,7 +907,9 @@ void ThemeMac::inflateControlPaintRect(ControlPart part, const ControlStates& st
 
 void ThemeMac::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView* scrollView, float deviceScaleFactor, float pageScaleFactor, bool useSystemAppearance, bool useDarkAppearance)
 {
-    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
+    UNUSED_PARAM(useSystemAppearance);
+
+    LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
 
     switch (part) {
         case CheckboxPart:
index e12c869..148020b 100644 (file)
@@ -2541,7 +2541,7 @@ void RenderLayerBacking::paintContents(const GraphicsLayer* graphicsLayer, Graph
 #endif
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(renderer().page().useSystemAppearance(), renderer().page().useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(renderer().document().useDarkAppearance());
 #endif
 
     // The dirtyRect is in the coords of the painting root.
index b0cba54..1655337 100644 (file)
@@ -2782,7 +2782,7 @@ void paintScrollbar(Scrollbar* scrollbar, GraphicsContext& context, const IntRec
 void RenderLayerCompositor::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase, const FloatRect& clip, GraphicsLayerPaintBehavior)
 {
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(page().useSystemAppearance(), page().useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(m_renderView.document().useDarkAppearance());
 #endif
 
     IntRect pixelSnappedRectForIntegralPositionedItems = snappedIntRect(LayoutRect(clip));
index 34f3a1e..a487a3c 100644 (file)
@@ -317,7 +317,7 @@ bool RenderTheme::paint(const RenderBox& box, ControlStates& controlStates, cons
     case ButtonPart:
     case InnerSpinButtonPart:
         updateControlStatesForRenderer(box, controlStates);
-        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.page().useSystemAppearance(), box.page().useDarkAppearance());
+        Theme::singleton().paint(part, controlStates, paintInfo.context(), devicePixelSnappedRect, box.style().effectiveZoom(), &box.view().frameView(), deviceScaleFactor, pageScaleFactor, box.document().useSystemAppearance(), box.document().useDarkAppearance());
         return false;
     default:
         break;
index 1f88aed..835a695 100644 (file)
@@ -56,7 +56,7 @@ void RenderThemeCocoa::drawLineForDocumentMarker(const RenderText& renderer, Gra
     if (context.paintingDisabled())
         return;
 
-    auto circleColor = colorForMarkerLineStyle(style, renderer.page().useSystemAppearance() && renderer.page().useDarkAppearance());
+    auto circleColor = colorForMarkerLineStyle(style, renderer.document().useDarkAppearance());
 
     // Center the underline and ensure we only draw entire dots.
     FloatPoint offsetPoint = origin;
index 91cd6de..6b8dbcd 100644 (file)
@@ -297,7 +297,7 @@ RenderThemeMac::RenderThemeMac()
 
 NSView *RenderThemeMac::documentViewFor(const RenderObject& o) const
 {
-    LocalDefaultSystemAppearance localAppearance(o.page().useSystemAppearance(), o.page().useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
     ControlStates states(extractControlStatesForRenderer(o));
     return ThemeMac::ensuredView(&o.view().frameView(), states);
 }
@@ -392,14 +392,14 @@ String RenderThemeMac::imageControlsStyleSheet() const
 
 Color RenderThemeMac::platformActiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
 {
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor selectedTextBackgroundColor]);
 }
 
 Color RenderThemeMac::platformInactiveSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor unemphasizedSelectedTextBackgroundColor]);
 #else
     UNUSED_PARAM(options);
@@ -409,7 +409,7 @@ Color RenderThemeMac::platformInactiveSelectionBackgroundColor(OptionSet<StyleCo
 
 Color RenderThemeMac::transformSelectionBackgroundColor(const Color& color, OptionSet<StyleColor::Options> options) const
 {
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     if (localAppearance.usingDarkAppearance()) {
         // Use an alpha value that is similar to results from blendWithWhite() on light colors.
         static const float darkAppearanceAlpha = 0.8;
@@ -421,13 +421,13 @@ Color RenderThemeMac::transformSelectionBackgroundColor(const Color& color, Opti
 
 bool RenderThemeMac::supportsSelectionForegroundColors(OptionSet<StyleColor::Options> options) const
 {
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return localAppearance.usingDarkAppearance();
 }
 
 Color RenderThemeMac::platformActiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
 {
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     if (localAppearance.usingDarkAppearance())
         return colorFromNSColor([NSColor selectedTextColor]);
     return { };
@@ -436,7 +436,7 @@ Color RenderThemeMac::platformActiveSelectionForegroundColor(OptionSet<StyleColo
 Color RenderThemeMac::platformInactiveSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     if (localAppearance.usingDarkAppearance())
         return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
     return { };
@@ -449,7 +449,7 @@ Color RenderThemeMac::platformInactiveSelectionForegroundColor(OptionSet<StyleCo
 Color RenderThemeMac::platformActiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor selectedContentBackgroundColor]);
 #else
     UNUSED_PARAM(options);
@@ -460,7 +460,7 @@ Color RenderThemeMac::platformActiveListBoxSelectionBackgroundColor(OptionSet<St
 Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor unemphasizedSelectedContentBackgroundColor]);
 #else
     UNUSED_PARAM(options);
@@ -470,14 +470,14 @@ Color RenderThemeMac::platformInactiveListBoxSelectionBackgroundColor(OptionSet<
 
 Color RenderThemeMac::platformActiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
 {
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor alternateSelectedControlTextColor]);
 }
 
 Color RenderThemeMac::platformInactiveListBoxSelectionForegroundColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor unemphasizedSelectedTextColor]);
 #else
     UNUSED_PARAM(options);
@@ -495,7 +495,7 @@ Color RenderThemeMac::platformFocusRingColor(OptionSet<StyleColor::Options> opti
 Color RenderThemeMac::platformActiveTextSearchHighlightColor(OptionSet<StyleColor::Options> options) const
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
-    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseSystemAppearance), options.contains(StyleColor::Options::UseDarkAppearance));
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     return colorFromNSColor([NSColor findHighlightColor]);
 #else
     UNUSED_PARAM(options);
@@ -612,9 +612,7 @@ void RenderThemeMac::platformColorsDidChange()
 
 auto RenderThemeMac::colorCache(OptionSet<StyleColor::Options> options) const -> ColorCache&
 {
-    const bool useSystemAppearance = options.contains(StyleColor::Options::UseSystemAppearance);
-    const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
-    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
     if (localAppearance.usingDarkAppearance())
         return m_darkColorCache;
     return RenderTheme::colorCache(options);
@@ -626,7 +624,7 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O
     const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
     const bool forVisitedLink = options.contains(StyleColor::Options::ForVisitedLink);
 
-    LocalDefaultSystemAppearance localAppearance(useSystemAppearance, useDarkAppearance);
+    LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
 
     auto& cache = colorCache(options);
 
@@ -1802,7 +1800,7 @@ void RenderThemeMac::setPopupButtonCellState(const RenderObject& o, const IntSiz
 
 void RenderThemeMac::paintCellAndSetFocusedElementNeedsRepaintIfNecessary(NSCell* cell, const RenderObject& renderer, const PaintInfo& paintInfo, const FloatRect& rect)
 {
-    LocalDefaultSystemAppearance localAppearance(renderer.page().useSystemAppearance(), renderer.page().useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(renderer));
     bool shouldDrawFocusRing = isFocused(renderer) && renderer.style().outlineStyleIsAuto() == OutlineIsAuto::On;
     bool shouldUseImageBuffer = renderer.style().effectiveZoom() != 1 || renderer.page().pageScaleFactor() != 1;
     bool shouldDrawCell = true;
@@ -1884,7 +1882,7 @@ bool RenderThemeMac::paintSliderThumb(const RenderObject& o, const PaintInfo& pa
         ? sliderThumbVertical()
         : sliderThumbHorizontal();
 
-    LocalDefaultSystemAppearance localAppearance(o.page().useSystemAppearance(), o.page().useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(usingDarkAppearance(o));
 
     LocalCurrentGraphicsContext localContext(paintInfo.context());
 
@@ -2997,12 +2995,7 @@ bool RenderThemeMac::paintAttachment(const RenderObject& renderer, const PaintIn
 
 bool RenderThemeMac::usingDarkAppearance(const RenderObject& o) const
 {
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-    return o.page().useSystemAppearance() && o.page().useDarkAppearance();
-#else
-    UNUSED_PARAM(o);
-    return false;
-#endif
+    return o.document().useDarkAppearance();
 }
 
 CGColorRef RenderThemeMac::colorForMarkerLineStyle(DocumentMarkerLineStyle style, bool useDarkMode)
index 088c10b..91ef851 100644 (file)
@@ -324,7 +324,8 @@ ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec
     }
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(m_page->useSystemAppearance(), m_page->useDarkAppearance());
+    auto* document = m_page->mainFrame().document();
+    LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
 #endif
 
     view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect)));
index 05a037c..9972177 100644 (file)
@@ -1,3 +1,20 @@
+2018-10-16  Timothy Hatcher  <timothy@apple.com>
+
+        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
+        https://bugs.webkit.org/show_bug.cgi?id=190526
+        rdar://problem/45230140
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/mac/WKPrintingView.mm:
+        (-[WKPrintingView drawRect:]): Update use of LocalDefaultSystemAppearance.
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::renderedImage): Ditto.
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::paintControlForLayerInContext): Ditto.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::drawRect): Ditto.
+
 2018-10-16  Justin Michaud  <justin_michaud@apple.com>
 
         Implement feature flag and bindings for CSS Painting API
index d206ffe..aa53743 100644 (file)
@@ -556,11 +556,8 @@ static NSString *linkDestinationName(PDFDocument *document, PDFDestination *dest
 
     ASSERT(_printOperation == [NSPrintOperation currentOperation]);
 
-    auto* page = _webFrame->page();
-    if (!page)
-        return;
-
-    WebCore::LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
+    // Always use the light appearance when printing.
+    WebCore::LocalDefaultSystemAppearance localAppearance(false);
 
     if ([self _isPrintingPreview]) {
         [self _drawPreview:nsRect];
index 6a80186..3f4f567 100644 (file)
@@ -124,7 +124,7 @@ RefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions option
         return nullptr;
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(frame->page()->useSystemAppearance(), frame->page()->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(ownerDocument.useDarkAppearance());
 #endif
 
     Ref<Frame> protector(*frame);
index 49b2225..d20760e 100644 (file)
@@ -1219,7 +1219,7 @@ void PDFPlugin::paintControlForLayerInContext(CALayer *layer, CGContextRef conte
 {
 #if PLATFORM(MAC)
     auto* page = webFrame()->coreFrame()->page();
-    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(page->useDarkAppearance());
 #endif
 
     GraphicsContext graphicsContext(context);
index e1f6727..321acbb 100644 (file)
@@ -1541,7 +1541,8 @@ void WebPage::scrollMainFrameIfNotAtMaxScrollPosition(const IntSize& scrollOffse
 void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
 {
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(m_page->useSystemAppearance(), m_page->useDarkAppearance());
+    auto* document = m_mainFrame->coreFrame()->document();
+    LocalDefaultSystemAppearance localAppearance(document ? document->useDarkAppearance() : false);
 #endif
 
     GraphicsContextStateSaver stateSaver(graphicsContext);
index b05e12d..b1b1adb 100644 (file)
@@ -1,3 +1,14 @@
+2018-10-16  Timothy Hatcher  <timothy@apple.com>
+
+        Add <meta name="supported-color-schemes"> to control what color schemes the page supports
+        https://bugs.webkit.org/show_bug.cgi?id=190526
+        rdar://problem/45230140
+
+        Reviewed by Dean Jackson.
+
+        * WebCoreSupport/WebEditorClient.mm:
+        (_WebCreateFragment): Update use of LocalDefaultSystemAppearance.
+
 2018-10-16  Justin Michaud  <justin_michaud@apple.com>
 
         Implement feature flag and bindings for CSS Painting API
index 3180429..0c073a6 100644 (file)
@@ -478,8 +478,7 @@ static NSDictionary *attributesForAttributedStringConversion()
 void _WebCreateFragment(Document& document, NSAttributedString *string, FragmentAndResources& result)
 {
 #if PLATFORM(MAC)
-    auto* page = document.page();
-    LocalDefaultSystemAppearance localAppearance(page->useSystemAppearance(), page->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(document.useDarkAppearance());
 #endif
 
     static NSDictionary *documentAttributes = [attributesForAttributedStringConversion() retain];