Bug 704738 - Resize page content on device rotation. r=Cwiiis a=java-only

Some cleanup: ensure we abort and re-bounce the viewport
if the device is rotated during a double-tap zoom. Also
rename variables to be more appropriate
This commit is contained in:
Kartikaya Gupta 2011-12-12 11:22:34 -05:00
Родитель 87f29234cb
Коммит 5c1b4941f0
2 изменённых файлов: 13 добавлений и 9 удалений

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

@ -258,9 +258,9 @@ public class LayerController {
}
/** Informs the pan/zoom controller that the viewport metrics changed. */
public void notifyPanZoomControllerOfGeometryChange(boolean abortFling) {
public void notifyPanZoomControllerOfGeometryChange(boolean abortAnimation) {
if (mPanZoomController != null)
mPanZoomController.geometryChanged(abortFling);
mPanZoomController.geometryChanged(abortAnimation);
}
/**

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

@ -136,8 +136,7 @@ public class PanZoomController
* similar to TOUCHING but after starting a pan */
PANNING_HOLD_LOCKED, /* like PANNING_HOLD, but axis lock still in effect */
PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */
ANIMATED_ZOOM, /* animated zoom to a new rect */
BOUNCING, /* bouncing back */
ANIMATED_ZOOM /* animated zoom to a new rect */
}
private PanZoomState mState;
@ -241,16 +240,21 @@ public class PanZoomController
}
}
public void geometryChanged(boolean aAbortFling) {
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.
public void geometryChanged(boolean abortAnimation) {
if (abortAnimation) {
// this happens when gecko changes the viewport on us or if the device is rotated.
// if that's the case, abort any animation in progress and re-zoom 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 ANIMATED_ZOOM:
// the zoom that's in progress likely makes no sense any more (such as if
// the screen orientation changed) so abort it and start a new one to
// ensure the viewport doesn't contain out-of-bounds areas
case NOTHING:
bounce();
break;