Diff
Modified: trunk/LayoutTests/ChangeLog (241149 => 241150)
--- trunk/LayoutTests/ChangeLog 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/LayoutTests/ChangeLog 2019-02-07 23:34:26 UTC (rev 241150)
@@ -1,3 +1,17 @@
+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 Nikita Vasilyev <nvasil...@apple.com>
Web Inspector: Fix modify-css-property-race.html flakiness
Modified: trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt (241149 => 241150)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar-expected.txt 2019-02-07 23:34:26 UTC (rev 241150)
@@ -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: trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html (241149 => 241150)
--- trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/LayoutTests/css-dark-mode/supported-color-schemes-scrollbar.html 2019-02-07 23:34:26 UTC (rev 241150)
@@ -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: trunk/Source/WebCore/ChangeLog (241149 => 241150)
--- trunk/Source/WebCore/ChangeLog 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/ChangeLog 2019-02-07 23:34:26 UTC (rev 241150)
@@ -1,3 +1,29 @@
+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 Eric Carlson <eric.carl...@apple.com>
[MSE] Convert debug-only logging to runtime logging
Modified: trunk/Source/WebCore/page/ChromeClient.h (241149 => 241150)
--- trunk/Source/WebCore/page/ChromeClient.h 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/page/ChromeClient.h 2019-02-07 23:34:26 UTC (rev 241150)
@@ -406,7 +406,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: trunk/Source/WebCore/page/FrameView.cpp (241149 => 241150)
--- trunk/Source/WebCore/page/FrameView.cpp 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/page/FrameView.cpp 2019-02-07 23:34:26 UTC (rev 241150)
@@ -364,7 +364,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: trunk/Source/WebCore/rendering/RenderLayer.cpp (241149 => 241150)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-02-07 23:34:26 UTC (rev 241150)
@@ -3242,6 +3242,11 @@
return false;
}
+bool RenderLayer::useDarkAppearance() const
+{
+ return renderer().useDarkAppearance();
+}
+
#if ENABLE(CSS_SCROLL_SNAP)
void RenderLayer::updateSnapOffsets()
{
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (241149 => 241150)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2019-02-07 23:34:26 UTC (rev 241150)
@@ -445,6 +445,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: trunk/Source/WebCore/testing/Internals.cpp (241149 => 241150)
--- trunk/Source/WebCore/testing/Internals.cpp 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/testing/Internals.cpp 2019-02-07 23:34:26 UTC (rev 241150)
@@ -2552,14 +2552,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:
@@ -2572,6 +2594,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: trunk/Source/WebCore/testing/Internals.h (241149 => 241150)
--- trunk/Source/WebCore/testing/Internals.h 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/testing/Internals.h 2019-02-07 23:34:26 UTC (rev 241150)
@@ -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: trunk/Source/WebCore/testing/Internals.idl (241149 => 241150)
--- trunk/Source/WebCore/testing/Internals.idl 2019-02-07 23:23:25 UTC (rev 241149)
+++ trunk/Source/WebCore/testing/Internals.idl 2019-02-07 23:34:26 UTC (rev 241150)
@@ -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().