Skip to content

Commit

Permalink
Clarify the role of "mainFrameCanRubberBand" at the ScrollingTree level
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=268697
rdar://122242780

Reviewed by Tim Horton.

ScrollingTree::mainFrameCanRubberBandOnSide() is easy to mis-use: it doesn't mean that rubber-banding
will happen, only that the client (Safari, Mail etc) has allowed rubber-banding to happen on this side.
So rename it accordingly.

This make it clear that `ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandOnSide()` isn't
using it correctly. Future changes will fix that.

* Source/WebCore/page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::setClientAllowedMainFrameRubberBandableEdges):
(WebCore::ScrollingTree::clientAllowsMainFrameRubberBandingOnSide):
(WebCore::ScrollingTree::willWheelEventStartSwipeGesture):
(WebCore::ScrollingTree::setMainFrameCanRubberBand): Deleted.
(WebCore::ScrollingTree::mainFrameCanRubberBandOnSide): Deleted.
* Source/WebCore/page/scrolling/ScrollingTree.h:
* Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
(WebCore::ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandOnSide const):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::handleWheelEvent):
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.cpp:
(WebKit::RemoteLayerTreeEventDispatcher::determineWheelEventProcessing):
* Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::internalWheelEvent):

Canonical link: https://commits.webkit.org/274061@main
  • Loading branch information
smfr committed Feb 4, 2024
1 parent f232a5d commit 5ffedc5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions Source/WebCore/page/scrolling/ScrollingTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,17 +783,17 @@ void ScrollingTree::setMainFramePinnedState(RectEdges<bool> edgePinningState)
m_swipeState.mainFramePinnedState = edgePinningState;
}

void ScrollingTree::setMainFrameCanRubberBand(RectEdges<bool> canRubberBand)
void ScrollingTree::setClientAllowedMainFrameRubberBandableEdges(RectEdges<bool> clientAllowedRubberBandableEdges)
{
Locker locker { m_swipeStateLock };

m_swipeState.canRubberBand = canRubberBand;
m_swipeState.clientAllowedRubberBandableEdges = clientAllowedRubberBandableEdges;
}

bool ScrollingTree::mainFrameCanRubberBandOnSide(BoxSide side)
bool ScrollingTree::clientAllowsMainFrameRubberBandingOnSide(BoxSide side)
{
Locker locker { m_swipeStateLock };
return m_swipeState.canRubberBand.at(side);
return m_swipeState.clientAllowedRubberBandableEdges.at(side);
}

void ScrollingTree::addPendingScrollUpdate(ScrollUpdate&& update)
Expand Down Expand Up @@ -843,13 +843,13 @@ bool ScrollingTree::willWheelEventStartSwipeGesture(const PlatformWheelEvent& wh

Locker locker { m_swipeStateLock };

if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedState.left() && !m_swipeState.canRubberBand.left())
if (wheelEvent.deltaX() > 0 && m_swipeState.mainFramePinnedState.left() && !m_swipeState.clientAllowedRubberBandableEdges.left())
return true;
if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedState.right() && !m_swipeState.canRubberBand.right())
if (wheelEvent.deltaX() < 0 && m_swipeState.mainFramePinnedState.right() && !m_swipeState.clientAllowedRubberBandableEdges.right())
return true;
if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedState.top() && !m_swipeState.canRubberBand.top())
if (wheelEvent.deltaY() > 0 && m_swipeState.mainFramePinnedState.top() && !m_swipeState.clientAllowedRubberBandableEdges.top())
return true;
if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedState.bottom() && !m_swipeState.canRubberBand.bottom())
if (wheelEvent.deltaY() < 0 && m_swipeState.mainFramePinnedState.bottom() && !m_swipeState.clientAllowedRubberBandableEdges.bottom())
return true;

return false;
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/page/scrolling/ScrollingTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
void setMainFramePinnedState(RectEdges<bool>);

// Can be called from any thread. Will update what edges allow rubber-banding.
WEBCORE_EXPORT void setMainFrameCanRubberBand(RectEdges<bool>);
bool mainFrameCanRubberBandOnSide(BoxSide);
WEBCORE_EXPORT void setClientAllowedMainFrameRubberBandableEdges(RectEdges<bool>);
bool clientAllowsMainFrameRubberBandingOnSide(BoxSide);

bool isHandlingProgrammaticScroll() const { return m_isHandlingProgrammaticScroll; }
void setIsHandlingProgrammaticScroll(bool isHandlingProgrammaticScroll) { m_isHandlingProgrammaticScroll = isHandlingProgrammaticScroll; }
Expand Down Expand Up @@ -320,7 +320,7 @@ class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
TreeState m_treeState WTF_GUARDED_BY_LOCK(m_treeStateLock);

struct SwipeState {
RectEdges<bool> canRubberBand { true, true, true, true };
RectEdges<bool> clientAllowedRubberBandableEdges { true, true, true, true };
RectEdges<bool> mainFramePinnedState { true, true, true, true };
ScrollPinningBehavior scrollPinningBehavior { ScrollPinningBehavior::DoNotPin };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
bool ScrollingTreeScrollingNodeDelegateMac::shouldRubberBandOnSide(BoxSide side) const
{
if (scrollingNode().isRootNode())
return scrollingTree().mainFrameCanRubberBandOnSide(side);
return scrollingTree().clientAllowsMainFrameRubberBandingOnSide(side);

switch (side) {
case BoxSide::Top:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void RemoteScrollingCoordinatorProxy::handleWheelEvent(const WebWheelEvent& whee
// Replicate the hack in EventDispatcher::internalWheelEvent(). We could pass rubberBandableEdges all the way through the
// WebProcess and back via the ScrollingTree, but we only ever need to consult it here.
if (platformWheelEvent.phase() == PlatformWheelEventPhase::Began)
m_scrollingTree->setMainFrameCanRubberBand(rubberBandableEdges);
m_scrollingTree->setClientAllowedMainFrameRubberBandableEdges(rubberBandableEdges);

auto processingSteps = m_scrollingTree->determineWheelEventProcessing(platformWheelEvent);
if (!processingSteps.contains(WheelEventProcessingSteps::AsyncScrolling)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ OptionSet<WheelEventProcessingSteps> RemoteLayerTreeEventDispatcher::determineWh
// Replicate the hack in EventDispatcher::internalWheelEvent(). We could pass rubberBandableEdges all the way through the
// WebProcess and back via the ScrollingTree, but we only ever need to consult it here.
if (wheelEvent.phase() == PlatformWheelEventPhase::Began)
scrollingTree->setMainFrameCanRubberBand(rubberBandableEdges);
scrollingTree->setClientAllowedMainFrameRubberBandableEdges(rubberBandableEdges);

return scrollingTree->determineWheelEventProcessing(wheelEvent);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void EventDispatcher::internalWheelEvent(PageIdentifier pageID, const WebWheelEv
// scrolling tree can be notified.
// We only need to do this at the beginning of the gesture.
if (platformWheelEvent.phase() == PlatformWheelEventPhase::Began)
scrollingTree->setMainFrameCanRubberBand(rubberBandableEdges);
scrollingTree->setClientAllowedMainFrameRubberBandableEdges(rubberBandableEdges);

auto processingSteps = scrollingTree->determineWheelEventProcessing(platformWheelEvent);
bool useMainThreadForScrolling = processingSteps.contains(WheelEventProcessingSteps::SynchronousScrolling);
Expand Down

0 comments on commit 5ffedc5

Please sign in to comment.