Title: [261056] trunk
Revision
261056
Author
[email protected]
Date
2020-05-02 20:49:16 -0700 (Sat, 02 May 2020)

Log Message

Make it possible to test overlay scrollbar interactions
https://bugs.webkit.org/show_bug.cgi?id=211342

Reviewed by Daniel Bates.

Source/WebCore:

Add internals.horizontalScrollbarState() and internals.verticalScrollbarState() and hook them
up via ScrollableArea to ScrollAnimatorMac. They dump state based on the NSScrollerImp state.

Make internals.setUsesOverlayScrollbars(true) actually trigger real overlay scrollbars by notifying
the ScrollbarTheme about the scrollbar style change.

Tests: fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html
       fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html
       fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html
       fast/scrolling/mac/scrollbars/scrollbar-state.html

* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::ScrollAnimator::horizontalScrollbarStateForTesting const):
(WebCore::ScrollAnimator::ScrollAnimator::verticalScrollbarStateForTesting const):
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::horizontalScrollbarStateForTesting const):
(WebCore::ScrollableArea::verticalScrollbarStateForTesting const):
* platform/ScrollableArea.h:
* platform/mac/NSScrollerImpDetails.h:
* platform/mac/ScrollAnimatorMac.h:
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::scrollbarState):
(WebCore::ScrollAnimatorMac::horizontalScrollbarStateForTesting const):
(WebCore::ScrollAnimatorMac::verticalScrollbarStateForTesting const):
* testing/Internals.cpp:
(WebCore:: const):
(WebCore::Internals::scrollbarOverlayStyle const):
(WebCore::Internals::scrollbarUsingDarkAppearance const):
(WebCore::Internals::horizontalScrollbarState const):
(WebCore::Internals::verticalScrollbarState const):
(WebCore::Internals::setUsesOverlayScrollbars):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

New tests, and some helper functions in UIHelper.

* fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered-expected.txt: Added.
* fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html: Added.
* fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal-expected.txt: Added.
* fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html: Added.
* fast/scrolling/mac/scrollbars/overlay-scrollbar-state-expected.txt: Added.
* fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html: Added.
* fast/scrolling/mac/scrollbars/scrollbar-state-expected.txt: Added.
* fast/scrolling/mac/scrollbars/scrollbar-state.html: Added.
* resources/ui-helper.js:
(window.UIHelper.async mouseWheelMayBeginAt):
(window.UIHelper.async mouseWheelCancelAt):
(window.UIHelper.async waitForCondition):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (261055 => 261056)


--- trunk/LayoutTests/ChangeLog	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/LayoutTests/ChangeLog	2020-05-03 03:49:16 UTC (rev 261056)
@@ -1,3 +1,25 @@
+2020-05-02  Simon Fraser  <[email protected]>
+
+        Make it possible to test overlay scrollbar interactions
+        https://bugs.webkit.org/show_bug.cgi?id=211342
+
+        Reviewed by Daniel Bates.
+
+        New tests, and some helper functions in UIHelper.
+
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered-expected.txt: Added.
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html: Added.
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal-expected.txt: Added.
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html: Added.
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-state-expected.txt: Added.
+        * fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html: Added.
+        * fast/scrolling/mac/scrollbars/scrollbar-state-expected.txt: Added.
+        * fast/scrolling/mac/scrollbars/scrollbar-state.html: Added.
+        * resources/ui-helper.js:
+        (window.UIHelper.async mouseWheelMayBeginAt):
+        (window.UIHelper.async mouseWheelCancelAt):
+        (window.UIHelper.async waitForCondition):
+
 2020-05-02  Diego Pino Garcia  <[email protected]>
 
         [GTK][WPE] Gardening, several WebGL tests are failing after r261023

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered-expected.txt (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered-expected.txt	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,15 @@
+Test hover over overlay scrollbar
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Document
+enabled
+Hovering vertical scrollbar should show expanded scrollbar
+PASS Scrollbar state: enabled,expanded,visible_track,visible_thumb
+Unhovering vertical scrollbar should hide it
+PASS Thumb and track hidden
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,66 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:useMockScrollbars=false ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    
+    <script>
+        jsTestIsAsync = true;
+        
+        window.internals.setUsesOverlayScrollbars(true);
+
+        async function doTest()
+        {
+            description('Test hover over overlay scrollbar');
+            if (!window.internals)
+                return;
+            
+            debug('Document');
+            debug(internals.verticalScrollbarState());
+            
+            let windowWidth = window.innerWidth;
+
+            debug('Hovering vertical scrollbar should show expanded scrollbar');
+            await UIHelper.mouseWheelScrollAt(windowWidth - 8, 10);
+            await UIHelper.waitForCondition(() => {
+                let state = internals.verticalScrollbarState();
+                let expanded = state.indexOf('expanded') != -1;
+                if (expanded)
+                    testPassed('Scrollbar state: ' + state);
+                return expanded;
+            });
+
+            debug('Unhovering vertical scrollbar should hide it');
+            await UIHelper.moveMouseAndWaitForFrame(windowWidth - 20, 10);
+            await UIHelper.waitForCondition(() => {
+                let state = internals.verticalScrollbarState();
+                let thumbHidden = state.indexOf('visible_thumb') == -1;
+                let trackHidden = state.indexOf('visible_track') == -1;
+                if (thumbHidden && trackHidden)
+                    testPassed('Thumb and track hidden');
+                return thumbHidden && trackHidden;
+            });
+
+            finishJSTest();
+        }
+
+        window.addEventListener('load', () => {
+            doTest();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="auto scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scroll scroller">
+        <div class="contents"></div>
+    </div>
+    <script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal-expected.txt (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal-expected.txt	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,15 @@
+Test maybegin and cancelled
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Document
+enabled
+MayBegin should show the scrollbar
+PASS Scrollbar state: enabled,visible_thumb
+Cancelled should hide the scrollbar
+PASS Scrollbar state: enabled
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,66 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:useMockScrollbars=false ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    
+    <script>
+        jsTestIsAsync = true;
+        
+        window.internals.setUsesOverlayScrollbars(true);
+
+        async function doTest()
+        {
+            description('Test maybegin and cancelled');
+            if (!window.internals)
+                return;
+            
+            debug('Document');
+            debug(internals.verticalScrollbarState());
+            
+            let windowWidth = window.innerWidth;
+
+            debug('MayBegin should show the scrollbar');
+            await UIHelper.mouseWheelMayBeginAt(100, 100);
+            await UIHelper.waitForCondition(() => {
+                let state = internals.verticalScrollbarState();
+                let visible = state.indexOf('visible_thumb') != -1;
+                if (visible)
+                    testPassed('Scrollbar state: ' + state);
+                return visible;
+            });
+
+            debug('Cancelled should hide the scrollbar');
+            await UIHelper.mouseWheelCancelAt(100, 100);
+
+            await UIHelper.waitForCondition(() => {
+                let state = internals.verticalScrollbarState();
+                let hidden = state.indexOf('visible_thumb') == -1;
+                if (hidden)
+                    testPassed('Scrollbar state: ' + state);
+                return hidden;
+            });
+
+            finishJSTest();
+        }
+
+        window.addEventListener('load', () => {
+            doTest();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="auto scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scroll scroller">
+        <div class="contents"></div>
+    </div>
+    <script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state-expected.txt (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state-expected.txt	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,18 @@
+Test scrollbar state internals
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Document
+enabled
+none
+overflow:auto
+PASS internals.verticalScrollbarState(autoScroller) is "enabled"
+PASS internals.horizontalScrollbarState(autoScroller) is "none"
+overflow:scroll
+PASS internals.verticalScrollbarState(scrollScroller) is "enabled"
+PASS internals.horizontalScrollbarState(scrollScroller) is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,66 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:useMockScrollbars=false ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+        .scroller {
+            margin: 10px;
+            width: 100px;
+            height: 100px;
+        }
+        .contents {
+            width: 100%;
+            height: 200%;
+        }
+        .auto {
+            overflow: auto;
+        }
+        .scroll {
+            overflow: scroll;
+        }
+    </style>
+    <script src=""
+    <script>
+        jsTestIsAsync = true;
+        
+        let autoScroller;
+        let scrollScroller;
+        
+        window.internals.setUsesOverlayScrollbars(true);
+
+        window.addEventListener('load', () => {
+            description('Test scrollbar state internals');
+            if (!window.internals)
+                return;
+            
+            debug('Document');
+            debug(internals.verticalScrollbarState());
+            debug(internals.horizontalScrollbarState());
+
+            autoScroller = document.querySelector('.auto.scroller')
+            scrollScroller = document.querySelector('.scroll.scroller')
+
+            debug('overflow:auto');
+            shouldBeEqualToString('internals.verticalScrollbarState(autoScroller)', 'enabled');
+            shouldBeEqualToString('internals.horizontalScrollbarState(autoScroller)', 'none');
+
+            debug('overflow:scroll');
+            shouldBeEqualToString('internals.verticalScrollbarState(scrollScroller)', 'enabled');
+            shouldBeEqualToString('internals.horizontalScrollbarState(scrollScroller)', 'none');
+
+            finishJSTest();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="auto scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scroll scroller">
+        <div class="contents"></div>
+    </div>
+    <script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state-expected.txt (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state-expected.txt	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,18 @@
+Test scrollbar state internals
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Document
+PASS internals.verticalScrollbarState() is "enabled"
+PASS internals.horizontalScrollbarState() is "none"
+overflow:auto
+PASS internals.verticalScrollbarState(autoScroller) is "enabled"
+PASS internals.horizontalScrollbarState(autoScroller) is "none"
+overflow:scroll
+PASS internals.verticalScrollbarState(scrollScroller) is "enabled"
+PASS internals.horizontalScrollbarState(scrollScroller) is "disabled"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state.html (0 => 261056)


--- trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/scrollbars/scrollbar-state.html	2020-05-03 03:49:16 UTC (rev 261056)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        body {
+            height: 1000px;
+        }
+        .scroller {
+            margin: 10px;
+            width: 100px;
+            height: 100px;
+        }
+        .contents {
+            width: 100%;
+            height: 200%;
+        }
+        .auto {
+            overflow: auto;
+        }
+        .scroll {
+            overflow: scroll;
+        }
+    </style>
+    <script src=""
+    <script>
+        jsTestIsAsync = true;
+        
+        let autoScroller;
+        let scrollScroller;
+
+        window.addEventListener('load', () => {
+            description('Test scrollbar state internals');
+            if (!window.internals)
+                return;
+            
+            debug('Document');
+            shouldBeEqualToString('internals.verticalScrollbarState()', 'enabled');
+            shouldBeEqualToString('internals.horizontalScrollbarState()', 'none');
+
+            autoScroller = document.querySelector('.auto.scroller')
+            scrollScroller = document.querySelector('.scroll.scroller')
+
+            debug('overflow:auto');
+            shouldBeEqualToString('internals.verticalScrollbarState(autoScroller)', 'enabled');
+            shouldBeEqualToString('internals.horizontalScrollbarState(autoScroller)', 'none');
+
+            debug('overflow:scroll');
+            shouldBeEqualToString('internals.verticalScrollbarState(scrollScroller)', 'enabled');
+            shouldBeEqualToString('internals.horizontalScrollbarState(scrollScroller)', 'disabled');
+
+            finishJSTest();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="auto scroller">
+        <div class="contents"></div>
+    </div>
+    <div class="scroll scroller">
+        <div class="contents"></div>
+    </div>
+    <script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/resources/ui-helper.js (261055 => 261056)


--- trunk/LayoutTests/resources/ui-helper.js	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/LayoutTests/resources/ui-helper.js	2020-05-03 03:49:16 UTC (rev 261056)
@@ -59,6 +59,20 @@
         });
     }
 
+    static async mouseWheelMayBeginAt(x, y)
+    {
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseScrollByWithWheelAndMomentumPhases(x, y, "maybegin", "none");
+        await UIHelper.animationFrame();
+    }
+
+    static async mouseWheelCancelAt(x, y)
+    {
+        eventSender.mouseMoveTo(x, y);
+        eventSender.mouseScrollByWithWheelAndMomentumPhases(x, y, "cancelled", "none");
+        await UIHelper.animationFrame();
+    }
+
     static async waitForScrollCompletion()
     {
         return new Promise(resolve => {
@@ -73,6 +87,13 @@
         return new Promise(requestAnimationFrame);
     }
 
+    static async waitForCondition(conditionFunc)
+    {
+        while (!conditionFunc()) {
+            await UIHelper.animationFrame();
+        }
+    }
+
     static sendEventStream(eventStream)
     {
         const eventStreamAsString = JSON.stringify(eventStream);

Modified: trunk/Source/WebCore/ChangeLog (261055 => 261056)


--- trunk/Source/WebCore/ChangeLog	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/ChangeLog	2020-05-03 03:49:16 UTC (rev 261056)
@@ -1,3 +1,44 @@
+2020-05-02  Simon Fraser  <[email protected]>
+
+        Make it possible to test overlay scrollbar interactions
+        https://bugs.webkit.org/show_bug.cgi?id=211342
+
+        Reviewed by Daniel Bates.
+
+        Add internals.horizontalScrollbarState() and internals.verticalScrollbarState() and hook them
+        up via ScrollableArea to ScrollAnimatorMac. They dump state based on the NSScrollerImp state.
+
+        Make internals.setUsesOverlayScrollbars(true) actually trigger real overlay scrollbars by notifying
+        the ScrollbarTheme about the scrollbar style change.
+
+        Tests: fast/scrolling/mac/scrollbars/overlay-scrollbar-hovered.html
+               fast/scrolling/mac/scrollbars/overlay-scrollbar-reveal.html
+               fast/scrolling/mac/scrollbars/overlay-scrollbar-state.html
+               fast/scrolling/mac/scrollbars/scrollbar-state.html
+
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::ScrollAnimator::horizontalScrollbarStateForTesting const):
+        (WebCore::ScrollAnimator::ScrollAnimator::verticalScrollbarStateForTesting const):
+        * platform/ScrollableArea.cpp:
+        (WebCore::ScrollableArea::horizontalScrollbarStateForTesting const):
+        (WebCore::ScrollableArea::verticalScrollbarStateForTesting const):
+        * platform/ScrollableArea.h:
+        * platform/mac/NSScrollerImpDetails.h:
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::scrollbarState):
+        (WebCore::ScrollAnimatorMac::horizontalScrollbarStateForTesting const):
+        (WebCore::ScrollAnimatorMac::verticalScrollbarStateForTesting const):
+        * testing/Internals.cpp:
+        (WebCore:: const):
+        (WebCore::Internals::scrollbarOverlayStyle const):
+        (WebCore::Internals::scrollbarUsingDarkAppearance const):
+        (WebCore::Internals::horizontalScrollbarState const):
+        (WebCore::Internals::verticalScrollbarState const):
+        (WebCore::Internals::setUsesOverlayScrollbars):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2020-05-02  Daniel Bates  <[email protected]>
 
         Page::editableElementsInRect() should return root editable elements

Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (261055 => 261056)


--- trunk/Source/WebCore/platform/ScrollAnimator.h	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h	2020-05-03 03:49:16 UTC (rev 261056)
@@ -123,6 +123,9 @@
     virtual bool isRubberBandInProgress() const { return false; }
     virtual bool isScrollSnapInProgress() const { return false; }
 
+    virtual String horizontalScrollbarStateForTesting() const { return emptyString(); }
+    virtual String verticalScrollbarStateForTesting() const { return emptyString(); }
+
     void setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& testMonitor) { m_wheelEventTestMonitor = testMonitor; }
 
 #if (ENABLE(CSS_SCROLL_SNAP) || ENABLE(RUBBER_BANDING)) && PLATFORM(MAC)

Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (261055 => 261056)


--- trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp	2020-05-03 03:49:16 UTC (rev 261056)
@@ -438,6 +438,16 @@
     return layerForScrollCorner();
 }
 
+String ScrollableArea::horizontalScrollbarStateForTesting() const
+{
+    return scrollAnimator().horizontalScrollbarStateForTesting();
+}
+
+String ScrollableArea::verticalScrollbarStateForTesting() const
+{
+    return scrollAnimator().verticalScrollbarStateForTesting();
+}
+
 #if ENABLE(CSS_SCROLL_SNAP)
 ScrollSnapOffsetsInfo<LayoutUnit>& ScrollableArea::ensureSnapOffsetsInfo()
 {

Modified: trunk/Source/WebCore/platform/ScrollableArea.h (261055 => 261056)


--- trunk/Source/WebCore/platform/ScrollableArea.h	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/ScrollableArea.h	2020-05-03 03:49:16 UTC (rev 261056)
@@ -136,6 +136,9 @@
     virtual bool horizontalScrollbarHiddenByStyle() const { return false; }
     virtual bool verticalScrollbarHiddenByStyle() const { return false; }
 
+    WEBCORE_EXPORT String horizontalScrollbarStateForTesting() const;
+    WEBCORE_EXPORT String verticalScrollbarStateForTesting() const;
+
     bool inLiveResize() const { return m_inLiveResize; }
     WEBCORE_EXPORT virtual void willStartLiveResize();
     WEBCORE_EXPORT virtual void willEndLiveResize();

Modified: trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h (261055 => 261056)


--- trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2020-05-03 03:49:16 UTC (rev 261056)
@@ -29,6 +29,8 @@
 
 #include <wtf/Optional.h>
 
+enum NSScrollerStyle : long;
+
 namespace WebCore {
 
 class WEBCORE_EXPORT ScrollerStyle {

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h (261055 => 261056)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2020-05-03 03:49:16 UTC (rev 261056)
@@ -138,6 +138,9 @@
     bool isRubberBandInProgress() const override;
     bool isScrollSnapInProgress() const override;
 
+    String horizontalScrollbarStateForTesting() const final;
+    String verticalScrollbarStateForTesting() const final;
+
 #if ENABLE(RUBBER_BANDING)
     /// ScrollControllerClient member functions.
     IntSize stretchAmount() const override;

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (261055 => 261056)


--- trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2020-05-03 03:49:16 UTC (rev 261056)
@@ -853,6 +853,43 @@
 #endif
 }
 
+static String scrollbarState(Scrollbar* scrollbar)
+{
+    if (!scrollbar)
+        return "none"_s;
+
+    StringBuilder result;
+    result.append(scrollbar->enabled() ? "enabled"_s : "disabled"_s);
+
+    if (!scrollbar->isOverlayScrollbar())
+        return result.toString();
+
+    NSScrollerImp *scrollerImp = scrollerImpForScrollbar(*scrollbar);
+    if (!scrollerImp)
+        return result.toString();
+
+    if (scrollerImp.expanded)
+        result.append(",expanded"_s);
+
+    if (scrollerImp.trackAlpha > 0)
+        result.append(",visible_track"_s);
+
+    if (scrollerImp.knobAlpha > 0)
+        result.append(",visible_thumb"_s);
+
+    return result.toString();
+}
+
+String ScrollAnimatorMac::horizontalScrollbarStateForTesting() const
+{
+    return scrollbarState(m_scrollableArea.horizontalScrollbar());
+}
+
+String ScrollAnimatorMac::verticalScrollbarStateForTesting() const
+{
+    return scrollbarState(m_scrollableArea.verticalScrollbar());
+}
+
 void ScrollAnimatorMac::immediateScrollToPositionForScrollAnimation(const FloatPoint& newPosition)
 {
     ASSERT(m_scrollAnimationHelper);

Modified: trunk/Source/WebCore/testing/Internals.cpp (261055 => 261056)


--- trunk/Source/WebCore/testing/Internals.cpp	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/testing/Internals.cpp	2020-05-03 03:49:16 UTC (rev 261056)
@@ -322,6 +322,8 @@
 
 #if PLATFORM(MAC)
 #include "GraphicsContextGLOpenGLManager.h"
+#include "NSScrollerImpDetails.h"
+#include "ScrollbarThemeMac.h"
 #endif
 
 #if PLATFORM(COCOA)
@@ -2746,7 +2748,7 @@
     return document->frame()->trackedRepaintRectsAsText();
 }
 
-ExceptionOr<String> Internals::scrollbarOverlayStyle(Node* node) const
+ExceptionOr<ScrollableArea*> Internals::scrollableAreaForNode(Node* node) const
 {
     if (!node)
         node = contextDocument();
@@ -2754,17 +2756,18 @@
     if (!node)
         return Exception { InvalidAccessError };
 
-    node->document().updateLayoutIgnorePendingStylesheets();
+    auto nodeRef = makeRef(*node);
+    nodeRef->document().updateLayoutIgnorePendingStylesheets();
 
     ScrollableArea* scrollableArea = nullptr;
-    if (is<Document>(*node)) {
-        auto* frameView = downcast<Document>(node)->view();
+    if (is<Document>(nodeRef)) {
+        auto* frameView = downcast<Document>(nodeRef.get()).view();
         if (!frameView)
             return Exception { InvalidAccessError };
 
         scrollableArea = frameView;
-    } else if (is<Element>(*node)) {
-        auto& element = *downcast<Element>(node);
+    } else if (is<Element>(nodeRef)) {
+        auto& element = downcast<Element>(nodeRef.get());
         if (!element.renderBox())
             return Exception { InvalidAccessError };
 
@@ -2775,6 +2778,16 @@
     if (!scrollableArea)
         return Exception { InvalidNodeTypeError };
 
+    return scrollableArea;
+}
+
+ExceptionOr<String> Internals::scrollbarOverlayStyle(Node* node) const
+{
+    auto areaOrException = scrollableAreaForNode(node);
+    if (areaOrException.hasException())
+        return areaOrException.releaseException();
+
+    auto* scrollableArea = areaOrException.releaseReturnValue();
     switch (scrollableArea->scrollbarOverlayStyle()) {
     case ScrollbarOverlayStyleDefault:
         return "default"_str;
@@ -2790,34 +2803,32 @@
 
 ExceptionOr<bool> Internals::scrollbarUsingDarkAppearance(Node* node) const
 {
-    if (!node)
-        node = contextDocument();
+    auto areaOrException = scrollableAreaForNode(node);
+    if (areaOrException.hasException())
+        return areaOrException.releaseException();
 
-    if (!node)
-        return Exception { InvalidAccessError };
+    auto* scrollableArea = areaOrException.releaseReturnValue();
+    return scrollableArea->useDarkAppearance();
+}
 
-    node->document().updateLayoutIgnorePendingStylesheets();
+ExceptionOr<String> Internals::horizontalScrollbarState(Node* node) const
+{
+    auto areaOrException = scrollableAreaForNode(node);
+    if (areaOrException.hasException())
+        return areaOrException.releaseException();
 
-    ScrollableArea* scrollableArea = nullptr;
-    if (is<Document>(*node)) {
-        auto* frameView = downcast<Document>(node)->view();
-        if (!frameView)
-            return Exception { InvalidAccessError };
+    auto* scrollableArea = areaOrException.releaseReturnValue();
+    return scrollableArea->horizontalScrollbarStateForTesting();
+}
 
-        scrollableArea = frameView;
-    } else if (is<Element>(*node)) {
-        auto& element = *downcast<Element>(node);
-        if (!element.renderBox())
-            return Exception { InvalidAccessError };
+ExceptionOr<String> Internals::verticalScrollbarState(Node* node) const
+{
+    auto areaOrException = scrollableAreaForNode(node);
+    if (areaOrException.hasException())
+        return areaOrException.releaseException();
 
-        scrollableArea = element.renderBox()->layer();
-    } else
-        return Exception { InvalidNodeTypeError };
-
-    if (!scrollableArea)
-        return Exception { InvalidNodeTypeError };
-
-    return scrollableArea->useDarkAppearance();
+    auto* scrollableArea = areaOrException.releaseReturnValue();
+    return scrollableArea->verticalScrollbarStateForTesting();
 }
 
 ExceptionOr<String> Internals::scrollingStateTreeAsText() const
@@ -3575,6 +3586,14 @@
 void Internals::setUsesOverlayScrollbars(bool enabled)
 {
     WebCore::DeprecatedGlobalSettings::setUsesOverlayScrollbars(enabled);
+#if PLATFORM(MAC)
+    ScrollerStyle::setUseOverlayScrollbars(enabled);
+    ScrollbarTheme& theme = ScrollbarTheme::theme();
+    if (theme.isMockTheme())
+        return;
+
+    static_cast<ScrollbarThemeMac&>(theme).preferencesChanged();
+#endif
 }
 
 void Internals::setUsesMockScrollAnimator(bool enabled)

Modified: trunk/Source/WebCore/testing/Internals.h (261055 => 261056)


--- trunk/Source/WebCore/testing/Internals.h	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/testing/Internals.h	2020-05-03 03:49:16 UTC (rev 261056)
@@ -96,6 +96,7 @@
 class Range;
 class RenderedDocumentMarker;
 class SVGSVGElement;
+class ScrollableArea;
 class SerializedScriptValue;
 class SourceBuffer;
 class StringCallback;
@@ -397,6 +398,9 @@
     ExceptionOr<String> scrollbarOverlayStyle(Node*) const;
     ExceptionOr<bool> scrollbarUsingDarkAppearance(Node*) const;
 
+    ExceptionOr<String> horizontalScrollbarState(Node*) const;
+    ExceptionOr<String> verticalScrollbarState(Node*) const;
+
     ExceptionOr<String> scrollingStateTreeAsText() const;
     ExceptionOr<String> scrollingTreeAsText() const;
     ExceptionOr<String> mainThreadScrollingReasons() const;
@@ -1014,6 +1018,7 @@
     Frame* frame() const;
 
     ExceptionOr<RenderedDocumentMarker*> markerAt(Node&, const String& markerType, unsigned index);
+    ExceptionOr<ScrollableArea*> scrollableAreaForNode(Node*) const;
 
 #if ENABLE(MEDIA_STREAM)
     // RealtimeMediaSource::Observer API

Modified: trunk/Source/WebCore/testing/Internals.idl (261055 => 261056)


--- trunk/Source/WebCore/testing/Internals.idl	2020-05-02 21:23:00 UTC (rev 261055)
+++ trunk/Source/WebCore/testing/Internals.idl	2020-05-03 03:49:16 UTC (rev 261056)
@@ -459,6 +459,8 @@
 
     [MayThrowException] DOMString scrollbarOverlayStyle(optional Node? node = null);
     [MayThrowException] boolean scrollbarUsingDarkAppearance(optional Node? node = null);
+    [MayThrowException] DOMString horizontalScrollbarState(optional Node? node = null);
+    [MayThrowException] DOMString verticalScrollbarState(optional Node? node = null);
 
     [MayThrowException] DOMString scrollingStateTreeAsText();
     [MayThrowException] DOMString scrollingTreeAsText();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to