Title: [259672] trunk/Source
Revision
259672
Author
[email protected]
Date
2020-04-07 14:33:04 -0700 (Tue, 07 Apr 2020)

Log Message

Use RectEdges<> in some scrolling tree code
https://bugs.webkit.org/show_bug.cgi?id=210141

Reviewed by Tim Horton.
Source/WebCore:

Add utility functions on ScrollingTreeScrollingNode to get pinned and rubberband state.
Use them to push main frame state to the scrolling tree (which we do so we can safely
access the state from the EventDispatcher thread).

* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::setMainFramePinnedState):
(WebCore::ScrollingTree::setMainFrameCanRubberBand):
(WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
(WebCore::ScrollingTree::setMainFramePinState): Deleted.
(WebCore::ScrollingTree::setCanRubberBandState): Deleted.
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::edgePinnedState const):
(WebCore::ScrollingTreeScrollingNode::isRubberBanding const):
* page/scrolling/ScrollingTreeScrollingNode.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinAndRubberbandState):

Source/WebKit:

Construct a RectEdges<>. Order is top, right, bottom, left.

* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259671 => 259672)


--- trunk/Source/WebCore/ChangeLog	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/ChangeLog	2020-04-07 21:33:04 UTC (rev 259672)
@@ -1,3 +1,28 @@
+2020-04-07  Simon Fraser  <[email protected]>
+
+        Use RectEdges<> in some scrolling tree code
+        https://bugs.webkit.org/show_bug.cgi?id=210141
+
+        Reviewed by Tim Horton.
+
+        Add utility functions on ScrollingTreeScrollingNode to get pinned and rubberband state.
+        Use them to push main frame state to the scrolling tree (which we do so we can safely
+        access the state from the EventDispatcher thread).
+
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::setMainFramePinnedState):
+        (WebCore::ScrollingTree::setMainFrameCanRubberBand):
+        (WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
+        (WebCore::ScrollingTree::setMainFramePinState): Deleted.
+        (WebCore::ScrollingTree::setCanRubberBandState): Deleted.
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/ScrollingTreeScrollingNode.cpp:
+        (WebCore::ScrollingTreeScrollingNode::edgePinnedState const):
+        (WebCore::ScrollingTreeScrollingNode::isRubberBanding const):
+        * page/scrolling/ScrollingTreeScrollingNode.h:
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinAndRubberbandState):
+
 2020-04-07  Joanmarie Diggs  <[email protected]>
 
         AX: Change ATK mapping of the ARIA alert and alertdialog roles

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (259671 => 259672)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2020-04-07 21:33:04 UTC (rev 259672)
@@ -383,24 +383,18 @@
     m_treeState.mainFrameIsScrollSnapping = isScrollSnapping;
 }
 
-void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom)
+void ScrollingTree::setMainFramePinnedState(RectEdges<bool> edgePinningState)
 {
     LockHolder locker(m_swipeStateMutex);
 
-    m_swipeState.mainFramePinnedToTheLeft = pinnedToTheLeft;
-    m_swipeState.mainFramePinnedToTheRight = pinnedToTheRight;
-    m_swipeState.mainFramePinnedToTheTop = pinnedToTheTop;
-    m_swipeState.mainFramePinnedToTheBottom = pinnedToTheBottom;
+    m_swipeState.mainFramePinnedState = edgePinningState;
 }
 
-void ScrollingTree::setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
+void ScrollingTree::setMainFrameCanRubberBand(RectEdges<bool> canRubberBand)
 {
     LockHolder locker(m_swipeStateMutex);
 
-    m_swipeState.rubberBandsAtLeft = canRubberBandAtLeft;
-    m_swipeState.rubberBandsAtRight = canRubberBandAtRight;
-    m_swipeState.rubberBandsAtTop = canRubberBandAtTop;
-    m_swipeState.rubberBandsAtBottom = canRubberBandAtBottom;
+    m_swipeState.canRubberBand = canRubberBand;
 }
 
 // Can be called from the main thread.
