Title: [182245] trunk/Source/WebKit2
Revision
182245
Author
timothy_hor...@apple.com
Date
2015-04-01 11:57:25 -0700 (Wed, 01 Apr 2015)

Log Message

Smart magnification gesture sometimes shoots to the middle of the page
https://bugs.webkit.org/show_bug.cgi?id=143296
<rdar://problem/18209280>

Reviewed by Dean Jackson.

* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture):
Constrain the target rect to the viewport, and if it had overflowed the viewport,
scroll halfway towards the gesture origin.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (182244 => 182245)


--- trunk/Source/WebKit2/ChangeLog	2015-04-01 18:42:52 UTC (rev 182244)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-01 18:57:25 UTC (rev 182245)
@@ -1,3 +1,16 @@
+2015-04-01  Timothy Horton  <timothy_hor...@apple.com>
+
+        Smart magnification gesture sometimes shoots to the middle of the page
+        https://bugs.webkit.org/show_bug.cgi?id=143296
+        <rdar://problem/18209280>
+
+        Reviewed by Dean Jackson.
+
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::didCollectGeometryForSmartMagnificationGesture):
+        Constrain the target rect to the viewport, and if it had overflowed the viewport,
+        scroll halfway towards the gesture origin.
+
 2015-03-31  Simon Fraser  <simon.fra...@apple.com>
 
         Remove scrolling tree dependency on wheel event handler counts, and use fast scrolling even when there are wheel handlers

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (182244 => 182245)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2015-04-01 18:42:52 UTC (rev 182244)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2015-04-01 18:57:25 UTC (rev 182245)
@@ -224,10 +224,20 @@
 
     double targetMagnification = visibleContentRect.width() / unscaledTargetRect.width();
 
+    FloatRect unscaledVisibleContentRect = visibleContentRect;
+    unscaledVisibleContentRect.scale(1 / currentScaleFactor);
+    FloatRect viewportConstrainedUnscaledTargetRect = unscaledTargetRect;
+    viewportConstrainedUnscaledTargetRect.intersect(unscaledVisibleContentRect);
+
+    if (unscaledTargetRect.width() > viewportConstrainedUnscaledTargetRect.width())
+        viewportConstrainedUnscaledTargetRect.setX(unscaledVisibleContentRect.x() + (origin.x() / currentScaleFactor) - viewportConstrainedUnscaledTargetRect.width() / 2);
+    if (unscaledTargetRect.height() > viewportConstrainedUnscaledTargetRect.height())
+        viewportConstrainedUnscaledTargetRect.setY(unscaledVisibleContentRect.y() + (origin.y() / currentScaleFactor) - viewportConstrainedUnscaledTargetRect.height() / 2);
+
     // For replaced elements like images, we want to fit the whole element
     // in the view, so scale it down enough to make both dimensions fit if possible.
     if (isReplacedElement)
-        targetMagnification = std::min(targetMagnification, static_cast<double>(visibleContentRect.height() / unscaledTargetRect.height()));
+        targetMagnification = std::min(targetMagnification, static_cast<double>(visibleContentRect.height() / viewportConstrainedUnscaledTargetRect.height()));
 
     targetMagnification = std::min(std::max(targetMagnification, minMagnification), maxMagnification);
 
@@ -241,7 +251,7 @@
             targetMagnification = 1;
     }
 
-    FloatRect targetRect(unscaledTargetRect);
+    FloatRect targetRect(viewportConstrainedUnscaledTargetRect);
     targetRect.scale(targetMagnification);
     FloatPoint targetOrigin(visibleContentRect.center());
     targetOrigin.moveBy(-targetRect.center());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to