Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 164643002: [Android] Eliminate JNI hop for critical path gestures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 11cfc9af8ca7fa069d01970574d7bc9c87a2492c..3ee52e862976573aaa5484ef6d37bc001c0dde56 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -1232,6 +1232,7 @@ public class ContentViewCore
@SuppressWarnings("unused")
@CalledByNative
private void onFlingStartEventConsumed(int vx, int vy) {
+ temporarilyHideTextHandles();
for (mGestureStateListenersIterator.rewind();
mGestureStateListenersIterator.hasNext();) {
mGestureStateListenersIterator.next().onFlingStartGesture(
@@ -1257,12 +1258,15 @@ public class ContentViewCore
@SuppressWarnings("unused")
@CalledByNative
private void onScrollBeginEventAck() {
+ temporarilyHideTextHandles();
+ mZoomControlsDelegate.invokeZoomPicker();
updateGestureStateListener(GestureEventType.SCROLL_START);
}
@SuppressWarnings("unused")
@CalledByNative
private void onScrollUpdateGestureConsumed() {
+ mZoomControlsDelegate.invokeZoomPicker();
for (mGestureStateListenersIterator.rewind();
mGestureStateListenersIterator.hasNext();) {
mGestureStateListenersIterator.next().onScrollUpdateGestureConsumed();
@@ -1278,6 +1282,7 @@ public class ContentViewCore
@SuppressWarnings("unused")
@CalledByNative
private void onPinchBeginEventAck() {
+ temporarilyHideTextHandles();
updateGestureStateListener(GestureEventType.PINCH_BEGIN);
}
@@ -1287,21 +1292,23 @@ public class ContentViewCore
updateGestureStateListener(GestureEventType.PINCH_END);
}
+ @SuppressWarnings("unused")
+ @CalledByNative
+ private void onDoubleTapEventAck() {
+ temporarilyHideTextHandles();
+ }
+
/**
- * Called just prior to a gesture being forwarded to the renderer. All listening
- * for the sending of (synthetic or touch-derived) gestures should occur here.
+ * Called just prior to a tap or press gesture being forwarded to the renderer.
*/
@SuppressWarnings("unused")
@CalledByNative
- private boolean filterGestureEvent(int type, int x, int y) {
- if (offerGestureToEmbedder(type)) return true;
- updateTextHandlesForGesture(type);
+ private boolean filterTapOrPressEvent(int type, int x, int y) {
+ if (type == GestureEventType.LONG_PRESS && offerLongPressToEmbedder()) {
+ return true;
+ }
updateForTapOrPress(type, x, y);
updateForDoubleTapUMA(type);
- // TODO(jdduke): Determine if this should be called while a pinch is active.
- if (type == GestureEventType.SCROLL_BY) {
- mZoomControlsDelegate.invokeZoomPicker();
- }
return false;
}
@@ -2393,20 +2400,6 @@ public class ContentViewCore
return mInsertionHandleController != null && mInsertionHandleController.isShowing();
}
- private void updateTextHandlesForGesture(int type) {
- switch(type) {
- case GestureEventType.DOUBLE_TAP:
- case GestureEventType.SCROLL_START:
- case GestureEventType.FLING_START:
- case GestureEventType.PINCH_BEGIN:
- temporarilyHideTextHandles();
- break;
-
- default:
- break;
- }
- }
-
// Makes the insertion/selection handles invisible. They will fade back in shortly after the
// last call to scheduleTextHandleFadeIn (or temporarilyHideTextHandles).
private void temporarilyHideTextHandles() {
@@ -3265,18 +3258,12 @@ public class ContentViewCore
}
/**
- * Offer a subset of gesture events to the embedding View,
- * primarily for WebView compatibility.
- *
- * @param type The type of the event.
+ * Offer a long press gesture to the embedding View, primarily for WebView compatibility.
*
* @return true if the embedder handled the event.
*/
- private boolean offerGestureToEmbedder(int type) {
- if (type == GestureEventType.LONG_PRESS) {
- return mContainerView.performLongClick();
- }
- return false;
+ private boolean offerLongPressToEmbedder() {
+ return mContainerView.performLongClick();
}
private native long nativeInit(long webContentsPtr,
« no previous file with comments | « content/browser/android/content_view_core_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698