Chromium Code Reviews| Index: content/browser/android/content_view_core_impl.cc |
| diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc |
| index 8c322d27848ba8ccc29718ba75e1ffce88089c2e..c1b7b3ee14fc3f672076b0a4bba213487b4872f7 100644 |
| --- a/content/browser/android/content_view_core_impl.cc |
| +++ b/content/browser/android/content_view_core_impl.cc |
| @@ -1028,11 +1028,7 @@ void ContentViewCoreImpl::CancelActiveTouchSequenceIfNecessary() { |
| scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); |
| DCHECK(cancel_event); |
| - if (!gesture_provider_.OnTouchEvent(*cancel_event)) |
| - return; |
| - |
| - rwhv->SendTouchEvent( |
| - CreateWebTouchEventFromMotionEvent(*cancel_event, 1.f / dpi_scale())); |
| + OnMotionEvent(*cancel_event); |
| } |
| jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
| @@ -1052,6 +1048,7 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
| jfloat touch_major_0, |
| jfloat touch_major_1) { |
| RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| + // Avoid synthesizing a touch event if it cannot be forwarded. |
| if (!rwhv) |
| return false; |
| @@ -1071,11 +1068,7 @@ jboolean ContentViewCoreImpl::OnTouchEvent(JNIEnv* env, |
| touch_major_0, |
| touch_major_1); |
| - if (!gesture_provider_.OnTouchEvent(event)) |
| - return false; |
| - |
| - rwhv->SendTouchEvent(WebTouchEventBuilder::Build(event, 1.f / dpi_scale())); |
| - return true; |
| + return OnMotionEvent(event); |
| } |
| float ContentViewCoreImpl::GetDpiScale() const { |
| @@ -1131,6 +1124,28 @@ WebGestureEvent ContentViewCoreImpl::MakeGestureEvent( |
| type, time_ms / 1000.0, x / dpi_scale(), y / dpi_scale()); |
| } |
| +bool ContentViewCoreImpl::OnMotionEvent(const ui::MotionEvent& event) { |
| + RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
| + if (!rwhv) |
| + return false; |
| + |
| + if (!gesture_provider_.OnTouchEvent(event)) |
| + return false; |
| + |
| + // If there are no touch handlers and the touch queue is empty, touch |
| + // forwarding can be short-circuited completely. |
|
tdresser
2014/03/28 17:55:27
It feels like this comment is breaking encapsulati
jdduke (slow)
2014/03/28 18:33:55
Yes, though in my mind those details are vital to
tdresser
2014/03/28 18:40:05
SGTM.
|
| + RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| + rwhv->GetRenderWidgetHost()); |
| + if (!host->ShouldForwardTouchEvent()) { |
| + ConfirmTouchEvent(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS); |
| + return true; |
| + } |
| + |
| + rwhv->SendTouchEvent( |
| + CreateWebTouchEventFromMotionEvent(event, 1.f / dpi_scale())); |
| + return true; |
| +} |
| + |
| void ContentViewCoreImpl::SendGestureEvent( |
| const blink::WebGestureEvent& event) { |
| RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |