Title: [233958] branches/safari-606-branch/Source/WebCore
Revision
233958
Author
[email protected]
Date
2018-07-18 19:00:09 -0700 (Wed, 18 Jul 2018)

Log Message

Cherry-pick r233883. rdar://problem/42345112

    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):

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

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (233957 => 233958)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 02:00:06 UTC (rev 233957)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-07-19 02:00:09 UTC (rev 233958)
@@ -1,5 +1,42 @@
 2018-07-18  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r233883. rdar://problem/42345112
+
+    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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233883 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-18  Babak Shafiei  <[email protected]>
+
         Cherry-pick r233879. rdar://problem/42345389
 
     Release assert in ~TimerBase is getting hit in WK1 apps which uses JSC API directly

Modified: branches/safari-606-branch/Source/WebCore/page/ios/EventHandlerIOS.mm (233957 => 233958)


--- branches/safari-606-branch/Source/WebCore/page/ios/EventHandlerIOS.mm	2018-07-19 02:00:06 UTC (rev 233957)
+++ branches/safari-606-branch/Source/WebCore/page/ios/EventHandlerIOS.mm	2018-07-19 02:00:09 UTC (rev 233958)
@@ -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