Bug 856039 - Guard against viewport size changes getting clobbered by animations. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 01 Apr 2013 10:17:03 -0400
changeset 127255 be42980135f2f72e7e11a1252e2c9e4ac8fa5eb8
parent 127254 42912b8b82d4c868a38c6fbd96bbb097192202fc
child 127256 dccd236555132a061ac9ce36e51df232dfbf5ae1
push id1651
push userjandemooij@gmail.com
push dateMon, 01 Apr 2013 19:51:43 +0000
reviewersCwiiis
bugs856039
milestone22.0a1
Bug 856039 - Guard against viewport size changes getting clobbered by animations. 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
@@ -804,16 +804,22 @@ public class GeckoLayerClient implements
      * You must hold the monitor while calling this.
      */
     @Override
     public void setViewportMetrics(ImmutableViewportMetrics metrics) {
         setViewportMetrics(metrics, true, true);
     }
 
     private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko, boolean keepFixedMargins) {
+        // This class owns the viewport size; don't let other pieces of code clobber our notion
+        // of the viewport size. The only place the viewport size should ever be updated is in
+        // the GeckoLayerClient.setViewportSize function, and there mViewportMetrics is updated
+        // directly.
+        metrics = metrics.setViewportSize(mViewportMetrics.getWidth(), mViewportMetrics.getHeight());
+
         if (keepFixedMargins) {
             mViewportMetrics = metrics.setFixedLayerMarginsFrom(mViewportMetrics);
         } else {
             mViewportMetrics = metrics;
         }
         mView.requestRender();
         if (notifyGecko && mGeckoIsReady) {
             geometryChanged();
--- a/mobile/android/base/gfx/ImmutableViewportMetrics.java
+++ b/mobile/android/base/gfx/ImmutableViewportMetrics.java
@@ -160,16 +160,20 @@ public class ImmutableViewportMetrics {
             FloatUtils.interpolate(fixedLayerMarginLeft, to.fixedLayerMarginLeft, t),
             FloatUtils.interpolate(fixedLayerMarginTop, to.fixedLayerMarginTop, t),
             FloatUtils.interpolate(fixedLayerMarginRight, to.fixedLayerMarginRight, t),
             FloatUtils.interpolate(fixedLayerMarginBottom, to.fixedLayerMarginBottom, t),
             FloatUtils.interpolate(zoomFactor, to.zoomFactor, t));
     }
 
     public ImmutableViewportMetrics setViewportSize(float width, float height) {
+        if (FloatUtils.fuzzyEquals(width, getWidth()) && FloatUtils.fuzzyEquals(height, getHeight())) {
+            return this;
+        }
+
         return new ImmutableViewportMetrics(
             pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
             cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
             viewportRectLeft, viewportRectTop, viewportRectLeft + width, viewportRectTop + height,
             fixedLayerMarginLeft, fixedLayerMarginTop, fixedLayerMarginRight, fixedLayerMarginBottom,
             zoomFactor);
     }