diff options
author | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 23:19:28 +0000 |
---|---|---|
committer | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 23:19:28 +0000 |
commit | a1a25c571a24b9bc9103378e0eee2c6d51d2dae3 (patch) | |
tree | 27838e909382cd84444429f95f81bfe56f1b6298 /content | |
parent | 25489c008bfa5935e8e1e4a9093d47a0489d36ae (diff) | |
download | chromium_src-a1a25c571a24b9bc9103378e0eee2c6d51d2dae3.zip chromium_src-a1a25c571a24b9bc9103378e0eee2c6d51d2dae3.tar.gz chromium_src-a1a25c571a24b9bc9103378e0eee2c6d51d2dae3.tar.bz2 |
[Android] Eliminate JNI hop for critical path gestures
Previously, all gestures would pass through Java as they were filtered prior
to being forwarded to the renderer. However, only a small subset of gestures
really need to be seen during this filtering phase. The rest can be accommodated
simply by inspecting the corresponding gesture ack. This saves ~20us per
GestureScrollUpdate and GesturePinchUpdate.
BUG=341613
Review URL: https://codereview.chromium.org/164643002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251181 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/android/content_view_core_impl.cc | 18 | ||||
-rw-r--r-- | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java | 51 |
2 files changed, 31 insertions, 38 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index e981865..20eb17c 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -619,13 +619,19 @@ void ContentViewCoreImpl::OnGestureEventAck(const blink::WebGestureEvent& event, case WebInputEvent::GesturePinchEnd: Java_ContentViewCore_onPinchEndEventAck(env, j_obj.obj()); break; + case WebInputEvent::GestureDoubleTap: + Java_ContentViewCore_onDoubleTapEventAck(env, j_obj.obj()); + break; default: break; } } bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { - if (!WebInputEvent::isGestureEventType(event.type)) + if (event.type != WebInputEvent::GestureTap && + event.type != WebInputEvent::GestureDoubleTap && + event.type != WebInputEvent::GestureLongTap && + event.type != WebInputEvent::GestureLongPress) return false; JNIEnv* env = AttachCurrentThread(); @@ -636,11 +642,11 @@ bool ContentViewCoreImpl::FilterInputEvent(const blink::WebInputEvent& event) { const blink::WebGestureEvent& gesture = static_cast<const blink::WebGestureEvent&>(event); int gesture_type = ToContentViewGestureHandlerType(event.type); - return Java_ContentViewCore_filterGestureEvent(env, - j_obj.obj(), - gesture_type, - gesture.x, - gesture.y); + return Java_ContentViewCore_filterTapOrPressEvent(env, + j_obj.obj(), + gesture_type, + gesture.x, + gesture.y); } bool ContentViewCoreImpl::HasFocus() { 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 11cfc9a..3ee52e8 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, |