Title: [286682] branches/safari-612-branch/Source
Revision
286682
Author
alanc...@apple.com
Date
2021-12-08 12:23:02 -0800 (Wed, 08 Dec 2021)

Log Message

Cherry-pick r283353. rdar://problem/85928816

    Simplify some scrolling-related code in WebKit with use of RectEdges<bool>
    https://bugs.webkit.org/show_bug.cgi?id=231037

    Reviewed by Tim Horton.

    Source/WebCore:

    Export edgePinnedState().

    * platform/ScrollableArea.h:

    Source/WebKit:

    Use RectEdges<bool> in code that tracks rubber banding state, and edge pinned state.

    * Shared/WebCoreArgumentCoders.cpp:
    (IPC::ArgumentCoder<RectEdges<bool>>::encode):
    (IPC::ArgumentCoder<RectEdges<bool>>::decode):
    * Shared/WebCoreArgumentCoders.h:
    * UIProcess/API/C/WKPage.cpp:
    (WKPageIsPinnedToLeftSide):
    (WKPageIsPinnedToRightSide):
    (WKPageIsPinnedToTopSide):
    (WKPageIsPinnedToBottomSide):
    (WKPageRubberBandsAtLeft):
    (WKPageRubberBandsAtRight):
    (WKPageRubberBandsAtTop):
    (WKPageRubberBandsAtBottom):
    * UIProcess/Cocoa/WebViewImpl.mm:
    (WebKit::toWKRectEdge):
    (WebKit::toRectEdges):
    (WebKit::WebViewImpl::pinnedState):
    (WebKit::WebViewImpl::rubberBandingEnabled):
    (WebKit::WebViewImpl::setRubberBandingEnabled):
    * UIProcess/ViewGestureController.cpp:
    (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::sendWheelEvent):
    (WebKit::WebPageProxy::setRubberBandsAtLeft):
    (WebKit::WebPageProxy::setRubberBandsAtRight):
    (WebKit::WebPageProxy::setRubberBandsAtTop):
    (WebKit::WebPageProxy::setRubberBandsAtBottom):
    (WebKit::WebPageProxy::didCommitLoadForFrame):
    (WebKit::WebPageProxy::resetState):
    (WebKit::WebPageProxy::didChangeScrollOffsetPinningForMainFrame):
    (WebKit::WebPageProxy::rubberBandsAtLeft const): Deleted.
    (WebKit::WebPageProxy::rubberBandsAtRight const): Deleted.
    (WebKit::WebPageProxy::rubberBandsAtTop const): Deleted.
    (WebKit::WebPageProxy::rubberBandsAtBottom const): Deleted.
    * UIProcess/WebPageProxy.h:
    * UIProcess/WebPageProxy.messages.in:
    * WebProcess/WebPage/EventDispatcher.cpp:
    (WebKit::EventDispatcher::wheelEvent):
    * WebProcess/WebPage/EventDispatcher.h:
    * WebProcess/WebPage/EventDispatcher.messages.in:
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::updateMainFrameScrollOffsetPinning):
    * WebProcess/WebPage/WebPage.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283353 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (286681 => 286682)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-12-08 20:23:02 UTC (rev 286682)
