Title: [233883] trunk/Source/WebCore
Revision
233883
Author
[email protected]
Date
2018-07-16 21:44:23 -0700 (Mon, 16 Jul 2018)

Log Message

Correctly adjust scroll offsets when a page is zoomed
https://bugs.webkit.org/show_bug.cgi?id=187673
<rdar://problem/41712829>

Reviewed by Wenson Hsieh.

Will add test later.

Make sure that distance is scaled by the pageScaleFactor, to
make sure that we scroll correctly when we are zoomed in.

* page/ios/EventHandlerIOS.mm:
(WebCore::autoscrollAdjustmentFactorForScreenBoundaries):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (233882 => 233883)


--- trunk/Source/WebCore/ChangeLog	2018-07-17 04:22:22 UTC (rev 233882)
+++ trunk/Source/WebCore/ChangeLog	2018-07-17 04:44:23 UTC (rev 233883)
@@ -1,3 +1,19 @@
+2018-07-16  Megan Gardner  <[email protected]>
+
+        Correctly adjust scroll offsets when a page is zoomed
+        https://bugs.webkit.org/show_bug.cgi?id=187673
+        <rdar://problem/41712829>
+
+        Reviewed by Wenson Hsieh.
+
+        Will add test later.
+
+        Make sure that distance is scaled by the pageScaleFactor, to 
+        make sure that we scroll correctly when we are zoomed in.
+
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::autoscrollAdjustmentFactorForScreenBoundaries):
+        
 2018-07-16  Simon Fraser  <[email protected]>
 
         Roll out r233873 and r233875 since they caused 8 new layout test crashes.

Modified: trunk/Source/WebCore/page/ios/EventHandlerIOS.mm (233882 => 233883)


--- trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2018-07-17 04:22:22 UTC (rev 233882)
+++ trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2018-07-17 04:44:23 UTC (rev 233883)
@@ -578,7 +578,7 @@
     m_autoscrollController->stopAutoscrollTimer();
 }
 
-static IntSize autoscrollAdjustmentFactorForScreenBoundaries(const IntPoint& screenPoint, const FloatRect& screenRect)
+static IntSize autoscrollAdjustmentFactorForScreenBoundaries(const IntPoint& contentPosition, const FloatRect& unobscuredContentRect, float zoomFactor)
 {
     // If the window is at the edge of the screen, and the touch position is also at that edge of the screen,
     // we need to adjust the autoscroll amount in order for the user to be able to autoscroll in that direction.
@@ -590,33 +590,35 @@
     
 #define EDGE_DISTANCE_THRESHOLD 100
 
-    float screenLeftEdge = screenRect.x();
-    float insetScreenLeftEdge = screenLeftEdge + EDGE_DISTANCE_THRESHOLD;
-    float screenRightEdge = screenRect.maxX();
-    float insetScreenRightEdge = screenRightEdge - EDGE_DISTANCE_THRESHOLD;
-    if (screenPoint.x() >= screenLeftEdge && screenPoint.x() < insetScreenLeftEdge) {
-        float distanceFromEdge = screenPoint.x() - screenLeftEdge - EDGE_DISTANCE_THRESHOLD;
+    CGSize edgeDistanceThreshold = CGSizeMake(EDGE_DISTANCE_THRESHOLD / zoomFactor, EDGE_DISTANCE_THRESHOLD / zoomFactor);
+    
+    float screenLeftEdge = unobscuredContentRect.x();
+    float insetScreenLeftEdge = screenLeftEdge + edgeDistanceThreshold.width;
+    float screenRightEdge = unobscuredContentRect.maxX();
+    float insetScreenRightEdge = screenRightEdge - edgeDistanceThreshold.width;
+    if (contentPosition.x() >= screenLeftEdge && contentPosition.x() < insetScreenLeftEdge) {
+        float distanceFromEdge = contentPosition.x() - screenLeftEdge - edgeDistanceThreshold.width;
         if (distanceFromEdge < 0)
-            adjustmentFactor.setWidth(-EDGE_DISTANCE_THRESHOLD);
-    } else if (screenPoint.x() >= insetScreenRightEdge && screenPoint.x() < screenRightEdge) {
-        float distanceFromEdge = EDGE_DISTANCE_THRESHOLD - (screenRightEdge - screenPoint.x());
+            adjustmentFactor.setWidth(-edgeDistanceThreshold.width);
+    } else if (contentPosition.x() >= insetScreenRightEdge && contentPosition.x() < screenRightEdge) {
+        float distanceFromEdge = edgeDistanceThreshold.width - (screenRightEdge - contentPosition.x());
         if (distanceFromEdge > 0)
-            adjustmentFactor.setWidth(EDGE_DISTANCE_THRESHOLD);
+            adjustmentFactor.setWidth(edgeDistanceThreshold.width);
     }
     
-    float screenTopEdge = screenRect.y();
-    float insetScreenTopEdge = screenTopEdge + EDGE_DISTANCE_THRESHOLD;
-    float screenBottomEdge = screenRect.maxY();
-    float insetScreenBottomEdge = screenBottomEdge - EDGE_DISTANCE_THRESHOLD;
+    float screenTopEdge = unobscuredContentRect.y();
+    float insetScreenTopEdge = screenTopEdge + edgeDistanceThreshold.height;
+    float screenBottomEdge = unobscuredContentRect.maxY();
+    float insetScreenBottomEdge = screenBottomEdge - edgeDistanceThreshold.height;
     
-    if (screenPoint.y() >= screenTopEdge && screenPoint.y() < insetScreenTopEdge) {
-        float distanceFromEdge = screenPoint.y() - screenTopEdge - EDGE_DISTANCE_THRESHOLD;
+    if (contentPosition.y() >= screenTopEdge && contentPosition.y() < insetScreenTopEdge) {
+        float distanceFromEdge = contentPosition.y() - screenTopEdge - edgeDistanceThreshold.height;
         if (distanceFromEdge < 0)
-            adjustmentFactor.setHeight(-EDGE_DISTANCE_THRESHOLD);
-    } else if (screenPoint.y() >= insetScreenBottomEdge && screenPoint.y() < screenBottomEdge) {
-        float distanceFromEdge = EDGE_DISTANCE_THRESHOLD - (screenBottomEdge - screenPoint.y());
+            adjustmentFactor.setHeight(-edgeDistanceThreshold.height);
+    } else if (contentPosition.y() >= insetScreenBottomEdge && contentPosition.y() < screenBottomEdge) {
+        float distanceFromEdge = edgeDistanceThreshold.height - (screenBottomEdge - contentPosition.y());
         if (distanceFromEdge > 0)
-            adjustmentFactor.setHeight(EDGE_DISTANCE_THRESHOLD);
+            adjustmentFactor.setHeight(edgeDistanceThreshold.height);
     }
     
     return adjustmentFactor;
@@ -630,7 +632,7 @@
     
     // Manually need to convert viewToContents, as it will be skipped because delegatedScrolling is on iOS
     IntPoint contentPosition = protectedFrame->view()->viewToContents(protectedFrame->view()->convertFromContainingWindow(m_targetAutoscrollPositionInWindow));
-    IntSize adjustPosition = autoscrollAdjustmentFactorForScreenBoundaries(contentPosition, unobscuredContentRect);
+    IntSize adjustPosition = autoscrollAdjustmentFactorForScreenBoundaries(contentPosition, unobscuredContentRect, protectedFrame->page()->pageScaleFactor());
     return contentPosition + adjustPosition;
 }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to