Use a light scrollbar for transparent web views in dark mode.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 01:15:24 +0000 (01:15 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2018 01:15:24 +0000 (01:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191559
rdar://problem/46000489

Reviewed by Dean Jackson.

Source/WebCore:

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

* css/CSSProperties.json: Marked supported-color-schemes as a custom Value.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueSupportedColorSchemes):
* editing/cocoa/WebContentReaderCocoa.mm: Use FrameView's useDarkAppearance().
(WebCore::createFragment):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::paint): Use FrameView's useDarkAppearance().
* page/FrameView.cpp:
(WebCore::FrameView::recalculateScrollbarOverlayStyle): Use a light scrollbar for
transparent web views in dark mode.
(WebCore::FrameView::rendererForSupportedColorSchemes const): Added.
Return the body for document element renderer.
(WebCore::FrameView::useDarkAppearance const): Use rendererForSupportedColorSchemes.
(WebCore::FrameView::styleColorOptions const): Added. Ditto.
* page/FrameView.h:
* rendering/style/RenderStyle.cpp:
(WebCore::rareInheritedDataChangeRequiresRepaint): Drive-by fix. Added supportedColorSchemes.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::setHasExplicitlySetSupportedColorSchemes): Added.
(WebCore::RenderStyle::hasExplicitlySetSupportedColorSchemes const): Added.
(WebCore::RenderStyle::NonInheritedFlags::operator== const): Added supportedColorSchemes.
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::draw): Use FrameView's useDarkAppearance().
* testing/Internals.cpp:
(WebCore::Internals::setViewIsTransparent): Added.
(WebCore::Internals::scrollbarOverlayStyle const): Added.
* testing/Internals.h:
* testing/Internals.idl: Added setViewIsTransparent and scrollbarOverlayStyle.

Source/WebKit:

* WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::renderedImage): Use FrameView's useDarkAppaearance().
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::drawRect): Ditto.

LayoutTests:

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

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt [new file with mode: 0644]
LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSProperties.json
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/svg/graphics/SVGImage.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp

index 1cb854a..96c3d3d 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-13  Timothy Hatcher  <timothy@apple.com>
+
+        Use a light scrollbar for transparent web views in dark mode.
+        https://bugs.webkit.org/show_bug.cgi?id=191559
+        rdar://problem/46000489
+
+        Reviewed by Dean Jackson.
+
+        * css-dark-mode/supported-color-schemes-scrollbar-expected.txt: Added.
+        * css-dark-mode/supported-color-schemes-scrollbar.html: Added.
+
 2018-11-13  Ross Kirsling  <ross.kirsling@sony.com>
 
         [WinCairo] Unreviewed layout test gardening.