@@ -1,5 +1,81 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r283353. rdar://problem/85928816
+
+    Simplify some scrolling-related code in WebKit with use of RectEdges<bool>
+    https://bugs.webkit.org/show_bug.cgi?id=231037
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Export edgePinnedState().
+    
+    * platform/ScrollableArea.h:
+    
+    Source/WebKit:
+    
+    Use RectEdges<bool> in code that tracks rubber banding state, and edge pinned state.
+    
+    * Shared/WebCoreArgumentCoders.cpp:
+    (IPC::ArgumentCoder<RectEdges<bool>>::encode):
+    (IPC::ArgumentCoder<RectEdges<bool>>::decode):
+    * Shared/WebCoreArgumentCoders.h:
+    * UIProcess/API/C/WKPage.cpp:
+    (WKPageIsPinnedToLeftSide):
+    (WKPageIsPinnedToRightSide):
+    (WKPageIsPinnedToTopSide):
+    (WKPageIsPinnedToBottomSide):
+    (WKPageRubberBandsAtLeft):
+    (WKPageRubberBandsAtRight):
+    (WKPageRubberBandsAtTop):
+    (WKPageRubberBandsAtBottom):
+    * UIProcess/Cocoa/WebViewImpl.mm:
+    (WebKit::toWKRectEdge):
+    (WebKit::toRectEdges):
+    (WebKit::WebViewImpl::pinnedState):
+    (WebKit::WebViewImpl::rubberBandingEnabled):
+    (WebKit::WebViewImpl::setRubberBandingEnabled):
+    * UIProcess/ViewGestureController.cpp:
+    (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::sendWheelEvent):
+    (WebKit::WebPageProxy::setRubberBandsAtLeft):
+    (WebKit::WebPageProxy::setRubberBandsAtRight):
+    (WebKit::WebPageProxy::setRubberBandsAtTop):
+    (WebKit::WebPageProxy::setRubberBandsAtBottom):
+    (WebKit::WebPageProxy::didCommitLoadForFrame):
+    (WebKit::WebPageProxy::resetState):
+    (WebKit::WebPageProxy::didChangeScrollOffsetPinningForMainFrame):
+    (WebKit::WebPageProxy::rubberBandsAtLeft const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtRight const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtTop const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtBottom const): Deleted.
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * WebProcess/WebPage/EventDispatcher.cpp:
+    (WebKit::EventDispatcher::wheelEvent):
+    * WebProcess/WebPage/EventDispatcher.h:
+    * WebProcess/WebPage/EventDispatcher.messages.in:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::updateMainFrameScrollOffsetPinning):
+    * WebProcess/WebPage/WebPage.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-30  Simon Fraser  <simon.fra...@apple.com>
+
+            Simplify some scrolling-related code in WebKit with use of RectEdges<bool>
+            https://bugs.webkit.org/show_bug.cgi?id=231037
+
+            Reviewed by Tim Horton.
+
+            Export edgePinnedState().
+
+            * platform/ScrollableArea.h:
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r286270. rdar://problem/85928816
 
     Plumb raw platform scrolling deltas along in wheel events

Modified: branches/safari-612-branch/Source/WebCore/platform/ScrollableArea.h (286681 => 286682)


--- branches/safari-612-branch/Source/WebCore/platform/ScrollableArea.h	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebCore/platform/ScrollableArea.h	2021-12-08 20:23:02 UTC (rev 286682)
@@ -318,7 +318,7 @@
 
     bool isPinnedForScrollDeltaOnAxis(float scrollDelta, ScrollEventAxis) const;
     bool isPinnedForScrollDelta(const FloatSize&) const;
-    RectEdges<bool> edgePinnedState() const;
+    WEBCORE_EXPORT RectEdges<bool> edgePinnedState() const;
 
     // True if scrolling happens by moving compositing layers.
     virtual bool usesCompositedScrolling() const { return false; }

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-12-08 20:23:02 UTC (rev 286682)
@@ -1,5 +1,123 @@
 2021-12-01  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r283353. rdar://problem/85928816
