Title: [181510] trunk/Source/WebCore
Revision
181510
Author
[email protected]
Date
2015-03-15 12:13:36 -0700 (Sun, 15 Mar 2015)

Log Message

scroll snap points do not properly account for zoomed pages
https://bugs.webkit.org/show_bug.cgi?id=142706
<rdar://problem/20165771>

Reviewed by Anders Carlsson.

When a WebView is zoomed (such that it has a non-unity pageScaleFactor), we need to account for this
scaling value when selecting our correct scroll snap point target, as well as when specifying the
pixel location for our animation to target.

* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor): Added new delegate method.
* platform/cocoa/ScrollController.h:
(WebCore::ScrollControllerClient::pageScaleFactor): Added new default delegate.
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::beginScrollSnapAnimation): Calculate the correct scroll target
based on the page scale factor.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (181509 => 181510)


--- trunk/Source/WebCore/ChangeLog	2015-03-15 17:52:03 UTC (rev 181509)
+++ trunk/Source/WebCore/ChangeLog	2015-03-15 19:13:36 UTC (rev 181510)
@@ -1,3 +1,24 @@
+2015-03-15  Brent Fulgham  <[email protected]>
+
+        scroll snap points do not properly account for zoomed pages
+        https://bugs.webkit.org/show_bug.cgi?id=142706
+        <rdar://problem/20165771>
+
+        Reviewed by Anders Carlsson.
+
+        When a WebView is zoomed (such that it has a non-unity pageScaleFactor), we need to account for this
+        scaling value when selecting our correct scroll snap point target, as well as when specifying the
+        pixel location for our animation to target.
+
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h:
+        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+        (WebCore::ScrollingTreeFrameScrollingNodeMac::pageScaleFactor): Added new delegate method.
+        * platform/cocoa/ScrollController.h:
+        (WebCore::ScrollControllerClient::pageScaleFactor): Added new default delegate.
+        * platform/cocoa/ScrollController.mm:
+        (WebCore::ScrollController::beginScrollSnapAnimation): Calculate the correct scroll target
+        based on the page scale factor.
+
 2015-03-15  Csaba Osztrogonác  <[email protected]>
 
         Fix run-bindings-tests on the WinCairo bot

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h (181509 => 181510)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h	2015-03-15 17:52:03 UTC (rev 181509)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h	2015-03-15 19:13:36 UTC (rev 181510)
@@ -82,6 +82,7 @@
 #if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
     LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
     void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
+    float pageScaleFactor() const override;
 #endif
 
     void logExposedUnfilledArea();

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


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-03-15 17:52:03 UTC (rev 181509)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm	2015-03-15 19:13:36 UTC (rev 181510)
@@ -558,6 +558,11 @@
 
     immediateScrollBy(change - currentPosition);
 }
+
+float ScrollingTreeFrameScrollingNodeMac::pageScaleFactor() const
+{
+    return frameScaleFactor();
+}
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (181509 => 181510)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-03-15 17:52:03 UTC (rev 181509)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h	2015-03-15 19:13:36 UTC (rev 181510)
@@ -86,8 +86,12 @@
     virtual void stopScrollSnapTimer(ScrollEventAxis)
     {
         // Override to perform client-specific scroll snap point end logic
-        
     }
+
+    virtual float pageScaleFactor() const
+    {
+        return 1.0f;
+    }
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (181509 => 181510)


--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-03-15 17:52:03 UTC (rev 181509)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm	2015-03-15 19:13:36 UTC (rev 181510)
@@ -684,9 +684,11 @@
     if (snapState.m_snapOffsets.isEmpty())
         return;
 
-    projectedScrollDestination = std::min(std::max(projectedScrollDestination, snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
+    float scaleFactor = m_client->pageScaleFactor();
+    
+    projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
     snapState.m_initialOffset = offset;
-    snapState.m_targetOffset = closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
+    snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
     if (snapState.m_initialOffset == snapState.m_targetOffset)
         return;
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to