Title: [274495] trunk/Source/WebCore
Revision
274495
Author
[email protected]
Date
2021-03-16 11:03:44 -0700 (Tue, 16 Mar 2021)

Log Message

[Nicosia] Add support for scroll-snap when handling wheel events
https://bugs.webkit.org/show_bug.cgi?id=223255

Patch by Martin Robinson <[email protected]> on 2021-03-16
Reviewed by Žan Doberšek.

No new tests. This fixes css3/scroll-snap/scroll-snap-wheel-event.html
for Nicosia ports.

* page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
(WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):
(WebCore::ScrollingTreeScrollingNodeDelegateNicosia::pageScaleFactor):
* page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274494 => 274495)


--- trunk/Source/WebCore/ChangeLog	2021-03-16 17:56:20 UTC (rev 274494)
+++ trunk/Source/WebCore/ChangeLog	2021-03-16 18:03:44 UTC (rev 274495)
@@ -1,3 +1,18 @@
+2021-03-16  Martin Robinson  <[email protected]>
+
+        [Nicosia] Add support for scroll-snap when handling wheel events
+        https://bugs.webkit.org/show_bug.cgi?id=223255
+
+        Reviewed by Žan Doberšek.
+
+        No new tests. This fixes css3/scroll-snap/scroll-snap-wheel-event.html
+        for Nicosia ports.
+
+        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp:
+        (WebCore::ScrollingTreeScrollingNodeDelegateNicosia::handleWheelEvent):
+        (WebCore::ScrollingTreeScrollingNodeDelegateNicosia::pageScaleFactor):
+        * page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h:
+
 2021-03-16  Alex Christensen  <[email protected]>
 
         Terminate network process when making new WebProcessPool in Lutron App

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp (274494 => 274495)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-03-16 17:56:20 UTC (rev 274494)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp	2021-03-16 18:03:44 UTC (rev 274495)
@@ -163,17 +163,33 @@
         }
     }
 
+    deltaX = -deltaX;
+    deltaY = -deltaY;
+
+    if (!scrollingNode().snapOffsetsInfo().isEmpty()) {
+        float scale = pageScaleFactor();
+        FloatPoint originalOffset = LayoutPoint(scrollingNode().currentScrollOffset().x() / scale, scrollingNode().currentScrollOffset().y() / scale);
+        FloatPoint newFloatOffset = scrollingNode().currentScrollOffset() + FloatSize(deltaX, deltaY);
+        auto newOffset = LayoutPoint(newFloatOffset.x() / scale, newFloatOffset.y() / scale);
+
+        auto offsetX = scrollingNode().snapOffsetsInfo().closestSnapOffset(ScrollEventAxis::Horizontal, newOffset.x(), deltaX, originalOffset.x()).first;
+        auto offsetY = scrollingNode().snapOffsetsInfo().closestSnapOffset(ScrollEventAxis::Vertical, newOffset.y(), deltaY, originalOffset.y()).first;
+
+        deltaX = (offsetX - originalOffset.x()) * scale;
+        deltaY = (offsetY - originalOffset.y()) * scale;
+    }
+
 #if ENABLE(SMOOTH_SCROLLING)
     if (m_scrollAnimatorEnabled && !wheelEvent.hasPreciseScrollingDeltas()) {
         ensureScrollAnimationSmooth();
-        m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, -deltaX);
-        m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, -deltaY);
+        m_smoothAnimation->scroll(HorizontalScrollbar, ScrollByPixel, 1, deltaX);
+        m_smoothAnimation->scroll(VerticalScrollbar, ScrollByPixel, 1, deltaY);
         return WheelEventHandlingResult::handled();
     }
 #endif
 
     auto updateScope = createUpdateScope();
-    scrollingNode().scrollBy({ -deltaX, -deltaY });
+    scrollingNode().scrollBy({ deltaX, deltaY });
 
     return WheelEventHandlingResult::handled();
 }
@@ -192,6 +208,14 @@
 #endif
 }
 
+float ScrollingTreeScrollingNodeDelegateNicosia::pageScaleFactor()
+{
+    // FIXME: What should this return for non-root frames, and overflow?
+    // Also, this should not have to access ScrollingTreeFrameScrollingNode.
+    return is<ScrollingTreeFrameScrollingNode>(scrollingNode()) ?
+        downcast<ScrollingTreeFrameScrollingNode>(scrollingNode()).frameScaleFactor() : 1.;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)

Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h (274494 => 274495)


--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h	2021-03-16 17:56:20 UTC (rev 274494)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.h	2021-03-16 18:03:44 UTC (rev 274495)
@@ -57,6 +57,7 @@
 
 private:
     bool m_scrollAnimatorEnabled { false };
+    float pageScaleFactor();
 
 #if ENABLE(KINETIC_SCROLLING)
     void ensureScrollAnimationKinetic();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to