+
+    Simplify some scrolling-related code in WebKit with use of RectEdges<bool>
+    https://bugs.webkit.org/show_bug.cgi?id=231037
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    Export edgePinnedState().
+    
+    * platform/ScrollableArea.h:
+    
+    Source/WebKit:
+    
+    Use RectEdges<bool> in code that tracks rubber banding state, and edge pinned state.
+    
+    * Shared/WebCoreArgumentCoders.cpp:
+    (IPC::ArgumentCoder<RectEdges<bool>>::encode):
+    (IPC::ArgumentCoder<RectEdges<bool>>::decode):
+    * Shared/WebCoreArgumentCoders.h:
+    * UIProcess/API/C/WKPage.cpp:
+    (WKPageIsPinnedToLeftSide):
+    (WKPageIsPinnedToRightSide):
+    (WKPageIsPinnedToTopSide):
+    (WKPageIsPinnedToBottomSide):
+    (WKPageRubberBandsAtLeft):
+    (WKPageRubberBandsAtRight):
+    (WKPageRubberBandsAtTop):
+    (WKPageRubberBandsAtBottom):
+    * UIProcess/Cocoa/WebViewImpl.mm:
+    (WebKit::toWKRectEdge):
+    (WebKit::toRectEdges):
+    (WebKit::WebViewImpl::pinnedState):
+    (WebKit::WebViewImpl::rubberBandingEnabled):
+    (WebKit::WebViewImpl::setRubberBandingEnabled):
+    * UIProcess/ViewGestureController.cpp:
+    (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::sendWheelEvent):
+    (WebKit::WebPageProxy::setRubberBandsAtLeft):
+    (WebKit::WebPageProxy::setRubberBandsAtRight):
+    (WebKit::WebPageProxy::setRubberBandsAtTop):
+    (WebKit::WebPageProxy::setRubberBandsAtBottom):
+    (WebKit::WebPageProxy::didCommitLoadForFrame):
+    (WebKit::WebPageProxy::resetState):
+    (WebKit::WebPageProxy::didChangeScrollOffsetPinningForMainFrame):
+    (WebKit::WebPageProxy::rubberBandsAtLeft const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtRight const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtTop const): Deleted.
+    (WebKit::WebPageProxy::rubberBandsAtBottom const): Deleted.
+    * UIProcess/WebPageProxy.h:
+    * UIProcess/WebPageProxy.messages.in:
+    * WebProcess/WebPage/EventDispatcher.cpp:
+    (WebKit::EventDispatcher::wheelEvent):
+    * WebProcess/WebPage/EventDispatcher.h:
+    * WebProcess/WebPage/EventDispatcher.messages.in:
+    * WebProcess/WebPage/WebPage.cpp:
+    (WebKit::WebPage::updateMainFrameScrollOffsetPinning):
+    * WebProcess/WebPage/WebPage.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283353 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-30  Simon Fraser  <simon.fra...@apple.com>
+
+            Simplify some scrolling-related code in WebKit with use of RectEdges<bool>
+            https://bugs.webkit.org/show_bug.cgi?id=231037
+
+            Reviewed by Tim Horton.
+
+            Use RectEdges<bool> in code that tracks rubber banding state, and edge pinned state.
+
+            * Shared/WebCoreArgumentCoders.cpp:
+            (IPC::ArgumentCoder<RectEdges<bool>>::encode):
+            (IPC::ArgumentCoder<RectEdges<bool>>::decode):
+            * Shared/WebCoreArgumentCoders.h:
+            * UIProcess/API/C/WKPage.cpp:
+            (WKPageIsPinnedToLeftSide):
+            (WKPageIsPinnedToRightSide):
+            (WKPageIsPinnedToTopSide):
+            (WKPageIsPinnedToBottomSide):
+            (WKPageRubberBandsAtLeft):
+            (WKPageRubberBandsAtRight):
+            (WKPageRubberBandsAtTop):
+            (WKPageRubberBandsAtBottom):
+            * UIProcess/Cocoa/WebViewImpl.mm:
+            (WebKit::toWKRectEdge):
+            (WebKit::toRectEdges):
+            (WebKit::WebViewImpl::pinnedState):
+            (WebKit::WebViewImpl::rubberBandingEnabled):
+            (WebKit::WebViewImpl::setRubberBandingEnabled):
+            * UIProcess/ViewGestureController.cpp:
+            (WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::sendWheelEvent):
+            (WebKit::WebPageProxy::setRubberBandsAtLeft):
+            (WebKit::WebPageProxy::setRubberBandsAtRight):
+            (WebKit::WebPageProxy::setRubberBandsAtTop):
+            (WebKit::WebPageProxy::setRubberBandsAtBottom):
+            (WebKit::WebPageProxy::didCommitLoadForFrame):
+            (WebKit::WebPageProxy::resetState):
+            (WebKit::WebPageProxy::didChangeScrollOffsetPinningForMainFrame):
+            (WebKit::WebPageProxy::rubberBandsAtLeft const): Deleted.
+            (WebKit::WebPageProxy::rubberBandsAtRight const): Deleted.
+            (WebKit::WebPageProxy::rubberBandsAtTop const): Deleted.
+            (WebKit::WebPageProxy::rubberBandsAtBottom const): Deleted.
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * WebProcess/WebPage/EventDispatcher.cpp:
+            (WebKit::EventDispatcher::wheelEvent):
+            * WebProcess/WebPage/EventDispatcher.h:
+            * WebProcess/WebPage/EventDispatcher.messages.in:
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::updateMainFrameScrollOffsetPinning):
+            * WebProcess/WebPage/WebPage.h:
+
+2021-12-01  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r286277. rdar://problem/85928816
 
     Fix the build

Modified: branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -675,8 +675,19 @@
 {
     return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent);
 }
+
+
+void ArgumentCoder<RectEdges<bool>>::encode(Encoder& encoder, const RectEdges<bool>& boxEdges)
+{
+    SimpleArgumentCoder<RectEdges<bool>>::encode(encoder, boxEdges);
+}
     
+bool ArgumentCoder<RectEdges<bool>>::decode(Decoder& decoder, RectEdges<bool>& boxEdges)
+{
+    return SimpleArgumentCoder<RectEdges<bool>>::decode(decoder, boxEdges);
+}
 
+
 void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
 {
     SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);

Modified: branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.h (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-12-08 20:23:02 UTC (rev 286682)
@@ -319,6 +319,11 @@
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatBoxExtent&);
 };
 
+template<> struct ArgumentCoder<WebCore::RectEdges<bool>> {
+    static void encode(Encoder&, const WebCore::RectEdges<bool>&);
+    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::RectEdges<bool>&);
+};
+
 template<> struct ArgumentCoder<WebCore::FloatSize> {
     static void encode(Encoder&, const WebCore::FloatSize&);
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatSize&);

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -678,27 +678,27 @@
 
 bool WKPageIsPinnedToLeftSide(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->isPinnedToLeftSide();
+    return toImpl(pageRef)->pinnedState().left();
 }
 
 bool WKPageIsPinnedToRightSide(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->isPinnedToRightSide();
+    return toImpl(pageRef)->pinnedState().right();
 }
 
 bool WKPageIsPinnedToTopSide(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->isPinnedToTopSide();
+    return toImpl(pageRef)->pinnedState().top();
 }
 
 bool WKPageIsPinnedToBottomSide(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->isPinnedToBottomSide();
+    return toImpl(pageRef)->pinnedState().bottom();
 }
 
 bool WKPageRubberBandsAtLeft(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->rubberBandsAtLeft();
+    return toImpl(pageRef)->rubberBandableEdges().left();
 }
 
 void WKPageSetRubberBandsAtLeft(WKPageRef pageRef, bool rubberBandsAtLeft)
@@ -709,7 +709,7 @@
 
 bool WKPageRubberBandsAtRight(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->rubberBandsAtRight();
+    return toImpl(pageRef)->rubberBandableEdges().right();
 }
 
 void WKPageSetRubberBandsAtRight(WKPageRef pageRef, bool rubberBandsAtRight)
@@ -720,7 +720,7 @@
 
 bool WKPageRubberBandsAtTop(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->rubberBandsAtTop();
+    return toImpl(pageRef)->rubberBandableEdges().top();
 }
 
 void WKPageSetRubberBandsAtTop(WKPageRef pageRef, bool rubberBandsAtTop)
@@ -731,7 +731,7 @@
 
 bool WKPageRubberBandsAtBottom(WKPageRef pageRef)
 {
-    return toImpl(pageRef)->rubberBandsAtBottom();
+    return toImpl(pageRef)->rubberBandableEdges().bottom();
 }
 
 void WKPageSetRubberBandsAtBottom(WKPageRef pageRef, bool rubberBandsAtBottom)

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-12-08 20:23:02 UTC (rev 286682)
@@ -5609,40 +5609,48 @@
     mouseMovedInternal(event);
 }
 
+static _WKRectEdge toWKRectEdge(RectEdges<bool> edges)
+{
+    _WKRectEdge result = _WKRectEdgeNone;
+
+    if (edges.left())
+        result |= _WKRectEdgeLeft;
+
+    if (edges.right())
+        result |= _WKRectEdgeRight;
+
+    if (edges.top())
+        result |= _WKRectEdgeTop;
+
+    if (edges.bottom())
+        result |= _WKRectEdgeBottom;
+
+    return result;
+}
+
+static RectEdges<bool> toRectEdges(_WKRectEdge edges)
+{
+    return {
+        edges & _WKRectEdgeTop,
+        edges & _WKRectEdgeRight,
+        edges & _WKRectEdgeBottom,
+        edges & _WKRectEdgeLeft
+    };
+}
+
 _WKRectEdge WebViewImpl::pinnedState()
 {
-    _WKRectEdge state = _WKRectEdgeNone;
-    if (m_page->isPinnedToLeftSide())
-        state |= _WKRectEdgeLeft;
-    if (m_page->isPinnedToRightSide())
-        state |= _WKRectEdgeRight;
-    if (m_page->isPinnedToTopSide())
-        state |= _WKRectEdgeTop;
-    if (m_page->isPinnedToBottomSide())
-        state |= _WKRectEdgeBottom;
-    return state;
+    return toWKRectEdge(m_page->pinnedState());
 }
 
 _WKRectEdge WebViewImpl::rubberBandingEnabled()
 {
-    _WKRectEdge state = _WKRectEdgeNone;
-    if (m_page->rubberBandsAtLeft())
-        state |= _WKRectEdgeLeft;
-    if (m_page->rubberBandsAtRight())
-        state |= _WKRectEdgeRight;
-    if (m_page->rubberBandsAtTop())
-        state |= _WKRectEdgeTop;
-    if (m_page->rubberBandsAtBottom())
-        state |= _WKRectEdgeBottom;
-    return state;
+    return toWKRectEdge(m_page->rubberBandableEdges());
 }
 
 void WebViewImpl::setRubberBandingEnabled(_WKRectEdge state)
 {
-    m_page->setRubberBandsAtLeft(state & _WKRectEdgeLeft);
-    m_page->setRubberBandsAtRight(state & _WKRectEdgeRight);
-    m_page->setRubberBandsAtTop(state & _WKRectEdgeTop);
-    m_page->setRubberBandsAtBottom(state & _WKRectEdgeBottom);
+    m_page->setRubberBandableEdges(toRectEdges(state));
 }
 
 void WebViewImpl::mouseDown(NSEvent *event)

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/ViewGestureController.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/ViewGestureController.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/ViewGestureController.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -421,8 +421,8 @@
     if (deltaShouldCancelSwipe(size))
         return false;
 
