Bug 956420 - Fix fixed margins on shorter-than-the-viewport pages. r=kats, a=lsblakk
authorChris Lord <chrislord.net@gmail.com>
Wed, 15 Jan 2014 16:58:48 +0000
changeset 167945 ca8ea758fb17a0e0b9be1e36bcd89a02217f3e17
parent 167944 d665a5c27111d593ad6969fe5bd1f9166b8b7441
child 167946 a8f56ea824c9a60c212b18d4e836d4858beff720
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, lsblakk
bugs956420
milestone27.0
Bug 956420 - Fix fixed margins on shorter-than-the-viewport pages. r=kats, a=lsblakk If a page is shorter than the screen, but taller than the screen with margins, and has a fixed position top or bottom bar, it would be offset incorrectly when scrolling downwards.
mobile/android/base/gfx/GeckoLayerClient.java
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -288,16 +288,25 @@ public class GeckoLayerClient implements
         fixedMargins.top = 0;
         fixedMargins.right = 0;
         fixedMargins.bottom = 0;
 
         // The maximum margins are determined by the scrollable area of the page.
         float maxMarginWidth = Math.max(0, metrics.getPageWidth() - metrics.getWidthWithoutMargins());
         float maxMarginHeight = Math.max(0, metrics.getPageHeight() - metrics.getHeightWithoutMargins());
 
+        // If the margins can't fully hide, they're pinned on - in which case,
+        // fixed margins should always be zero.
+        if (maxMarginWidth < metrics.marginLeft + metrics.marginRight) {
+          maxMarginWidth = 0;
+        }
+        if (maxMarginHeight < metrics.marginTop + metrics.marginBottom) {
+          maxMarginHeight = 0;
+        }
+
         PointF offset = metrics.getMarginOffset();
         RectF overscroll = metrics.getOverscroll();
         if (offset.x >= 0) {
             fixedMargins.right = Math.max(0, Math.min(offset.x - overscroll.right, maxMarginWidth));
         } else {
             fixedMargins.left = Math.max(0, Math.min(-offset.x - overscroll.left, maxMarginWidth));
         }
         if (offset.y >= 0) {