Bug 752939 - Update the mGeckoViewport when switching tabs so that we map touch events to the right point. r=Cwiiis a=blassey
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 08 May 2012 13:33:48 -0400
changeset 95667 c035ee184c13abf82b589e8f71f7a9367353229d
parent 95666 51e0f0461cbcdb2ac400f2ef9ac139abf951b488
child 95668 3f16abb633ee1055f3bacbd467509b7298313267
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis, blassey
Bug 752939 - Update the mGeckoViewport when switching tabs so that we map touch events to the right point. r=Cwiiis a=blassey
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -330,20 +330,29 @@ public class GeckoLayerClient implements
       * The compositor invokes this function just before compositing a frame where the document
       * is different from the document composited on the last frame. In these cases, the viewport
       * information we have in Java is no longer valid and needs to be replaced with the new
       * viewport information provided. setPageSize will never be invoked on the same frame that
       * this function is invoked on; and this function will always be called prior to syncViewportInfo.
     public void setFirstPaintViewport(float offsetX, float offsetY, float zoom, float pageWidth, float pageHeight, float cssPageWidth, float cssPageHeight) {
         synchronized (mLayerController) {
-            ViewportMetrics currentMetrics = new ViewportMetrics(mLayerController.getViewportMetrics());
+            final ViewportMetrics currentMetrics = new ViewportMetrics(mLayerController.getViewportMetrics());
             currentMetrics.setOrigin(new PointF(offsetX, offsetY));
             currentMetrics.setPageSize(new FloatSize(pageWidth, pageHeight), new FloatSize(cssPageWidth, cssPageHeight));
+            // Since we have switched to displaying a different document, we need to update any
+            // viewport-related state we have lying around. This includes mGeckoViewport and the
+            // viewport in mLayerController. Usually this information is updated via handleViewportMessage
+            // while we remain on the same document.
+            mLayerController.post(new Runnable() {
+                public void run() {
+                    mGeckoViewport = currentMetrics;
+                }
+            });
             // At this point, we have just switched to displaying a different document than we
             // we previously displaying. This means we need to abort any panning/zooming animations
             // that are in progress and send an updated display port request to browser.js as soon
             // as possible. We accomplish this by passing true to abortPanZoomAnimation, which
             // sends the request after aborting the animation. The display port request is actually
             // a full viewport update, which is fine because if browser.js has somehow moved to