-    bool isPinnedToLeft = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToLeftSide();
-    bool isPinnedToRight = m_shouldIgnorePinnedState || m_webPageProxy.isPinnedToRightSide();
+    bool isPinnedToLeft = m_shouldIgnorePinnedState || m_webPageProxy.pinnedState().left();
+    bool isPinnedToRight = m_shouldIgnorePinnedState || m_webPageProxy.pinnedState().right();
 
     bool tryingToSwipeBack = size.width() > 0 && isPinnedToLeft;
     bool tryingToSwipeForward = size.width() < 0 && isPinnedToRight;

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -2925,17 +2925,14 @@
     auto* connection = messageSenderConnection();
     if (!connection)
         return;
+    
+    auto rubberBandableEdges = this->rubberBandableEdges();
+    if (shouldUseImplicitRubberBandControl()) {
+        rubberBandableEdges.setLeft(!m_backForwardList->backItem());
+        rubberBandableEdges.setRight(!m_backForwardList->forwardItem());
+    }
+    connection -> send(Messages::EventDispatcher::WheelEvent(m_webPageID, event, rubberBandableEdges), 0);
 
-    connection->send(
-        Messages::EventDispatcher::WheelEvent(
-            m_webPageID,
-            event,
-            shouldUseImplicitRubberBandControl() ? !m_backForwardList->backItem() : rubberBandsAtLeft(),
-            shouldUseImplicitRubberBandControl() ? !m_backForwardList->forwardItem() : rubberBandsAtRight(),
-            rubberBandsAtTop(),
-            rubberBandsAtBottom()
-    ), 0, { }, Thread::QOS::UserInteractive);
-
     // Manually ping the web process to check for responsiveness since our wheel
     // event will dispatch to a non-main thread, which always responds.
     m_process->isResponsiveWithLazyStop();
@@ -4129,44 +4126,24 @@
     send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations));
 }
 
-bool WebPageProxy::rubberBandsAtLeft() const
-{
-    return m_rubberBandsAtLeft;
-}
-
 void WebPageProxy::setRubberBandsAtLeft(bool rubberBandsAtLeft)
 {
-    m_rubberBandsAtLeft = rubberBandsAtLeft;
+    m_rubberBandableEdges.setLeft(rubberBandsAtLeft);
 }
 
-bool WebPageProxy::rubberBandsAtRight() const
-{
-    return m_rubberBandsAtRight;
-}
-
 void WebPageProxy::setRubberBandsAtRight(bool rubberBandsAtRight)
 {
-    m_rubberBandsAtRight = rubberBandsAtRight;
+    m_rubberBandableEdges.setRight(rubberBandsAtRight);
 }
 
-bool WebPageProxy::rubberBandsAtTop() const
-{
-    return m_rubberBandsAtTop;
-}
-
 void WebPageProxy::setRubberBandsAtTop(bool rubberBandsAtTop)
 {
-    m_rubberBandsAtTop = rubberBandsAtTop;
+    m_rubberBandableEdges.setTop(rubberBandsAtTop);
 }
 