@@ -425,13 +419,13 @@
 
     LockHolder lock(m_swipeStateMutex);
 
-    if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedToTheLeft && !m_swipeState.rubberBandsAtLeft)
+    if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedState.left() && !m_swipeState.canRubberBand.left())
         return true;
-    if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedToTheRight && !m_swipeState.rubberBandsAtRight)
+    if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedState.right() && !m_swipeState.canRubberBand.right())
         return true;
-    if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedToTheTop && !m_swipeState.rubberBandsAtTop)
+    if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedState.top() && !m_swipeState.canRubberBand.top())
         return true;
-    if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedToTheBottom && !m_swipeState.rubberBandsAtBottom)
+    if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedState.bottom() && !m_swipeState.canRubberBand.bottom())
         return true;
 
     return false;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (259671 => 259672)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2020-04-07 21:33:04 UTC (rev 259672)
@@ -28,6 +28,7 @@
 #if ENABLE(ASYNC_SCROLLING)
 
 #include "PlatformWheelEvent.h"
+#include "RectEdges.h"
 #include "Region.h"
 #include "ScrollingCoordinator.h"
 #include "WheelEventTestMonitor.h"
@@ -118,10 +119,10 @@
     WEBCORE_EXPORT virtual void currentSnapPointIndicesDidChange(ScrollingNodeID, unsigned horizontal, unsigned vertical) = 0;
 #endif
 
-    void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
+    void setMainFramePinnedState(RectEdges<bool>);
 
     // Can be called from any thread. Will update what edges allow rubber-banding.
-    WEBCORE_EXPORT void setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
+    WEBCORE_EXPORT void setMainFrameCanRubberBand(RectEdges<bool>);
 
     bool isHandlingProgrammaticScroll() const { return m_isHandlingProgrammaticScroll; }
     void setIsHandlingProgrammaticScroll(bool isHandlingProgrammaticScroll) { m_isHandlingProgrammaticScroll = isHandlingProgrammaticScroll; }
@@ -212,10 +213,9 @@
         bool rubberBandsAtRight { true };
         bool rubberBandsAtTop { true };
         bool rubberBandsAtBottom { true };
-        bool mainFramePinnedToTheLeft { true };
-        bool mainFramePinnedToTheRight { true };
-        bool mainFramePinnedToTheTop { true };
-        bool mainFramePinnedToTheBottom { true };
+        
+        RectEdges<bool> canRubberBand  { true, true, true, true };
+        RectEdges<bool> mainFramePinnedState { true, true, true, true };
     };
 
     Lock m_swipeStateMutex;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (259671 => 259672)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp	2020-04-07 21:33:04 UTC (rev 259672)
@@ -151,6 +151,33 @@
     return newScrollPosition == oldScrollPosition;
 }
 
+RectEdges<bool> ScrollingTreeScrollingNode::edgePinnedState() const
+{
+    auto scrollPosition = currentScrollPosition();
+    auto minScrollPosition = minimumScrollPosition();
+    auto maxScrollPosition = maximumScrollPosition();
+
+    // Top, right, bottom, left.
+    return {
+        scrollPosition.y() <= minScrollPosition.y(),
+        scrollPosition.x() >= maxScrollPosition.x(),
+        scrollPosition.y() >= maxScrollPosition.y(),
+        scrollPosition.x() <= minScrollPosition.x()
+    };
+}
+
+bool ScrollingTreeScrollingNode::isRubberBanding() const
+{
+    auto scrollPosition = currentScrollPosition();
+    auto minScrollPosition = minimumScrollPosition();
+    auto maxScrollPosition = maximumScrollPosition();
+
+    return scrollPosition.x() < minScrollPosition.x()
+        || scrollPosition.x() > maxScrollPosition.x()
+        || scrollPosition.y() < minScrollPosition.y()
+        || scrollPosition.y() > maxScrollPosition.y();
+}
+
 FloatPoint ScrollingTreeScrollingNode::adjustedScrollPosition(const FloatPoint& scrollPosition, ScrollClamping clamping) const
 {
     if (clamping == ScrollClamping::Clamped)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (259671 => 259672)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h	2020-04-07 21:33:04 UTC (rev 259672)
@@ -28,6 +28,7 @@
 #if ENABLE(ASYNC_SCROLLING)
 
 #include "IntRect.h"
+#include "RectEdges.h"
 #include "ScrollSnapOffsetsInfo.h"
 #include "ScrollTypes.h"
 #include "ScrollableArea.h"
@@ -58,6 +59,9 @@
     FloatPoint currentScrollOffset() const { return ScrollableArea::scrollOffsetFromPosition(m_currentScrollPosition, toFloatSize(m_scrollOrigin)); }
     FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; }
     FloatSize scrollDeltaSinceLastCommit() const { return m_currentScrollPosition - m_lastCommittedScrollPosition; }
