Bug 704690 - Abort flings on gecko viewport update [r=Cwiiis]

If the Java code is in the middle of a fling when Gecko sends
a viewport update, abort the fling, cancel the velocity, and
re-fling. The re-fling is purely to get the page snapped to an
edge if needed.
This commit is contained in:
Kartikaya Gupta 2011-12-01 09:37:37 -05:00
parent e6126c1cc3
commit c844bf872f
2 changed files with 22 additions and 7 deletions

View File

@ -163,14 +163,14 @@ public class LayerController {
setForceRedraw();
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(false);
mView.requestRender();
}
public void scrollTo(PointF point) {
mViewportMetrics.setOrigin(point);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -181,7 +181,7 @@ public class LayerController {
mViewportMetrics.setOrigin(origin);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -189,7 +189,7 @@ public class LayerController {
public void setViewport(RectF viewport) {
mViewportMetrics.setViewport(viewport);
notifyLayerClientOfGeometryChange();
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(false);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}
@ -202,7 +202,7 @@ public class LayerController {
// Page size is owned by the LayerClient, so no need to notify it of
// this change.
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(false);
mView.requestRender();
}
@ -211,7 +211,7 @@ public class LayerController {
// We assume this was called by the LayerClient (as it includes page
// size), so no need to notify it of this change.
mPanZoomController.geometryChanged();
mPanZoomController.geometryChanged(true);
GeckoApp.mAppContext.repositionPluginViews(false);
mView.requestRender();
}

View File

@ -130,8 +130,23 @@ public class PanZoomController
}
}
public void geometryChanged() {
public void geometryChanged(boolean aAbortFling) {
populatePositionAndLength();
if (aAbortFling) {
// this happens when gecko changes the viewport on us. if that's the case, abort
// any fling that's in progress and re-fling so that the page snaps to edges. for
// other cases (where the user's finger(s) are down) don't do anything special.
switch (mState) {
case FLING:
mX.velocity = mY.velocity = 0.0f;
mState = PanZoomState.NOTHING;
// fall through
case NOTHING:
fling();
break;
}
}
}
/*