diff --git a/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt b/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt
new file mode 100644 (file)
index 0000000..074a0db
--- /dev/null
@@ -0,0 +1,11 @@
+
+PASS Set dark appearance 
+PASS Set view to transparent 
+PASS Body Element supported color scheme is light and dark 
+PASS Document Element supported color scheme is auto 
+PASS Scrollbar overlay style is light 
+PASS Set prefers-color-schemes: light on the document element 
+PASS Body Element supported color scheme is light and dark 
+PASS Document Element supported color scheme is light 
+PASS Scrollbar overlay style is default 
+
diff --git a/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html b/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html
new file mode 100644 (file)
index 0000000..b7d037b
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+
+<!-- webkit-test-runner [ experimental:DarkModeCSSEnabled=true ] -->
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<style>
+body {
+    supported-color-schemes: light dark;
+}
+</style>
+
+<body></body>
+
+<script>
+function test_prop(element, prop, expected) {
+    assert_equals(window.getComputedStyle(element).getPropertyValue(prop), expected);
+}
+
+test(function() {
+    if (!window.internals)
+        return;
+    internals.settings.setUseDarkAppearance(true);
+}, "Set dark appearance");
+
+test(function() {
+    if (!window.internals)
+        return;
+    internals.setViewIsTransparent(true);
+}, "Set view to transparent");
+
+test(function() {
+    test_prop(document.body, "supported-color-schemes", "light dark");
+}, "Body Element supported color scheme is light and dark");
+
+test(function() {
+    test_prop(document.documentElement, "supported-color-schemes", "auto");
+}, "Document Element supported color scheme is auto");
+
+test(function() {
+    if (!window.internals)
+        return;
+    assert_equals(internals.scrollbarOverlayStyle(), "light");
+}, "Scrollbar overlay style is light");
+
+test(function() {
+    let styleElement = document.createElement("style");
+    styleElement.textContent = ":root { supported-color-schemes: light }";
+    document.head.appendChild(styleElement);
+}, "Set prefers-color-schemes: light on the document element");
+
+test(function() {
+    test_prop(document.body, "supported-color-schemes", "light dark");
+}, "Body Element supported color scheme is light and dark");
+
+test(function() {
+    test_prop(document.documentElement, "supported-color-schemes", "light");
+}, "Document Element supported color scheme is light");
+
+test(function() {
+    if (!window.internals)
+        return;
+    assert_equals(internals.scrollbarOverlayStyle(), "default");
+}, "Scrollbar overlay style is default");
+</script>
index f6f456f..e8a8432 100644 (file)
@@ -1,3 +1,42 @@
+2018-11-13  Timothy Hatcher  <timothy@apple.com>
+
+        Use a light scrollbar for transparent web views in dark mode.
+        https://bugs.webkit.org/show_bug.cgi?id=191559
+        rdar://problem/46000489
+
+        Reviewed by Dean Jackson.
+
+        Test: css-dark-mode/supported-color-schemes-scrollbar.html
+
+        * css/CSSProperties.json: Marked supported-color-schemes as a custom Value.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueSupportedColorSchemes):
+        * editing/cocoa/WebContentReaderCocoa.mm: Use FrameView's useDarkAppearance().
+        (WebCore::createFragment):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::InspectorOverlay::paint): Use FrameView's useDarkAppearance().
+        * page/FrameView.cpp:
+        (WebCore::FrameView::recalculateScrollbarOverlayStyle): Use a light scrollbar for
+        transparent web views in dark mode.
+        (WebCore::FrameView::rendererForSupportedColorSchemes const): Added.
+        Return the body for document element renderer.
+        (WebCore::FrameView::useDarkAppearance const): Use rendererForSupportedColorSchemes.
+        (WebCore::FrameView::styleColorOptions const): Added. Ditto.
+        * page/FrameView.h:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::rareInheritedDataChangeRequiresRepaint): Drive-by fix. Added supportedColorSchemes.
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::setHasExplicitlySetSupportedColorSchemes): Added.
+        (WebCore::RenderStyle::hasExplicitlySetSupportedColorSchemes const): Added.
+        (WebCore::RenderStyle::NonInheritedFlags::operator== const): Added supportedColorSchemes.
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::draw): Use FrameView's useDarkAppearance().
+        * testing/Internals.cpp:
+        (WebCore::Internals::setViewIsTransparent): Added.
+        (WebCore::Internals::scrollbarOverlayStyle const): Added.
+        * testing/Internals.h:
+        * testing/Internals.idl: Added setViewIsTransparent and scrollbarOverlayStyle.
+
 2018-11-13  Ross Kirsling  <ross.kirsling@sony.com>
 
         [AppleWin] Unreviewed build fix after r238108.
index 3540092..fe012ba 100644 (file)
             "codegen-properties": {
                 "converter": "SupportedColorSchemes",
                 "comment": "This is the second highest priority property, to ensure that its value can be checked when resolving colors.",
+                "custom": "Value",
                 "enable-if": "ENABLE_DARK_MODE_CSS",
                 "high-priority": true
             },
index c13ca8b..4370218 100644 (file)
@@ -142,6 +142,10 @@ public:
     static void applyValueAlt(StyleResolver&, CSSValue&);
     static void applyValueWillChange(StyleResolver&, CSSValue&);
 
+#if ENABLE(DARK_MODE_CSS)
+    static void applyValueSupportedColorSchemes(StyleResolver&, CSSValue&);
+#endif
+
     static void applyValueStrokeWidth(StyleResolver&, CSSValue&);
     static void applyValueStrokeColor(StyleResolver&, CSSValue&);
 
@@ -827,6 +831,14 @@ inline void StyleBuilderCustom::applyValueWebkitTextZoom(StyleResolver& styleRes
     styleResolver.state().setFontDirty(true);
 }
 