+    
+    RectEdges<bool> edgePinnedState() const;
+    bool isRubberBanding() const;
 
     // These are imperative; they adjust the scrolling layers.
     void scrollTo(const FloatPoint&, ScrollType = ScrollType::User, ScrollClamping = ScrollClamping::Clamped);

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (259671 => 259672)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2020-04-07 21:33:04 UTC (rev 259672)
@@ -260,20 +260,8 @@
 {
     ASSERT(isRootNode());
 
-    auto scrollPosition = currentScrollPosition();
-    bool pinnedToTheLeft = scrollPosition.x() <= minimumScrollPosition().x();
-    bool pinnedToTheRight = scrollPosition.x() >= maximumScrollPosition().x();
-    bool pinnedToTheTop = scrollPosition.y() <= minimumScrollPosition().y();
-    bool pinnedToTheBottom = scrollPosition.y() >= maximumScrollPosition().y();
-
-    scrollingTree().setMainFramePinState(pinnedToTheLeft, pinnedToTheRight, pinnedToTheTop, pinnedToTheBottom);
-
-    bool rubberbanding = scrollPosition.x() < minimumScrollPosition().x()
-        || scrollPosition.x() > maximumScrollPosition().x()
-        || scrollPosition.y() < minimumScrollPosition().y()
-        || scrollPosition.y() > maximumScrollPosition().y();
-    
-    scrollingTree().setMainFrameIsRubberBanding(rubberbanding);
+    scrollingTree().setMainFramePinnedState(edgePinnedState());
+    scrollingTree().setMainFrameIsRubberBanding(isRubberBanding());
 }
 
 unsigned ScrollingTreeFrameScrollingNodeMac::exposedUnfilledArea() const

Modified: trunk/Source/WebKit/ChangeLog (259671 => 259672)


--- trunk/Source/WebKit/ChangeLog	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebKit/ChangeLog	2020-04-07 21:33:04 UTC (rev 259672)
@@ -1,3 +1,15 @@
+2020-04-07  Simon Fraser  <[email protected]>
+
+        Use RectEdges<> in some scrolling tree code
+        https://bugs.webkit.org/show_bug.cgi?id=210141
+
+        Reviewed by Tim Horton.
+        
+        Construct a RectEdges<>. Order is top, right, bottom, left.
+
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::wheelEvent):
+
 2020-04-07  Lauro Moura  <[email protected]>
 
         [GLIB] Avoid potential segfault in getPlatformEditorState

Modified: trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (259671 => 259672)


--- trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2020-04-07 21:14:16 UTC (rev 259671)
+++ trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2020-04-07 21:33:04 UTC (rev 259672)
@@ -124,7 +124,7 @@
         // scrolling tree can be notified.
         // We only need to do this at the beginning of the gesture.
         if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
-            scrollingTree->setCanRubberBandState(canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom);
+            scrollingTree->setMainFrameCanRubberBand({ canRubberBandAtTop, canRubberBandAtRight, canRubberBandAtBottom, canRubberBandAtLeft });
 
         ScrollingEventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to