Bug 956420 - Fix fixed margins on shorter-than-the-viewport pages. r=kats
authorChris Lord <chrislord.net@gmail.com>
Wed, 15 Jan 2014 16:58:48 +0000
changeset 163686 b1ea2300010cb8ff804545df03df0e7c37304861
parent 163685 cbfac99adeef4acd03ead0ec132b6898b2622ba8
child 163687 c1f6fbc397bd67d63ea79df232f31cbe3640f590
push id38541
push userchrislord.net@gmail.com
push dateThu, 16 Jan 2014 12:01:38 +0000
treeherdermozilla-inbound@b1ea2300010c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs956420
milestone29.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 956420 - Fix fixed margins on shorter-than-the-viewport pages. r=kats 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
@@ -287,16 +287,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) {