Bug 752939 - Update the mGeckoViewport when switching tabs so that we map touch events to the right point. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 08 May 2012 13:33:48 -0400
changeset 95778 e6e6f5bc3561aa02c8071ba5a86f84ac5c211079
parent 95777 ba7cf6fd10aed5d634905f4607e0d916be10c0e2
child 95779 f2f8b1127a54a88ea8c96192f17dce12f8642283
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Bug 752939 - Update the mGeckoViewport when switching tabs so that we map touch events to the right point. r=Cwiiis
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -331,20 +331,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