Bug 856039 - Guard against viewport size changes getting clobbered by animations. r=Cwiiis
--- 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);
}