-bool WebPageProxy::rubberBandsAtBottom() const
-{
-    return m_rubberBandsAtBottom;
-}
-
 void WebPageProxy::setRubberBandsAtBottom(bool rubberBandsAtBottom)
 {
-    m_rubberBandsAtBottom = rubberBandsAtBottom;
+    m_rubberBandableEdges.setBottom(rubberBandsAtBottom);
 }
     
 void WebPageProxy::setEnableVerticalRubberBanding(bool enableVerticalRubberBanding)
@@ -4938,11 +4915,7 @@
         if (m_mainFrameHasCustomContentProvider) {
             // Always assume that the main frame is pinned here, since the custom representation view will handle
             // any wheel events and dispatch them to the WKView when necessary.
-            m_mainFrameIsPinnedToLeftSide = true;
-            m_mainFrameIsPinnedToRightSide = true;
-            m_mainFrameIsPinnedToTopSide = true;
-            m_mainFrameIsPinnedToBottomSide = true;
-
+            m_mainFramePinnedState = { true, true, true, true };
             m_uiClient->pinnedStateDidChange(*this);
         }
         pageClient().didCommitLoadForMainFrame(mimeType, frameHasCustomContentProvider);
@@ -7854,10 +7827,7 @@
     m_mainFrameHasHorizontalScrollbar = false;
     m_mainFrameHasVerticalScrollbar = false;
 
-    m_mainFrameIsPinnedToLeftSide = true;
-    m_mainFrameIsPinnedToRightSide = true;
-    m_mainFrameIsPinnedToTopSide = true;
-    m_mainFrameIsPinnedToBottomSide = true;
+    m_mainFramePinnedState = { true, true, true, true };
 
     m_visibleScrollerThumbRect = IntRect();
 
@@ -8764,13 +8734,10 @@
     m_mainFrameHasVerticalScrollbar = hasVerticalScrollbar;
 }
 
-void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide)
+void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(RectEdges<bool> pinnedState)
 {
     pageClient().pinnedStateWillChange();
-    m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide;
-    m_mainFrameIsPinnedToRightSide = pinnedToRightSide;
-    m_mainFrameIsPinnedToTopSide = pinnedToTopSide;
-    m_mainFrameIsPinnedToBottomSide = pinnedToBottomSide;
+    m_mainFramePinnedState = pinnedState;
     pageClient().pinnedStateDidChange();
 
     m_uiClient->pinnedStateDidChange(*this);

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.h	2021-12-08 20:23:02 UTC (rev 286682)
@@ -101,6 +101,7 @@
 #include <WebCore/PlatformSpeechSynthesisUtterance.h>
 #include <WebCore/PlatformSpeechSynthesizer.h>
 #include <WebCore/PointerID.h>
+#include <WebCore/RectEdges.h>
 #include <WebCore/RegistrableDomain.h>
 #include <WebCore/RunJavaScriptParameters.h>
 #include <WebCore/ScrollTypes.h>
@@ -1085,18 +1086,13 @@
     void setSuppressScrollbarAnimations(bool);
     bool areScrollbarAnimationsSuppressed() const { return m_suppressScrollbarAnimations; }
 
-    bool isPinnedToLeftSide() const { return m_mainFrameIsPinnedToLeftSide; }
-    bool isPinnedToRightSide() const { return m_mainFrameIsPinnedToRightSide; }
-    bool isPinnedToTopSide() const { return m_mainFrameIsPinnedToTopSide; }
-    bool isPinnedToBottomSide() const { return m_mainFrameIsPinnedToBottomSide; }
+    WebCore::RectEdges<bool> pinnedState() const { return m_mainFramePinnedState; }
 
-    bool rubberBandsAtLeft() const;
+    WebCore::RectEdges<bool> rubberBandableEdges() const { return m_rubberBandableEdges; }
+    void setRubberBandableEdges(WebCore::RectEdges<bool> edges) { m_rubberBandableEdges = edges; }
     void setRubberBandsAtLeft(bool);
-    bool rubberBandsAtRight() const;
     void setRubberBandsAtRight(bool);
-    bool rubberBandsAtTop() const;
     void setRubberBandsAtTop(bool);
-    bool rubberBandsAtBottom() const;
     void setRubberBandsAtBottom(bool);
 
     void setShouldUseImplicitRubberBandControl(bool shouldUseImplicitRubberBandControl) { m_shouldUseImplicitRubberBandControl = shouldUseImplicitRubberBandControl; }
@@ -2148,7 +2144,7 @@
     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
     void recommendedScrollbarStyleDidChange(int32_t newStyle);
     void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar);
