Bug 960146. r=kats,wesj
This commit is contained in:
@@ -128,6 +128,8 @@ class JavaPanZoomController
|
||||
private boolean mMediumPress;
|
||||
/* Used to change the scrollY direction */
|
||||
private boolean mNegateWheelScrollY;
|
||||
/* Whether the current event has been default-prevented. */
|
||||
private boolean mDefaultPrevented;
|
||||
|
||||
// Handler to be notified when overscroll occurs
|
||||
private Overscroll mOverscroll;
|
||||
@@ -343,7 +345,9 @@ class JavaPanZoomController
|
||||
return mTouchEventHandler.handleEvent(event);
|
||||
}
|
||||
|
||||
boolean handleEvent(MotionEvent event) {
|
||||
boolean handleEvent(MotionEvent event, boolean defaultPrevented) {
|
||||
mDefaultPrevented = defaultPrevented;
|
||||
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_DOWN: return handleTouchStart(event);
|
||||
case MotionEvent.ACTION_MOVE: return handleTouchMove(event);
|
||||
@@ -401,17 +405,6 @@ class JavaPanZoomController
|
||||
}
|
||||
}
|
||||
|
||||
/** This function must be called on the UI thread. */
|
||||
public void preventedTouchFinished() {
|
||||
checkMainThread();
|
||||
if (mState == PanZoomState.WAITING_LISTENERS) {
|
||||
// if we enter here, we just finished a block of events whose default actions
|
||||
// were prevented by touch listeners. Now there are no touch points left, so
|
||||
// we need to reset our state and re-bounce because we might be in overscroll
|
||||
bounce();
|
||||
}
|
||||
}
|
||||
|
||||
/** This must be called on the UI thread. */
|
||||
@Override
|
||||
public void pageRectUpdated() {
|
||||
@@ -524,16 +517,18 @@ class JavaPanZoomController
|
||||
case FLING:
|
||||
case AUTONAV:
|
||||
case BOUNCE:
|
||||
case WAITING_LISTENERS:
|
||||
// should never happen
|
||||
Log.e(LOGTAG, "Received impossible touch end while in " + mState);
|
||||
// fall through
|
||||
case ANIMATED_ZOOM:
|
||||
case NOTHING:
|
||||
// may happen if user double-taps and drags without lifting after the
|
||||
// second tap. ignore if this happens.
|
||||
return false;
|
||||
|
||||
case WAITING_LISTENERS:
|
||||
if (!mDefaultPrevented) {
|
||||
// should never happen
|
||||
Log.e(LOGTAG, "Received impossible touch end while in " + mState);
|
||||
}
|
||||
// fall through
|
||||
case TOUCHING:
|
||||
// the switch into TOUCHING might have happened while the page was
|
||||
// snapping back after overscroll. we need to finish the snap if that
|
||||
@@ -562,16 +557,6 @@ class JavaPanZoomController
|
||||
private boolean handleTouchCancel(MotionEvent event) {
|
||||
cancelTouch();
|
||||
|
||||
if (mState == PanZoomState.WAITING_LISTENERS) {
|
||||
// we might get a cancel event from the TouchEventHandler while in the
|
||||
// WAITING_LISTENERS state if the touch listeners prevent-default the
|
||||
// block of events. at this point being in WAITING_LISTENERS is equivalent
|
||||
// to being in NOTHING with the exception of possibly being in overscroll.
|
||||
// so here we don't want to do anything right now; the overscroll will be
|
||||
// corrected in preventedTouchFinished().
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure we snap back if we're overscrolled
|
||||
bounce();
|
||||
return false;
|
||||
@@ -827,9 +812,9 @@ class JavaPanZoomController
|
||||
if (FloatUtils.fuzzyEquals(displacement.x, 0.0f) && FloatUtils.fuzzyEquals(displacement.y, 0.0f)) {
|
||||
return;
|
||||
}
|
||||
if (mSubscroller.scrollBy(displacement)) {
|
||||
if (mDefaultPrevented || mSubscroller.scrollBy(displacement)) {
|
||||
synchronized (mTarget.getLock()) {
|
||||
mTarget.onSubdocumentScrollBy(displacement.x, displacement.y);
|
||||
mTarget.scrollMarginsBy(displacement.x, displacement.y);
|
||||
}
|
||||
} else {
|
||||
synchronized (mTarget.getLock()) {
|
||||
|
||||
Reference in New Issue
Block a user