From 077a35a20b70d0a45f0ba32091f966ed861bc1c6 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 12 Mar 2012 12:03:38 -0400 Subject: [PATCH] Bug 732564 - Make sure to update the display port when we get a viewport update. r=Cwiiis --- mobile/android/base/gfx/GeckoLayerClient.java | 15 +++++++++++++-- mobile/android/base/gfx/LayerController.java | 5 ++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index 84f7edbe5bab..a8a2bb5f0ce2 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -301,7 +301,7 @@ public class GeckoLayerClient implements GeckoEventResponder, ImmutableViewportMetrics oldMetrics = mLayerController.getViewportMetrics(); newMetrics.setSize(oldMetrics.getSize()); mLayerController.setViewportMetrics(newMetrics); - mLayerController.abortPanZoomAnimation(); + mLayerController.abortPanZoomAnimation(false); } } catch (JSONException e) { Log.e(LOGTAG, "Unable to create viewport metrics in " + event + " handler", e); @@ -349,7 +349,14 @@ public class GeckoLayerClient implements GeckoEventResponder, currentMetrics.setZoomFactor(zoom); currentMetrics.setPageSize(new FloatSize(pageWidth, pageHeight)); mLayerController.setViewportMetrics(currentMetrics); - mLayerController.abortPanZoomAnimation(); + // 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 + // be out of sync with this first-paint viewport, then we force them back in sync. + mLayerController.abortPanZoomAnimation(true); } } @@ -363,6 +370,10 @@ public class GeckoLayerClient implements GeckoEventResponder, pageWidth = pageWidth * ourZoom / zoom; pageHeight = pageHeight * ourZoom /zoom; mLayerController.setPageSize(new FloatSize(pageWidth, pageHeight)); + // Here the page size of the document has changed, but the document being displayed + // is still the same. Therefore, we don't need to send anything to browser.js; any + // changes we need to make to the display port will get sent the next time we call + // adjustViewport(). } } diff --git a/mobile/android/base/gfx/LayerController.java b/mobile/android/base/gfx/LayerController.java index 30ade38b5efa..faa56d6ab7d1 100644 --- a/mobile/android/base/gfx/LayerController.java +++ b/mobile/android/base/gfx/LayerController.java @@ -342,11 +342,14 @@ public class LayerController implements Tabs.OnTabsChangedListener { } /** Aborts any pan/zoom animation that is currently in progress. */ - public void abortPanZoomAnimation() { + public void abortPanZoomAnimation(final boolean notifyLayerClient) { if (mPanZoomController != null) { mView.post(new Runnable() { public void run() { mPanZoomController.abortAnimation(); + if (notifyLayerClient) { + notifyLayerClientOfGeometryChange(); + } } }); }