Diff
Modified: branches/safari-607-branch/LayoutTests/ChangeLog (241185 => 241186)
--- branches/safari-607-branch/LayoutTests/ChangeLog 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/LayoutTests/ChangeLog 2019-02-08 05:36:21 UTC (rev 241186)
@@ -1,3 +1,58 @@
+2019-02-07 Babak Shafiei <bshaf...@apple.com>
+
+ Cherry-pick r241150. rdar://problem/47908154
+
+ Overflow element scrollbar is light for dark mode content.
+ https://bugs.webkit.org/show_bug.cgi?id=194407
+ rdar://problem/45991585
+
+ Reviewed by Beth Dakin.
+
+ Source/WebCore:
+
+ Tested by css-dark-mode/supported-color-schemes-scrollbar.html.
+
+ * page/ChromeClient.h:
+ (WebCore::FrameView::preferredScrollbarOverlayStyle): Return WTF::nullopt by default to avoid
+ short-circuiting auto detection in recalculateScrollbarOverlayStyle() for clients, like WK1,
+ that do not implement preferredScrollbarOverlayStyle().
+ * page/FrameView.cpp:
+ (WebCore::FrameView::recalculateScrollbarOverlayStyle): Use WTF::nullopt in the false case
+ to auto detect overlay style when page() is null.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::useDarkAppearance const): Added.
+ * rendering/RenderLayer.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::scrollbarOverlayStyle const): Added Node argument.
+ (WebCore::Internals::scrollbarUsingDarkAppearance const): Added.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+ LayoutTests:
+
+ Updated tests to look at overflow elements and if dark apearance
+ is used by the scrollbar directly.
+
+ * css-dark-mode/supported-color-schemes-scrollbar-expected.txt:
+ * css-dark-mode/supported-color-schemes-scrollbar.html:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-02-07 Timothy Hatcher <timo...@apple.com>
+
+ Overflow element scrollbar is light for dark mode content.
+ https://bugs.webkit.org/show_bug.cgi?id=194407
+ rdar://problem/45991585
+
+ Reviewed by Beth Dakin.
+
+ Updated tests to look at overflow elements and if dark apearance
+ is used by the scrollbar directly.
+
+ * css-dark-mode/supported-color-schemes-scrollbar-expected.txt:
+ * css-dark-mode/supported-color-schemes-scrollbar.html:
+
2019-02-07 Alan Coon <alanc...@apple.com>
Cherry-pick r240710. rdar://problem/47776353
Modified: branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt (241185 => 241186)
--- branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt 2019-02-08 05:36:21 UTC (rev 241186)
@@ -3,9 +3,15 @@
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 Document scrollbar overlay style is light
+PASS Document scrollbar is using dark appearance
+PASS Element scrollbar overlay style is default
+PASS Element scrollbar is using dark appearance
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
+PASS Document scrollbar overlay style is default
+PASS Document scrollbar is using light appearance
+PASS Element scrollbar overlay style is default
+PASS Element scrollbar is using dark appearance
Modified: branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html (241185 => 241186)
--- branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html 2019-02-08 05:36:21 UTC (rev 241186)
@@ -9,9 +9,21 @@
body {
supported-color-schemes: light dark;
}
+
+#test {
+ overflow-x: hidden;
+ overflow-y: scroll;
+ width: 100px;
+ height: 50px;
+}
+
+#test-content {
+ width: 100px;
+ height: 100px;
+}
</style>
-<body></body>
+<body><div id="test"><div id="test-content"></div></div></body>
<script>
function test_prop(element, prop, expected) {
@@ -42,9 +54,27 @@
if (!window.internals)
return;
assert_equals(internals.scrollbarOverlayStyle(), "light");
-}, "Scrollbar overlay style is light");
+}, "Document scrollbar overlay style is light");
test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarUsingDarkAppearance(), true);
+}, "Document scrollbar is using dark appearance");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarOverlayStyle(document.getElementById("test")), "default");
+}, "Element scrollbar overlay style is default");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarUsingDarkAppearance(document.getElementById("test")), true);
+}, "Element scrollbar is using dark appearance");
+
+test(function() {
let styleElement = document.createElement("style");
styleElement.textContent = ":root { supported-color-schemes: light }";
document.head.appendChild(styleElement);
@@ -62,5 +92,23 @@
if (!window.internals)
return;
assert_equals(internals.scrollbarOverlayStyle(), "default");
-}, "Scrollbar overlay style is default");
+}, "Document scrollbar overlay style is default");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarUsingDarkAppearance(), false);
+}, "Document scrollbar is using light appearance");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarOverlayStyle(document.getElementById("test")), "default");
+}, "Element scrollbar overlay style is default");
+
+test(function() {
+ if (!window.internals)
+ return;
+ assert_equals(internals.scrollbarUsingDarkAppearance(document.getElementById("test")), true);
+}, "Element scrollbar is using dark appearance");
</script>
Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/ChangeLog 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog 2019-02-08 05:36:21 UTC (rev 241186)
@@ -1,3 +1,70 @@
+2019-02-07 Babak Shafiei <bshaf...@apple.com>
+
+ Cherry-pick r241150. rdar://problem/47908154
+
+ Overflow element scrollbar is light for dark mode content.
+ https://bugs.webkit.org/show_bug.cgi?id=194407
+ rdar://problem/45991585
+
+ Reviewed by Beth Dakin.
+
+ Source/WebCore:
+
+ Tested by css-dark-mode/supported-color-schemes-scrollbar.html.
+
+ * page/ChromeClient.h:
+ (WebCore::FrameView::preferredScrollbarOverlayStyle): Return WTF::nullopt by default to avoid
+ short-circuiting auto detection in recalculateScrollbarOverlayStyle() for clients, like WK1,
+ that do not implement preferredScrollbarOverlayStyle().
+ * page/FrameView.cpp:
+ (WebCore::FrameView::recalculateScrollbarOverlayStyle): Use WTF::nullopt in the false case
+ to auto detect overlay style when page() is null.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::useDarkAppearance const): Added.
+ * rendering/RenderLayer.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::scrollbarOverlayStyle const): Added Node argument.
+ (WebCore::Internals::scrollbarUsingDarkAppearance const): Added.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
+ LayoutTests:
+
+ Updated tests to look at overflow elements and if dark apearance
+ is used by the scrollbar directly.
+
+ * css-dark-mode/supported-color-schemes-scrollbar-expected.txt:
+ * css-dark-mode/supported-color-schemes-scrollbar.html:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-02-07 Timothy Hatcher <timo...@apple.com>
+
+ Overflow element scrollbar is light for dark mode content.
+ https://bugs.webkit.org/show_bug.cgi?id=194407
+ rdar://problem/45991585
+
+ Reviewed by Beth Dakin.
+
+ Tested by css-dark-mode/supported-color-schemes-scrollbar.html.
+
+ * page/ChromeClient.h:
+ (WebCore::FrameView::preferredScrollbarOverlayStyle): Return WTF::nullopt by default to avoid
+ short-circuiting auto detection in recalculateScrollbarOverlayStyle() for clients, like WK1,
+ that do not implement preferredScrollbarOverlayStyle().
+ * page/FrameView.cpp:
+ (WebCore::FrameView::recalculateScrollbarOverlayStyle): Use WTF::nullopt in the false case
+ to auto detect overlay style when page() is null.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::useDarkAppearance const): Added.
+ * rendering/RenderLayer.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::scrollbarOverlayStyle const): Added Node argument.
+ (WebCore::Internals::scrollbarUsingDarkAppearance const): Added.
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2019-02-07 Alan Coon <alanc...@apple.com>
Cherry-pick r240710. rdar://problem/47776353
Modified: branches/safari-607-branch/Source/WebCore/page/ChromeClient.h (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/page/ChromeClient.h 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/page/ChromeClient.h 2019-02-08 05:36:21 UTC (rev 241186)
@@ -403,7 +403,7 @@
virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
virtual void recommendedScrollbarStyleDidChange(ScrollbarStyle) { }
- virtual Optional<ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() { return ScrollbarOverlayStyleDefault; }
+ virtual Optional<ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() { return WTF::nullopt; }
virtual void wheelEventHandlersChanged(bool hasHandlers) = 0;
Modified: branches/safari-607-branch/Source/WebCore/page/FrameView.cpp (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/page/FrameView.cpp 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/page/FrameView.cpp 2019-02-08 05:36:21 UTC (rev 241186)
@@ -390,7 +390,7 @@
void FrameView::recalculateScrollbarOverlayStyle()
{
ScrollbarOverlayStyle oldOverlayStyle = scrollbarOverlayStyle();
- Optional<ScrollbarOverlayStyle> clientOverlayStyle = frame().page() ? frame().page()->chrome().client().preferredScrollbarOverlayStyle() : ScrollbarOverlayStyleDefault;
+ Optional<ScrollbarOverlayStyle> clientOverlayStyle = frame().page() ? frame().page()->chrome().client().preferredScrollbarOverlayStyle() : WTF::nullopt;
if (clientOverlayStyle) {
if (clientOverlayStyle.value() != oldOverlayStyle)
setScrollbarOverlayStyle(clientOverlayStyle.value());
Modified: branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.cpp (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.cpp 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.cpp 2019-02-08 05:36:21 UTC (rev 241186)
@@ -3256,6 +3256,11 @@
return false;
}
+bool RenderLayer::useDarkAppearance() const
+{
+ return renderer().useDarkAppearance();
+}
+
#if ENABLE(CSS_SCROLL_SNAP)
void RenderLayer::updateSnapOffsets()
{
Modified: branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.h (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.h 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/rendering/RenderLayer.h 2019-02-08 05:36:21 UTC (rev 241186)
@@ -438,6 +438,7 @@
ScrollableArea* enclosingScrollableArea() const override;
bool isScrollableOrRubberbandable() override;
bool hasScrollableOrRubberbandableAncestor() override;
+ bool useDarkAppearance() const final;
#if ENABLE(CSS_SCROLL_SNAP)
void updateSnapOffsets() override;
#endif
Modified: branches/safari-607-branch/Source/WebCore/testing/Internals.cpp (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/testing/Internals.cpp 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/testing/Internals.cpp 2019-02-08 05:36:21 UTC (rev 241186)
@@ -2542,14 +2542,36 @@
return document->frame()->trackedRepaintRectsAsText();
}
-ExceptionOr<String> Internals::scrollbarOverlayStyle() const
+ExceptionOr<String> Internals::scrollbarOverlayStyle(Node* node) const
{
- Document* document = contextDocument();
- if (!document || !document->view())
+ if (!node)
+ node = contextDocument();
+
+ if (!node)
return Exception { InvalidAccessError };
- auto& frameView = *document->view();
- switch (frameView.scrollbarOverlayStyle()) {
+ node->document().updateLayoutIgnorePendingStylesheets();
+
+ ScrollableArea* scrollableArea = nullptr;
+ if (is<Document>(*node)) {
+ auto* frameView = downcast<Document>(node)->view();
+ if (!frameView)
+ return Exception { InvalidAccessError };
+
+ scrollableArea = frameView;
+ } else if (is<Element>(*node)) {
+ auto& element = *downcast<Element>(node);
+ if (!element.renderBox())
+ return Exception { InvalidAccessError };
+
+ scrollableArea = element.renderBox()->layer();
+ } else
+ return Exception { InvalidNodeTypeError };
+
+ if (!scrollableArea)
+ return Exception { InvalidNodeTypeError };
+
+ switch (scrollableArea->scrollbarOverlayStyle()) {
case ScrollbarOverlayStyleDefault:
return "default"_str;
case ScrollbarOverlayStyleDark:
@@ -2562,6 +2584,38 @@
return "unknown"_str;
}
+ExceptionOr<bool> Internals::scrollbarUsingDarkAppearance(Node* node) const
+{
+ if (!node)
+ node = contextDocument();
+
+ if (!node)
+ return Exception { InvalidAccessError };
+
+ node->document().updateLayoutIgnorePendingStylesheets();
+
+ ScrollableArea* scrollableArea = nullptr;
+ if (is<Document>(*node)) {
+ auto* frameView = downcast<Document>(node)->view();
+ if (!frameView)
+ return Exception { InvalidAccessError };
+
+ scrollableArea = frameView;
+ } else if (is<Element>(*node)) {
+ auto& element = *downcast<Element>(node);
+ if (!element.renderBox())
+ return Exception { InvalidAccessError };
+
+ scrollableArea = element.renderBox()->layer();
+ } else
+ return Exception { InvalidNodeTypeError };
+
+ if (!scrollableArea)
+ return Exception { InvalidNodeTypeError };
+
+ return scrollableArea->useDarkAppearance();
+}
+
ExceptionOr<String> Internals::scrollingStateTreeAsText() const
{
Document* document = contextDocument();
Modified: branches/safari-607-branch/Source/WebCore/testing/Internals.h (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/testing/Internals.h 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/testing/Internals.h 2019-02-08 05:36:21 UTC (rev 241186)
@@ -352,7 +352,8 @@
ExceptionOr<uint64_t> layerIDForElement(Element&);
ExceptionOr<String> repaintRectsAsText() const;
- ExceptionOr<String> scrollbarOverlayStyle() const;
+ ExceptionOr<String> scrollbarOverlayStyle(Node*) const;
+ ExceptionOr<bool> scrollbarUsingDarkAppearance(Node*) const;
ExceptionOr<String> scrollingStateTreeAsText() const;
ExceptionOr<String> mainThreadScrollingReasons() const;
Modified: branches/safari-607-branch/Source/WebCore/testing/Internals.idl (241185 => 241186)
--- branches/safari-607-branch/Source/WebCore/testing/Internals.idl 2019-02-08 05:36:16 UTC (rev 241185)
+++ branches/safari-607-branch/Source/WebCore/testing/Internals.idl 2019-02-08 05:36:21 UTC (rev 241186)
@@ -376,7 +376,8 @@
[MayThrowException] unsigned long long layerIDForElement(Element element);
- [MayThrowException] DOMString scrollbarOverlayStyle();
+ [MayThrowException] DOMString scrollbarOverlayStyle(optional Node? node = null);
+ [MayThrowException] boolean scrollbarUsingDarkAppearance(optional Node? node = null);
[MayThrowException] DOMString scrollingStateTreeAsText();
[MayThrowException] DOMString mainThreadScrollingReasons(); // FIXME: rename to synchronousScrollingReasons().