-    void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide);
+    void didChangeScrollOffsetPinningForMainFrame(WebCore::RectEdges<bool>);
     void didChangePageCount(unsigned);
     void themeColorChanged(const WebCore::Color&);
     void pageExtendedBackgroundColorDidChange(const WebCore::Color&);
@@ -2851,7 +2847,10 @@
 #endif
 
     PageLoadState m_pageLoadState;
-    
+
+    WebCore::RectEdges<bool> m_mainFramePinnedState { true, true, true, true };
+    WebCore::RectEdges<bool> m_rubberBandableEdges { true, true, true, true };
+
     bool m_delegatesScrolling { false };
 
     bool m_mainFrameHasHorizontalScrollbar { false };
@@ -2860,16 +2859,7 @@
     // Whether horizontal wheel events can be handled directly for swiping purposes.
     bool m_canShortCircuitHorizontalWheelEvents { true };
 
-    bool m_mainFrameIsPinnedToLeftSide { true };
-    bool m_mainFrameIsPinnedToRightSide { true };
-    bool m_mainFrameIsPinnedToTopSide { true };
-    bool m_mainFrameIsPinnedToBottomSide { true };
-
     bool m_shouldUseImplicitRubberBandControl { false };
-    bool m_rubberBandsAtLeft { true };
-    bool m_rubberBandsAtRight { true };
-    bool m_rubberBandsAtTop { true };
-    bool m_rubberBandsAtBottom { true };
         
     bool m_enableVerticalRubberBanding { true };
     bool m_enableHorizontalRubberBanding { true };

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-12-08 20:23:02 UTC (rev 286682)
@@ -75,7 +75,7 @@
     NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
     RecommendedScrollbarStyleDidChange(int32_t newStyle)
     DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
-    DidChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide)
+    DidChangeScrollOffsetPinningForMainFrame(WebCore::RectEdges<bool> pinnedState)
     DidChangePageCount(unsigned pageCount)
     ThemeColorChanged(WebCore::Color themeColor)
     PageExtendedBackgroundColorDidChange(WebCore::Color backgroundColor)

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -96,7 +96,7 @@
     connection->addWorkQueueMessageReceiver(Messages::EventDispatcher::messageReceiverName(), m_queue.get(), this);
 }
 
-void EventDispatcher::wheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
+void EventDispatcher::wheelEvent(PageIdentifier pageID, const WebWheelEvent& wheelEvent, RectEdges<bool> rubberBandableEdges)
 {
 #if PLATFORM(COCOA) || ENABLE(SCROLLING_THREAD)
     PlatformWheelEvent platformWheelEvent = platform(wheelEvent);
@@ -137,7 +137,7 @@
         // scrolling tree can be notified.
         // We only need to do this at the beginning of the gesture.
         if (platformWheelEvent.phase() == PlatformWheelEventPhase::Began)
-            scrollingTree->setMainFrameCanRubberBand({ canRubberBandAtTop, canRubberBandAtRight, canRubberBandAtBottom, canRubberBandAtLeft });
+            scrollingTree->setMainFrameCanRubberBand(rubberBandableEdges);
 
         auto processingSteps = scrollingTree->determineWheelEventProcessing(platformWheelEvent);
 
@@ -165,10 +165,7 @@
         });
     } while (false);
 #else
