Bug 1201076 - Don't clobber the page rect update if one comes in while in the middle of a bounce animation. r=snorp
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 28 Sep 2015 11:06:37 -0400
changeset 264708 396173a9720e87cf94ae8b23b075619a0440f1ed
parent 264707 8a6ece1de77aec317ed58430500c61e843c1f585
child 264709 642b7adaf3da296a76beb8920ef0f0487cbe53e3
push id15394
push userkgupta@mozilla.com
push dateMon, 28 Sep 2015 15:07:07 +0000
treeherderfx-team@396173a9720e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1201076
milestone44.0a1
Bug 1201076 - Don't clobber the page rect update if one comes in while in the middle of a bounce animation. r=snorp
mobile/android/base/gfx/ImmutableViewportMetrics.java
mobile/android/base/gfx/JavaPanZoomController.java
--- a/mobile/android/base/gfx/ImmutableViewportMetrics.java
+++ b/mobile/android/base/gfx/ImmutableViewportMetrics.java
@@ -214,16 +214,27 @@ public class ImmutableViewportMetrics {
     public ImmutableViewportMetrics setPageRect(RectF pageRect, RectF cssPageRect) {
         return new ImmutableViewportMetrics(
             pageRect.left, pageRect.top, pageRect.right, pageRect.bottom,
             cssPageRect.left, cssPageRect.top, cssPageRect.right, cssPageRect.bottom,
             viewportRectLeft, viewportRectTop, viewportRectWidth, viewportRectHeight,
             zoomFactor, isRTL);
     }
 
+    public ImmutableViewportMetrics setPageRectFrom(ImmutableViewportMetrics aMetrics) {
+        if (aMetrics.cssPageRectLeft == cssPageRectLeft &&
+            aMetrics.cssPageRectTop == cssPageRectTop &&
+            aMetrics.cssPageRectRight == cssPageRectRight &&
+            aMetrics.cssPageRectBottom == cssPageRectBottom) {
+            return this;
+        }
+        RectF css = aMetrics.getCssPageRect();
+        return setPageRect(RectUtils.scale(css, zoomFactor), css);
+    }
+
     public ImmutableViewportMetrics setIsRTL(boolean aIsRTL) {
         if (isRTL == aIsRTL) {
             return this;
         }
 
         return new ImmutableViewportMetrics(
             pageRectLeft, pageRectTop, pageRectRight, pageRectBottom,
             cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom,
--- a/mobile/android/base/gfx/JavaPanZoomController.java
+++ b/mobile/android/base/gfx/JavaPanZoomController.java
@@ -945,24 +945,24 @@ class JavaPanZoomController
             setState(PanZoomState.NOTHING);
         }
 
         /* Performs one frame of a bounce animation. */
         private void advanceBounce() {
             synchronized (mTarget.getLock()) {
                 float t = easeOut((float)mBounceDuration / BOUNCE_ANIMATION_DURATION);
                 ImmutableViewportMetrics newMetrics = mBounceStartMetrics.interpolate(mBounceEndMetrics, t);
-                mTarget.setViewportMetrics(newMetrics);
+                mTarget.setViewportMetrics(newMetrics.setPageRectFrom(getMetrics()));
             }
         }
 
         /* Concludes a bounce animation and snaps the viewport into place. */
         private void finishBounce() {
             synchronized (mTarget.getLock()) {
-                mTarget.setViewportMetrics(mBounceEndMetrics);
+                mTarget.setViewportMetrics(mBounceEndMetrics.setPageRectFrom(getMetrics()));
             }
         }
     }
 
     // The callback that performs the fling animation.
     private class FlingRenderTask extends PanZoomRenderTask {
 
         public FlingRenderTask() {