Bug 850889 - Fix animation conflict with overscroll and dynamic toolbar. r=kats

This fixes the conflicting animations when the dynamic toolbar is hiding/showing
and overscroll is snapping back simultaneously. This is by not clamping the
entire viewport on margin-setting, and by making sure that only calling
setFixedLayerMargins changes the fixed layer margins.
This commit is contained in:
Chris Lord 2013-03-18 15:43:02 +00:00
parent 67407d53cb
commit 0f24652dac

View File

@ -321,8 +321,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
default:
case UPDATE:
// Keep the old viewport size
metrics = messageMetrics.setViewportSize(oldMetrics.getWidth(), oldMetrics.getHeight())
.setFixedLayerMarginsFrom(oldMetrics);
metrics = messageMetrics.setViewportSize(oldMetrics.getWidth(), oldMetrics.getHeight());
if (!oldMetrics.fuzzyEquals(metrics)) {
abortPanZoomAnimation();
}
@ -343,7 +342,7 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
mGeckoViewport = newMetrics;
}
});
setViewportMetrics(newMetrics, type == ViewportMessageType.UPDATE);
setViewportMetrics(newMetrics, type == ViewportMessageType.UPDATE, true);
mDisplayPort = DisplayPortCalculator.calculate(getViewportMetrics(), null);
}
return mDisplayPort;
@ -382,11 +381,42 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
ImmutableViewportMetrics newMetrics = oldMetrics.setFixedLayerMargins(left, top, right, bottom);
if (mClampOnMarginChange) {
newMetrics = newMetrics.clampWithMargins();
// Only clamp on decreased margins
boolean changed = false;
float viewportRectLeft = oldMetrics.viewportRectLeft;
float viewportRectTop = oldMetrics.viewportRectTop;
// Clamp the x-axis if the page was over-scrolled into the margin
// area.
if (oldMetrics.fixedLayerMarginLeft > left &&
viewportRectLeft < oldMetrics.pageRectLeft - left) {
viewportRectLeft = oldMetrics.pageRectLeft - left;
changed = true;
} else if (oldMetrics.fixedLayerMarginRight > right &&
oldMetrics.viewportRectRight > oldMetrics.pageRectRight + right) {
viewportRectLeft = oldMetrics.pageRectRight + right - oldMetrics.getWidth();
changed = true;
}
// Do the same for the y-axis.
if (oldMetrics.fixedLayerMarginTop > top &&
viewportRectTop < oldMetrics.pageRectTop - top) {
viewportRectTop = oldMetrics.pageRectTop - top;
changed = true;
} else if (oldMetrics.fixedLayerMarginBottom > bottom &&
oldMetrics.viewportRectBottom > oldMetrics.pageRectBottom + bottom) {
viewportRectTop = oldMetrics.pageRectBottom + bottom - oldMetrics.getHeight();
changed = true;
}
// Set the new metrics, if they're different.
if (changed) {
newMetrics = newMetrics.setViewportOrigin(viewportRectLeft, viewportRectTop);
}
}
mForceRedraw = true;
setViewportMetrics(newMetrics, true);
setViewportMetrics(newMetrics, true, false);
}
public void setClampOnFixedLayerMarginsChange(boolean aClamp) {
@ -722,11 +752,15 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
*/
@Override
public void setViewportMetrics(ImmutableViewportMetrics metrics) {
setViewportMetrics(metrics, true);
setViewportMetrics(metrics, true, true);
}
private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko) {
private void setViewportMetrics(ImmutableViewportMetrics metrics, boolean notifyGecko, boolean keepFixedMargins) {
if (keepFixedMargins) {
mViewportMetrics = metrics.setFixedLayerMarginsFrom(mViewportMetrics);
} else {
mViewportMetrics = metrics;
}
mView.requestRender();
if (notifyGecko && mGeckoIsReady) {
geometryChanged();