-    UNUSED_PARAM(canRubberBandAtLeft);
-    UNUSED_PARAM(canRubberBandAtRight);
-    UNUSED_PARAM(canRubberBandAtTop);
-    UNUSED_PARAM(canRubberBandAtBottom);
+    UNUSED_PARAM(rubberBandableEdges);
 
     dispatchWheelEventViaMainThread(pageID, wheelEvent, processingSteps);
 #endif

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.h (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.h	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.h	2021-12-08 20:23:02 UTC (rev 286682)
@@ -30,6 +30,7 @@
 #include "WebEvent.h"
 #include <WebCore/PageIdentifier.h>
 #include <WebCore/PlatformWheelEvent.h>
+#include <WebCore/RectEdges.h>
 #include <WebCore/WheelEventDeltaFilter.h>
 #include <memory>
 #include <wtf/HashMap.h>
@@ -83,7 +84,7 @@
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
     // Message handlers
-    void wheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
+    void wheelEvent(WebCore::PageIdentifier, const WebWheelEvent&, WebCore::RectEdges<bool> rubberBandableEdges);
 #if ENABLE(IOS_TOUCH_EVENTS)
     void touchEvent(WebCore::PageIdentifier, const WebTouchEvent&, CompletionHandler<void(bool)>&&);
     void touchEventWithoutCallback(WebCore::PageIdentifier, const WebTouchEvent&);

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in	2021-12-08 20:23:02 UTC (rev 286682)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> EventDispatcher {
-    WheelEvent(WebCore::PageIdentifier pageID, WebKit::WebWheelEvent event, bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
+    WheelEvent(WebCore::PageIdentifier pageID, WebKit::WebWheelEvent event, WebCore::RectEdges<bool> rubberBandableEdges)
 #if ENABLE(IOS_TOUCH_EVENTS)
     TouchEvent(WebCore::PageIdentifier pageID, WebKit::WebTouchEvent event) -> (bool handled) Async MainThreadCallback
     TouchEventWithoutCallback(WebCore::PageIdentifier pageID, WebKit::WebTouchEvent event)

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-12-08 20:23:02 UTC (rev 286682)
@@ -4942,23 +4942,14 @@
 
 void WebPage::updateMainFrameScrollOffsetPinning()
 {
-    Frame& frame = m_page->mainFrame();
-    ScrollPosition scrollPosition = frame.view()->scrollPosition();
-    ScrollPosition maximumScrollPosition = frame.view()->maximumScrollPosition();
-    ScrollPosition minimumScrollPosition = frame.view()->minimumScrollPosition();
+    auto* frameView = mainFrameView();
+    if (!frameView)
+        return;
 
-    bool isPinnedToLeftSide = (scrollPosition.x() <= minimumScrollPosition.x());
-    bool isPinnedToRightSide = (scrollPosition.x() >= maximumScrollPosition.x());
-    bool isPinnedToTopSide = (scrollPosition.y() <= minimumScrollPosition.y());
-    bool isPinnedToBottomSide = (scrollPosition.y() >= maximumScrollPosition.y());
-
-    if (isPinnedToLeftSide != m_cachedMainFrameIsPinnedToLeftSide || isPinnedToRightSide != m_cachedMainFrameIsPinnedToRightSide || isPinnedToTopSide != m_cachedMainFrameIsPinnedToTopSide || isPinnedToBottomSide != m_cachedMainFrameIsPinnedToBottomSide) {
-        send(Messages::WebPageProxy::DidChangeScrollOffsetPinningForMainFrame(isPinnedToLeftSide, isPinnedToRightSide, isPinnedToTopSide, isPinnedToBottomSide));
-        
-        m_cachedMainFrameIsPinnedToLeftSide = isPinnedToLeftSide;
-        m_cachedMainFrameIsPinnedToRightSide = isPinnedToRightSide;
-        m_cachedMainFrameIsPinnedToTopSide = isPinnedToTopSide;
-        m_cachedMainFrameIsPinnedToBottomSide = isPinnedToBottomSide;
+    auto pinnedState = frameView->edgePinnedState();
+    if (pinnedState != m_cachedMainFramePinnedState) {
+        send(Messages::WebPageProxy::DidChangeScrollOffsetPinningForMainFrame(pinnedState));
+        m_cachedMainFramePinnedState = pinnedState;
     }
 }
 

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h (286681 => 286682)


--- branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-12-08 20:22:57 UTC (rev 286681)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-12-08 20:23:02 UTC (rev 286682)
@@ -81,6 +81,7 @@
 #include <WebCore/PluginData.h>
 #include <WebCore/PointerCharacteristics.h>
 #include <WebCore/PointerID.h>
+#include <WebCore/RectEdges.h>
 #include <WebCore/SecurityPolicyViolationEvent.h>
 #include <WebCore/ShareData.h>
 #include <WebCore/SimpleRange.h>
@@ -2156,10 +2157,7 @@
     std::optional<WebCore::SimpleRange> m_rangeForDropSnapshot;
 #endif
 
-    bool m_cachedMainFrameIsPinnedToLeftSide { true };
-    bool m_cachedMainFrameIsPinnedToRightSide { true };
-    bool m_cachedMainFrameIsPinnedToTopSide { true };
-    bool m_cachedMainFrameIsPinnedToBottomSide { true };
+    WebCore::RectEdges<bool> m_cachedMainFramePinnedState { true, true, true, true };
     bool m_canShortCircuitHorizontalWheelEvents { false };
     bool m_hasWheelEventHandlers { false };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to