Bug 1120244 - Prevent viewport bounds from going outside the page bounds. r=snorp
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 12 Jan 2015 11:11:22 -0500
changeset 223291 a6183ada03994b5694a3684c212b3fe6021d5e40
parent 223290 a13aa1af5d7551ac734f7d9ecc527059ab7e953f
child 223292 81877ee96549e0f4378b4d5643925825c9de66c8
push id28086
push userryanvm@gmail.com
push dateMon, 12 Jan 2015 20:15:15 +0000
treeherdermozilla-central@182904efdc21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1120244
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1120244 - Prevent viewport bounds from going outside the page bounds. r=snorp In Fennec, we display the dynamic toolbar once we have scrolled to the bottom of the page. In this configuration, animating in the toolbar should increase the top margin in the ImmutableViewportMetrics without affecting the viewportRect[Top|Bottom], because otherwise the scroll position would exceed the maximum allowed scroll position and the bottom of the viewport would go past the end of the page. This patch corrects the calculation used to enforce this.
mobile/android/base/gfx/ImmutableViewportMetrics.java
--- a/mobile/android/base/gfx/ImmutableViewportMetrics.java
+++ b/mobile/android/base/gfx/ImmutableViewportMetrics.java
@@ -228,22 +228,22 @@ public class ImmutableViewportMetrics {
 
     public ImmutableViewportMetrics offsetViewportBy(float dx, float dy) {
         return setViewportOrigin(viewportRectLeft + dx, viewportRectTop + dy);
     }
 
     public ImmutableViewportMetrics offsetViewportByAndClamp(float dx, float dy) {
         if (isRTL) {
             return setViewportOrigin(
-                Math.min(pageRectRight - getWidthWithoutMargins(), Math.max(viewportRectLeft + dx, pageRectLeft)),
-                Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeightWithoutMargins())));
+                Math.min(pageRectRight - getWidth(), Math.max(viewportRectLeft + dx, pageRectLeft)),
+                Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeight())));
         }
         return setViewportOrigin(
-            Math.max(pageRectLeft, Math.min(viewportRectLeft + dx, pageRectRight - getWidthWithoutMargins())),
-            Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeightWithoutMargins())));
+            Math.max(pageRectLeft, Math.min(viewportRectLeft + dx, pageRectRight - getWidth())),
+            Math.max(pageRectTop, Math.min(viewportRectTop + dy, pageRectBottom - getHeight())));
     }
 
     public ImmutableViewportMetrics setPageRect(RectF pageRect, RectF cssPageRect) {
         return new ImmutableViewportMetrics(
             pageRect.left, pageRect.top, pageRect.right, pageRect.bottom,
             cssPageRect.left, cssPageRect.top, cssPageRect.right, cssPageRect.bottom,
             viewportRectLeft, viewportRectTop, viewportRectRight, viewportRectBottom,
             marginLeft, marginTop, marginRight, marginBottom,