From f48835a4210ea1bb1ed6973dc64a2502f22b730a Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 12 Jan 2015 11:11:22 -0500 Subject: [PATCH] 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/gfx/ImmutableViewportMetrics.java b/mobile/android/base/gfx/ImmutableViewportMetrics.java index 817190c6c45..59d13250417 100644 --- a/mobile/android/base/gfx/ImmutableViewportMetrics.java +++ b/mobile/android/base/gfx/ImmutableViewportMetrics.java @@ -233,12 +233,12 @@ public class ImmutableViewportMetrics { 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) {