Bug 854289 - Fix offsetting of viewport with dynamic toolbar. r=kats

Make sure to offset the viewport *after* setting the Gecko viewport on
setFirstPaintViewport callbacks, so that we don't store an incorrect viewport
origin and end up offsetting events incorrectly.

Similarly, on page size updates, the Java-side viewport metrics are used to
update the Gecko metrics, so make sure they're clamped so that they aren't
incorrect during overscroll.
This commit is contained in:
Chris Lord 2013-04-01 10:33:19 +01:00
Родитель 5aa31382f8
Коммит 9b2ec9f6dc
1 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -383,7 +383,9 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
break; break;
} }
final ImmutableViewportMetrics geckoMetrics = newMetrics; // Update the Gecko-side viewport metrics. Make sure to do this
// before modifying the metrics below.
final ImmutableViewportMetrics geckoMetrics = newMetrics.clamp();
post(new Runnable() { post(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -591,12 +593,6 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
synchronized (this) { synchronized (this) {
ImmutableViewportMetrics currentMetrics = getViewportMetrics(); ImmutableViewportMetrics currentMetrics = getViewportMetrics();
// If we're meant to be scrolled to the top, take into account any
// margin set on the pan zoom controller.
if (FloatUtils.fuzzyEquals(offsetY, pageTop)) {
offsetY = -currentMetrics.fixedLayerMarginTop;
}
final ImmutableViewportMetrics newMetrics = currentMetrics final ImmutableViewportMetrics newMetrics = currentMetrics
.setViewportOrigin(offsetX, offsetY) .setViewportOrigin(offsetX, offsetY)
.setZoomFactor(zoom) .setZoomFactor(zoom)
@ -612,7 +608,16 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
mGeckoViewport = newMetrics; mGeckoViewport = newMetrics;
} }
}); });
setViewportMetrics(newMetrics);
// If we're meant to be scrolled to the top, take into account any
// margin set on the pan zoom controller.
if (FloatUtils.fuzzyEquals(offsetY, pageTop)
&& newMetrics.fixedLayerMarginTop > 0) {
setViewportMetrics(newMetrics.setViewportOrigin(offsetX,
-newMetrics.fixedLayerMarginTop));
} else {
setViewportMetrics(newMetrics);
}
Tab tab = Tabs.getInstance().getSelectedTab(); Tab tab = Tabs.getInstance().getSelectedTab();
mView.setBackgroundColor(tab.getBackgroundColor()); mView.setBackgroundColor(tab.getBackgroundColor());