Bug 820302 - Don't abort the pan-zoom animation on a viewport update if the page size didn't really change. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 21 Dec 2012 15:50:49 -0500
changeset 125929 3a086666f64512479d27215f4a1f174b97a1835b
parent 125928 95807c27bf993199c66a9206fa9e5b120001b874
child 125930 06cdd349042e501dee55995944bd28f55f75dfcf
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs820302
milestone20.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 820302 - Don't abort the pan-zoom animation on a viewport update if the page size didn't really change. r=Cwiiis
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/ImmutableViewportMetrics.java
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -297,17 +297,19 @@ public class GeckoLayerClient implements
             ImmutableViewportMetrics metrics;
             ImmutableViewportMetrics oldMetrics = getViewportMetrics();
 
             switch (type) {
             default:
             case UPDATE:
                 // Keep the old viewport size
                 metrics = messageMetrics.setViewportSize(oldMetrics.getWidth(), oldMetrics.getHeight());
-                abortPanZoomAnimation();
+                if (!oldMetrics.fuzzyEquals(metrics)) {
+                    abortPanZoomAnimation();
+                }
                 break;
             case PAGE_SIZE:
                 // adjust the page dimensions to account for differences in zoom
                 // between the rendered content (which is what Gecko tells us)
                 // and our zoom level (which may have diverged).
                 float scaleFactor = oldMetrics.zoomFactor / messageMetrics.zoomFactor;
                 metrics = oldMetrics.setPageRect(RectUtils.scale(messageMetrics.getPageRect(), scaleFactor), messageMetrics.getCssPageRect());
                 break;
--- a/mobile/android/base/gfx/ImmutableViewportMetrics.java
+++ b/mobile/android/base/gfx/ImmutableViewportMetrics.java
@@ -206,21 +206,20 @@ public class ImmutableViewportMetrics {
         return new ImmutableViewportMetrics(
             pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
             cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
             newViewport.left, newViewport.top, newViewport.right, newViewport.bottom,
             zoomFactor);
     }
 
     public boolean fuzzyEquals(ImmutableViewportMetrics other) {
-        return FloatUtils.fuzzyEquals(pageRectLeft, other.pageRectLeft)
-            && FloatUtils.fuzzyEquals(pageRectTop, other.pageRectTop)
-            && FloatUtils.fuzzyEquals(pageRectRight, other.pageRectRight)
-            && FloatUtils.fuzzyEquals(pageRectBottom, other.pageRectBottom)
-            && FloatUtils.fuzzyEquals(cssPageRectLeft, other.cssPageRectLeft)
+        // Don't bother checking the pageRectXXX values because they are a product
+        // of the cssPageRectXXX values and the zoomFactor, except with more rounding
+        // error. Checking those is both inefficient and can lead to false negatives.
+        return FloatUtils.fuzzyEquals(cssPageRectLeft, other.cssPageRectLeft)
             && FloatUtils.fuzzyEquals(cssPageRectTop, other.cssPageRectTop)
             && FloatUtils.fuzzyEquals(cssPageRectRight, other.cssPageRectRight)
             && FloatUtils.fuzzyEquals(cssPageRectBottom, other.cssPageRectBottom)
             && FloatUtils.fuzzyEquals(viewportRectLeft, other.viewportRectLeft)
             && FloatUtils.fuzzyEquals(viewportRectTop, other.viewportRectTop)
             && FloatUtils.fuzzyEquals(viewportRectRight, other.viewportRectRight)
             && FloatUtils.fuzzyEquals(viewportRectBottom, other.viewportRectBottom)
             && FloatUtils.fuzzyEquals(zoomFactor, other.zoomFactor);