⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259672 in webkit


Ignore:
Timestamp:
Apr 7, 2020, 2:33:04 PM (6 years ago)
Author:
Simon Fraser
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):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259671 r259672  
     12020-04-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Use RectEdges<> in some scrolling tree code
     4        https://bugs.webkit.org/show_bug.cgi?id=210141
     5
     6        Reviewed by Tim Horton.
     7
     8        Add utility functions on ScrollingTreeScrollingNode to get pinned and rubberband state.
     9        Use them to push main frame state to the scrolling tree (which we do so we can safely
     10        access the state from the EventDispatcher thread).
     11
     12        * page/scrolling/ScrollingTree.cpp:
     13        (WebCore::ScrollingTree::setMainFramePinnedState):
     14        (WebCore::ScrollingTree::setMainFrameCanRubberBand):
     15        (WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
     16        (WebCore::ScrollingTree::setMainFramePinState): Deleted.
     17        (WebCore::ScrollingTree::setCanRubberBandState): Deleted.
     18        * page/scrolling/ScrollingTree.h:
     19        * page/scrolling/ScrollingTreeScrollingNode.cpp:
     20        (WebCore::ScrollingTreeScrollingNode::edgePinnedState const):
     21        (WebCore::ScrollingTreeScrollingNode::isRubberBanding const):
     22        * page/scrolling/ScrollingTreeScrollingNode.h:
     23        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     24        (WebCore::ScrollingTreeFrameScrollingNodeMac::updateMainFramePinAndRubberbandState):
     25
    1262020-04-07  Joanmarie Diggs  <jdiggs@igalia.com>
    227
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r259165 r259672  
    384384}
    385385
    386 void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom)
     386void ScrollingTree::setMainFramePinnedState(RectEdges<bool> edgePinningState)
    387387{
    388388    LockHolder locker(m_swipeStateMutex);
    389389
    390     m_swipeState.mainFramePinnedToTheLeft = pinnedToTheLeft;
    391     m_swipeState.mainFramePinnedToTheRight = pinnedToTheRight;
    392     m_swipeState.mainFramePinnedToTheTop = pinnedToTheTop;
    393     m_swipeState.mainFramePinnedToTheBottom = pinnedToTheBottom;
    394 }
    395 
    396 void ScrollingTree::setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
     390    m_swipeState.mainFramePinnedState = edgePinningState;
     391}
     392
     393void ScrollingTree::setMainFrameCanRubberBand(RectEdges<bool> canRubberBand)
    397394{
    398395    LockHolder locker(m_swipeStateMutex);
    399396
    400     m_swipeState.rubberBandsAtLeft = canRubberBandAtLeft;
    401     m_swipeState.rubberBandsAtRight = canRubberBandAtRight;
    402     m_swipeState.rubberBandsAtTop = canRubberBandAtTop;
    403     m_swipeState.rubberBandsAtBottom = canRubberBandAtBottom;
     397    m_swipeState.canRubberBand = canRubberBand;
    404398}
    405399
     
    426420    LockHolder lock(m_swipeStateMutex);
    427421
    428     if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedToTheLeft && !m_swipeState.rubberBandsAtLeft)
     422    if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedState.left() && !m_swipeState.canRubberBand.left())
    429423        return true;
    430     if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedToTheRight && !m_swipeState.rubberBandsAtRight)
     424    if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedState.right() && !m_swipeState.canRubberBand.right())
    431425        return true;
    432     if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedToTheTop && !m_swipeState.rubberBandsAtTop)
     426    if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedState.top() && !m_swipeState.canRubberBand.top())
    433427        return true;
    434     if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedToTheBottom && !m_swipeState.rubberBandsAtBottom)
     428    if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedState.bottom() && !m_swipeState.canRubberBand.bottom())
    435429        return true;
    436430
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r258679 r259672  
    2929
    3030#include "PlatformWheelEvent.h"
     31#include "RectEdges.h"
    3132#include "Region.h"
    3233#include "ScrollingCoordinator.h"
     
    119120#endif
    120121
    121     void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
     122    void setMainFramePinnedState(RectEdges<bool>);
    122123
    123124    // Can be called from any thread. Will update what edges allow rubber-banding.
    124     WEBCORE_EXPORT void setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
     125    WEBCORE_EXPORT void setMainFrameCanRubberBand(RectEdges<bool>);
    125126
    126127    bool isHandlingProgrammaticScroll() const { return m_isHandlingProgrammaticScroll; }
     
    213214        bool rubberBandsAtTop { true };
    214215        bool rubberBandsAtBottom { true };
    215         bool mainFramePinnedToTheLeft { true };
    216         bool mainFramePinnedToTheRight { true };
    217         bool mainFramePinnedToTheTop { true };
    218         bool mainFramePinnedToTheBottom { true };
     216       
     217        RectEdges<bool> canRubberBand  { true, true, true, true };
     218        RectEdges<bool> mainFramePinnedState { true, true, true, true };
    219219    };
    220220
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

    r259112 r259672  
    152152}
    153153
     154RectEdges<bool> ScrollingTreeScrollingNode::edgePinnedState() const
     155{
     156    auto scrollPosition = currentScrollPosition();
     157    auto minScrollPosition = minimumScrollPosition();
     158    auto maxScrollPosition = maximumScrollPosition();
     159
     160    // Top, right, bottom, left.
     161    return {
     162        scrollPosition.y() <= minScrollPosition.y(),
     163        scrollPosition.x() >= maxScrollPosition.x(),
     164        scrollPosition.y() >= maxScrollPosition.y(),
     165        scrollPosition.x() <= minScrollPosition.x()
     166    };
     167}
     168
     169bool ScrollingTreeScrollingNode::isRubberBanding() const
     170{
     171    auto scrollPosition = currentScrollPosition();
     172    auto minScrollPosition = minimumScrollPosition();
     173    auto maxScrollPosition = maximumScrollPosition();
     174
     175    return scrollPosition.x() < minScrollPosition.x()
     176        || scrollPosition.x() > maxScrollPosition.x()
     177        || scrollPosition.y() < minScrollPosition.y()
     178        || scrollPosition.y() > maxScrollPosition.y();
     179}
     180
    154181FloatPoint ScrollingTreeScrollingNode::adjustedScrollPosition(const FloatPoint& scrollPosition, ScrollClamping clamping) const
    155182{
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

    r259112 r259672  
    2929
    3030#include "IntRect.h"
     31#include "RectEdges.h"
    3132#include "ScrollSnapOffsetsInfo.h"
    3233#include "ScrollTypes.h"
     
    5960    FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; }
    6061    FloatSize scrollDeltaSinceLastCommit() const { return m_currentScrollPosition - m_lastCommittedScrollPosition; }
     62   
     63    RectEdges<bool> edgePinnedState() const;
     64    bool isRubberBanding() const;
    6165
    6266    // These are imperative; they adjust the scrolling layers.
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r255037 r259672  
    261261    ASSERT(isRootNode());
    262262
    263     auto scrollPosition = currentScrollPosition();
    264     bool pinnedToTheLeft = scrollPosition.x() <= minimumScrollPosition().x();
    265     bool pinnedToTheRight = scrollPosition.x() >= maximumScrollPosition().x();
    266     bool pinnedToTheTop = scrollPosition.y() <= minimumScrollPosition().y();
    267     bool pinnedToTheBottom = scrollPosition.y() >= maximumScrollPosition().y();
    268 
    269     scrollingTree().setMainFramePinState(pinnedToTheLeft, pinnedToTheRight, pinnedToTheTop, pinnedToTheBottom);
    270 
    271     bool rubberbanding = scrollPosition.x() < minimumScrollPosition().x()
    272         || scrollPosition.x() > maximumScrollPosition().x()
    273         || scrollPosition.y() < minimumScrollPosition().y()
    274         || scrollPosition.y() > maximumScrollPosition().y();
    275    
    276     scrollingTree().setMainFrameIsRubberBanding(rubberbanding);
     263    scrollingTree().setMainFramePinnedState(edgePinnedState());
     264    scrollingTree().setMainFrameIsRubberBanding(isRubberBanding());
    277265}
    278266
  • trunk/Source/WebKit/ChangeLog

    r259670 r259672  
     12020-04-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Use RectEdges<> in some scrolling tree code
     4        https://bugs.webkit.org/show_bug.cgi?id=210141
     5
     6        Reviewed by Tim Horton.
     7       
     8        Construct a RectEdges<>. Order is top, right, bottom, left.
     9
     10        * WebProcess/WebPage/EventDispatcher.cpp:
     11        (WebKit::EventDispatcher::wheelEvent):
     12
    1132020-04-07  Lauro Moura  <lmoura@igalia.com>
    214
  • trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp

    r257578 r259672  
    125125        // We only need to do this at the beginning of the gesture.
    126126        if (platformWheelEvent.phase() == PlatformWheelEventPhaseBegan)
    127             scrollingTree->setCanRubberBandState(canRubberBandAtLeft, canRubberBandAtRight, canRubberBandAtTop, canRubberBandAtBottom);
     127            scrollingTree->setMainFrameCanRubberBand({ canRubberBandAtTop, canRubberBandAtRight, canRubberBandAtBottom, canRubberBandAtLeft });
    128128
    129129        ScrollingEventResult result = scrollingTree->tryToHandleWheelEvent(platformWheelEvent);
Note: See TracChangeset for help on using the changeset viewer.