+#if ENABLE(DARK_MODE_CSS)
+inline void StyleBuilderCustom::applyValueSupportedColorSchemes(StyleResolver& styleResolver, CSSValue& value)
+{
+    styleResolver.style()->setSupportedColorSchemes(StyleBuilderConverter::convertSupportedColorSchemes(styleResolver, value));
+    styleResolver.style()->setHasExplicitlySetSupportedColorSchemes(true);
+}
+#endif
+
 template<CSSPropertyID property>
 inline void StyleBuilderCustom::applyTextOrBoxShadowValue(StyleResolver& styleResolver, CSSValue& value)
 {
index d4207b9..e4b90bd 100644 (file)
@@ -135,8 +135,7 @@ static FragmentAndResources createFragment(Frame& frame, NSAttributedString *str
 
 #if PLATFORM(MAC)
     auto* view = frame.view();
-    auto* renderView = view ? view->renderView() : nullptr;
-    LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
+    LocalDefaultSystemAppearance localAppearance(view ? view->useDarkAppearance() : false);
 #endif
 
     NSArray *subresources = nil;
index dec71e5..053dad8 100644 (file)
@@ -184,7 +184,7 @@ void InspectorOverlay::paint(GraphicsContext& context)
     FrameView* view = overlayPage()->mainFrame().view();
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(view->renderView()->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(view->useDarkAppearance());
 #endif
 
     view->updateLayoutAndStyleIfNeededRecursive();
index a4f58f8..72aec25 100644 (file)
@@ -408,6 +408,8 @@ void FrameView::recalculateScrollbarOverlayStyle()
         backgroundColor.getHSL(hue, saturation, lightness);
         if (lightness <= .5 && backgroundColor.isVisible())
             computedOverlayStyle = ScrollbarOverlayStyleLight;
+        else if (!backgroundColor.isVisible() && useDarkAppearance())
+            computedOverlayStyle = ScrollbarOverlayStyleLight;
     }
 
     if (oldOverlayStyle != computedOverlayStyle)
@@ -2046,9 +2048,39 @@ bool FrameView::shouldSetCursor() const
     return page && page->isVisible() && page->focusController().isActive();
 }
 
+#if ENABLE(DARK_MODE_CSS)
+RenderObject* FrameView::rendererForSupportedColorSchemes() const
+{
+    auto* document = frame().document();
+    auto* documentElement = document ? document->documentElement() : nullptr;
+    auto* documentElementRenderer = documentElement ? documentElement->renderer() : nullptr;
+    if (documentElementRenderer && documentElementRenderer->style().hasExplicitlySetSupportedColorSchemes())
+        return documentElementRenderer;
+    auto* bodyElement = document ? document->bodyOrFrameset() : nullptr;
+    return bodyElement ? bodyElement->renderer() : nullptr;
+}
+#endif
+
 bool FrameView::useDarkAppearance() const
 {
-    return renderView()->useDarkAppearance();
+#if ENABLE(DARK_MODE_CSS)
+    if (auto* renderer = rendererForSupportedColorSchemes())
+        return renderer->useDarkAppearance();
+#endif
+    if (auto* document = frame().document())
+        return document->useDarkAppearance(nullptr);
+    return false;
+}
+
+OptionSet<StyleColor::Options> FrameView::styleColorOptions() const
+{
+#if ENABLE(DARK_MODE_CSS)
+    if (auto* renderer = rendererForSupportedColorSchemes())
+        return renderer->styleColorOptions();
+#endif
+    if (auto* document = frame().document())
+        return document->styleColorOptions(nullptr);
+    return { };
 }
 
 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
@@ -3916,7 +3948,7 @@ void FrameView::paintScrollCorner(GraphicsContext& context, const IntRect& corne
 #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:.
-    bool useDarkAppearance = renderView()->useDarkAppearance() || scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
+    bool useDarkAppearance = this->useDarkAppearance() || scrollbarOverlayStyle() == WebCore::ScrollbarOverlayStyleLight;
     LocalDefaultSystemAppearance localAppearance(useDarkAppearance);
 #endif
 
index 14f2d51..f3bd04e 100644 (file)
@@ -35,6 +35,7 @@
 #include "PaintPhase.h"
 #include "RenderPtr.h"
 #include "ScrollView.h"
+#include "StyleColor.h"
 #include "TiledBacking.h"
 #include <memory>
 #include <wtf/Forward.h>
@@ -509,7 +510,8 @@ public:
     bool isHandlingWheelEvent() const final;
     bool shouldSetCursor() const;
 
-    bool useDarkAppearance() const final;
+    WEBCORE_EXPORT bool useDarkAppearance() const final;
+    OptionSet<StyleColor::Options> styleColorOptions() const;
 
     // FIXME: Remove this method once plugin loading is decoupled from layout.
     void flushAnyPendingPostLayoutTasks();
@@ -735,6 +737,10 @@ private:
     void unobscuredContentSizeChanged() final;
 #endif
 
+#if ENABLE(DARK_MODE_CSS)
+    RenderObject* rendererForSupportedColorSchemes() const;
+#endif
+
     bool usesCompositedScrolling() const final;
     bool usesAsyncScrolling() const final;
     bool usesMockScrollAnimator() const final;
@@ -826,6 +832,9 @@ private:
     bool m_firstLayoutCallbackPending;
 
     bool m_isTransparent;
+#if ENABLE(DARK_MODE_CSS)
+    bool m_usesDarkAppearance { false };
+#endif
     Color m_baseBackgroundColor;
     IntSize m_lastViewportSize;
     float m_lastZoomFactor;
index 0b6b55b..7ba1091 100644 (file)
@@ -955,7 +955,11 @@ static bool rareInheritedDataChangeRequiresRepaint(const StyleRareInheritedData&
     return first.userModify != second.userModify
         || first.userSelect != second.userSelect
         || first.appleColorFilter != second.appleColorFilter
-        || first.imageRendering != second.imageRendering;
+        || first.imageRendering != second.imageRendering
+#if ENABLE(DARK_MODE_CSS)
+        || first.supportedColorSchemes != second.supportedColorSchemes
+#endif
+    ;
 }
 
 bool RenderStyle::changeRequiresRepaint(const RenderStyle& other, OptionSet<StyleDifferenceContextSensitiveProperty>& changedContextSensitiveProperties) const
index 8555d0b..3acb1c9 100644 (file)
@@ -638,6 +638,8 @@ public:
 
 #if ENABLE(DARK_MODE_CSS)
     StyleSupportedColorSchemes supportedColorSchemes() const { return m_rareInheritedData->supportedColorSchemes; }
+    void setHasExplicitlySetSupportedColorSchemes(bool v) { m_nonInheritedFlags.hasExplicitlySetSupportedColorSchemes = v; }
+    bool hasExplicitlySetSupportedColorSchemes() const { return m_nonInheritedFlags.hasExplicitlySetSupportedColorSchemes; };
 #endif
 
     TextOrientation textOrientation() const { return static_cast<TextOrientation>(m_rareInheritedData->textOrientation); }
@@ -1782,6 +1784,9 @@ private:
         unsigned hasExplicitlySetDirection : 1;
         unsigned hasExplicitlySetWritingMode : 1;
         unsigned hasExplicitlySetTextAlign : 1;
+#if ENABLE(DARK_MODE_CSS)
+        unsigned hasExplicitlySetSupportedColorSchemes : 1;
+#endif
         unsigned hasViewportUnits : 1;
         unsigned hasExplicitlyInheritedProperties : 1; // Explicitly inherits a non-inherited property.
         unsigned isUnique : 1; // Style cannot be shared.
@@ -1908,6 +1913,9 @@ inline bool RenderStyle::NonInheritedFlags::operator==(const NonInheritedFlags&
         && hasExplicitlySetDirection == other.hasExplicitlySetDirection
         && hasExplicitlySetWritingMode == other.hasExplicitlySetWritingMode
         && hasExplicitlySetTextAlign == other.hasExplicitlySetTextAlign
+#if ENABLE(DARK_MODE_CSS)
+        && hasExplicitlySetSupportedColorSchemes == other.hasExplicitlySetSupportedColorSchemes
+#endif
         && hasViewportUnits == other.hasViewportUnits
         && hasExplicitlyInheritedProperties == other.hasExplicitlyInheritedProperties
         && isUnique == other.isUnique
index 06097ec..af4f1e1 100644 (file)
@@ -325,7 +325,7 @@ ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec
     }
 
 #if PLATFORM(MAC)
-    LocalDefaultSystemAppearance localAppearance(view->renderView()->useDarkAppearance());
+    LocalDefaultSystemAppearance localAppearance(view->useDarkAppearance());
 #endif
 
     view->paint(context, intersection(context.clipBounds(), enclosingIntRect(srcRect)));
index 46dbccb..8a32051 100644 (file)
@@ -1673,6 +1673,16 @@ ExceptionOr<Ref<DOMRect>> Internals::visualViewportRect()
     return DOMRect::create(frameView.visualViewportRect());
 }
 
+ExceptionOr<void> Internals::setViewIsTransparent(bool transparent)
+{
+    Document* document = contextDocument();
+    if (!document || !document->view())
+        return Exception { InvalidAccessError };
+    Color backgroundColor = transparent ? Color::transparent : Color::white;
+    document->view()->updateBackgroundRecursively(backgroundColor, transparent);
+    return { };
+}
+
 ExceptionOr<void> Internals::setViewBaseBackgroundColor(const String& colorValue)
 {
     Document* document = contextDocument();
@@ -2491,6 +2501,26 @@ ExceptionOr<String> Internals::repaintRectsAsText() const
     return document->frame()->trackedRepaintRectsAsText();
 }
 
+ExceptionOr<String> Internals::scrollbarOverlayStyle() const
+{
+    Document* document = contextDocument();
+    if (!document || !document->view())
+        return Exception { InvalidAccessError };
+
+    auto& frameView = *document->view();
+    switch (frameView.scrollbarOverlayStyle()) {
+    case ScrollbarOverlayStyleDefault:
+        return "default"_str;
+    case ScrollbarOverlayStyleDark:
+        return "dark"_str;
+    case ScrollbarOverlayStyleLight:
+        return "light"_str;
+    }
+
+    ASSERT_NOT_REACHED();
+    return "unknown"_str;
+}
+
 ExceptionOr<String> Internals::scrollingStateTreeAsText() const
 {
     Document* document = contextDocument();
index 11cfb76..7da674f 100644 (file)
@@ -244,6 +244,7 @@ public:
     ExceptionOr<Ref<DOMRect>> layoutViewportRect();
     ExceptionOr<Ref<DOMRect>> visualViewportRect();
 
+    ExceptionOr<void> setViewIsTransparent(bool);
     ExceptionOr<void> setViewBaseBackgroundColor(const String& colorValue);
 
     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
@@ -347,6 +348,9 @@ public:
     ExceptionOr<String> layerTreeAsText(Document&, unsigned short flags) const;
     ExceptionOr<uint64_t> layerIDForElement(Element&);
     ExceptionOr<String> repaintRectsAsText() const;
+
+    ExceptionOr<String> scrollbarOverlayStyle() const;
+
     ExceptionOr<String> scrollingStateTreeAsText() const;
     ExceptionOr<String> mainThreadScrollingReasons() const;
     ExceptionOr<Ref<DOMRectList>> nonFastScrollableRects() const;
index 6b66bf3..edb83bc 100644 (file)
@@ -262,6 +262,7 @@ enum CompositingPolicy {
     [MayThrowException] DOMRect layoutViewportRect();
     [MayThrowException] DOMRect visualViewportRect();
 
+    [MayThrowException] void setViewIsTransparent(boolean trnasparent);
     [MayThrowException] void setViewBaseBackgroundColor(DOMString colorValue);
 
     [MayThrowException] void setPagination(DOMString mode, long gap, optional long pageLength = 0);
@@ -372,6 +373,8 @@ enum CompositingPolicy {
 
     [MayThrowException] unsigned long long layerIDForElement(Element element);
 
+    [MayThrowException] DOMString scrollbarOverlayStyle();
+
     [MayThrowException] DOMString scrollingStateTreeAsText();
     [MayThrowException] DOMString mainThreadScrollingReasons(); // FIXME: rename to synchronousScrollingReasons().
     [MayThrowException] DOMRectList nonFastScrollableRects();
index b734f95..2f9f2d8 100644 (file)
@@ -1,3 +1,16 @@
+2018-11-13  Timothy Hatcher  <timothy@apple.com>
+
+        Use a light scrollbar for transparent web views in dark mode.
+        https://bugs.webkit.org/show_bug.cgi?id=191559
+        rdar://problem/46000489
+
+        Reviewed by Dean Jackson.
+
+        * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
+        (WebKit::InjectedBundleRangeHandle::renderedImage): Use FrameView's useDarkAppaearance().
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::drawRect): Ditto.
+
 2018-11-13  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Do not show selection UI for editable elements with opacity near zero
index 4bfdd7f..e99f357 100644 (file)
@@ -125,8 +125,7 @@ RefPtr<WebImage> InjectedBundleRangeHandle::renderedImage(SnapshotOptions option
         return nullptr;
 
 #if PLATFORM(MAC)
-    RenderView* renderView = frameView->renderView();
-    LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
+    LocalDefaultSystemAppearance localAppearance(frameView->useDarkAppearance());
 #endif
 
     Ref<Frame> protector(*frame);
index 63bca22..9e37395 100644 (file)
@@ -1573,8 +1573,8 @@ void WebPage::scrollMainFrameIfNotAtMaxScrollPosition(const IntSize& scrollOffse
 void WebPage::drawRect(GraphicsContext& graphicsContext, const IntRect& rect)
 {
 #if PLATFORM(MAC)
-    RenderView* renderView = m_page->mainFrame().view()->renderView();
-    LocalDefaultSystemAppearance localAppearance(renderView ? renderView->useDarkAppearance() : false);
+    FrameView* mainFrameView = m_page->mainFrame().view();
+    LocalDefaultSystemAppearance localAppearance(mainFrameView ? mainFrameView->useDarkAppearance() : false);
 #endif
 
     GraphicsContextStateSaver stateSaver(graphicsContext);