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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 217253002: [Android] Short-circuit touch forwarding when no touch handlers exist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 6 years, 9 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
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..8606d5cd47712beb0675f21298f964e653eb0415 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,26 @@ 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;
+
+ 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();
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/input/input_router_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698