зеркало из https://github.com/mozilla/pjs.git
Bug 707571 (part 3) - Disable double-tap listener on pages with user-scalable=no [r=kats]
This commit is contained in:
Родитель
5cfc1c1da3
Коммит
53d1cc3ac9
|
@ -349,8 +349,13 @@ public class LayerController {
|
|||
mView.requestRender();
|
||||
}
|
||||
|
||||
public void setAllowZoom(boolean aValue) {
|
||||
public void setAllowZoom(final boolean aValue) {
|
||||
mAllowZoom = aValue;
|
||||
mView.post(new Runnable() {
|
||||
public void run() {
|
||||
mView.getTouchEventHandler().setDoubleTapEnabled(aValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean getAllowZoom() {
|
||||
|
|
|
@ -60,6 +60,7 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
|
|||
private final GestureDetector mGestureDetector;
|
||||
private final SimpleScaleGestureDetector mScaleGestureDetector;
|
||||
private final PanZoomController mPanZoomController;
|
||||
private final GestureDetector.OnDoubleTapListener mDoubleTapListener;
|
||||
|
||||
// the queue of events that we are holding on to while waiting for a preventDefault
|
||||
// notification
|
||||
|
@ -134,7 +135,9 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
|
|||
mListenerTimeoutProcessor = new ListenerTimeoutProcessor();
|
||||
mDispatchEvents = true;
|
||||
|
||||
mGestureDetector.setOnDoubleTapListener(controller.getDoubleTapListener());
|
||||
mDoubleTapListener = controller.getDoubleTapListener();
|
||||
setDoubleTapEnabled(true);
|
||||
|
||||
Tabs.registerOnTabsChangedListener(this);
|
||||
}
|
||||
|
||||
|
@ -213,6 +216,11 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
|
|||
mProcessingBalance--;
|
||||
}
|
||||
|
||||
/* This function MUST be called on the UI thread. */
|
||||
public void setDoubleTapEnabled(boolean aValue) {
|
||||
mGestureDetector.setOnDoubleTapListener(aValue ? mDoubleTapListener : null);
|
||||
}
|
||||
|
||||
/* This function MUST be called on the UI thread. */
|
||||
public void setWaitForTouchListeners(boolean aValue) {
|
||||
mWaitForTouchListeners = aValue;
|
||||
|
@ -238,7 +246,16 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
|
|||
*/
|
||||
private void dispatchEvent(MotionEvent event) {
|
||||
if (mGestureDetector.onTouchEvent(event)) {
|
||||
return;
|
||||
// An up/cancel event should get passed to both detectors, in
|
||||
// case it comes from a pointer the scale detector is tracking.
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
mScaleGestureDetector.onTouchEvent(event);
|
||||
if (mScaleGestureDetector.isInProgress()) {
|
||||
|
|
|
@ -1000,8 +1000,20 @@ public class PanZoomController
|
|||
sendPointToGecko("Gesture:LongPress", motionEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent motionEvent) {
|
||||
// When zooming is enabled, wait to see if there's a double-tap.
|
||||
if (mController.getAllowZoom())
|
||||
return false;
|
||||
sendPointToGecko("Gesture:SingleTap", motionEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
|
||||
// When zooming is disabled, we handle this in onSingleTapUp.
|
||||
if (!mController.getAllowZoom())
|
||||
return false;
|
||||
sendPointToGecko("Gesture:SingleTap", motionEvent);
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче