summaryrefslogtreecommitdiffstats
path: root/content/public
diff options
context:
space:
mode:
authorkkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 01:35:59 +0000
committerkkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 01:35:59 +0000
commitd146d7d590f19966ff37b111c612f5e065615851 (patch)
tree6a7046da09d5b5b80516ebbd4144665ec9abda20 /content/public
parentea16eba795aadff05a7a9beaf4c1704fc55dcb05 (diff)
downloadchromium_src-d146d7d590f19966ff37b111c612f5e065615851.zip
chromium_src-d146d7d590f19966ff37b111c612f5e065615851.tar.gz
chromium_src-d146d7d590f19966ff37b111c612f5e065615851.tar.bz2
[Android] Add a flag to ignore the subsequent touch events.
When we show the context popup menu by long-press, the subsequent touch events were processed by ContentViewGestureHandler even after the popup menu is shown. For example, showing the popup menu by long-press then moving up and down made the content view scroll. Also, it caused a crash on executing "Search by Image" on Android. This CL adds a flag so that the subsequent touch events can be ignored on-request. BUG=274832 Review URL: https://chromiumcodereview.appspot.com/22891008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public')
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentView.java5
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java24
2 files changed, 29 insertions, 0 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentView.java b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
index a04dcd9..b047909 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentView.java
@@ -338,6 +338,11 @@ public class ContentView extends FrameLayout
mContentViewCore.getContentViewGestureHandler().setIgnoreSingleTap(value);
}
+ /** @see ContentViewGestureHandler#setIgnoreRemainingTouchEvents */
+ public void setIgnoreRemainingTouchEvents() {
+ mContentViewCore.getContentViewGestureHandler().setIgnoreRemainingTouchEvents();
+ }
+
/**
* Modify the ContentView magnification level. The effect of calling this
* method is exactly as after "pinch zoom".
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java
index 37fd170..e82f01d 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewGestureHandler.java
@@ -81,6 +81,10 @@ class ContentViewGestureHandler implements LongPressDelegate {
// we will first show the press state, then trigger the click.
private boolean mShowPressIsCalled;
+ // This flag is used for ignoring the remaining touch events, i.e., All the events until the
+ // next ACTION_DOWN. This is automatically set to false on the next ACTION_DOWN.
+ private boolean mIgnoreRemainingTouchEvents;
+
// TODO(klobag): this is to avoid a bug in GestureDetector. With multi-touch,
// mAlwaysInTapRegion is not reset. So when the last finger is up, onSingleTapUp()
// will be mistakenly fired.
@@ -767,12 +771,32 @@ class ContentViewGestureHandler implements LongPressDelegate {
}
/**
+ * Cancel the current touch event sequence by sending ACTION_CANCEL and ignore all the
+ * subsequent events until the next ACTION_DOWN.
+ *
+ * One example usecase is stop processing the touch events when showing context popup menu.
+ */
+ public void setIgnoreRemainingTouchEvents() {
+ onTouchEvent(obtainActionCancelMotionEvent());
+ mIgnoreRemainingTouchEvents = true;
+ }
+
+ /**
* Handle the incoming MotionEvent.
* @return Whether the event was handled.
*/
boolean onTouchEvent(MotionEvent event) {
try {
TraceEvent.begin("onTouchEvent");
+
+ if (mIgnoreRemainingTouchEvents) {
+ if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ mIgnoreRemainingTouchEvents = false;
+ } else {
+ return false;
+ }
+ }
+
mLongPressDetector.cancelLongPressIfNeeded(event);
mSnapScrollController.setSnapScrollingMode(event);
// Notify native that scrolling has stopped whenever a down action is processed prior to