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

Unified Diff: content/renderer/android/synchronous_input_event_filter.cc

Issue 15920002: Fix WebView compositor input handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make InputEventAckState public Created 7 years, 7 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/renderer/android/synchronous_input_event_filter.cc
diff --git a/content/renderer/android/synchronous_input_event_filter.cc b/content/renderer/android/synchronous_input_event_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e889d762e8f9ea095fd1bd9421fe023d3b2d6905
--- /dev/null
+++ b/content/renderer/android/synchronous_input_event_filter.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/android/synchronous_input_event_filter.h"
+
+#include "base/callback.h"
+#include "base/logging.h"
+
+using WebKit::WebInputEvent;
+
+namespace content {
+
+SynchronousInputEventFilter::SynchronousInputEventFilter(
+ const Handler& handler)
+ : handler_(handler) {
+ DCHECK(!handler_.is_null());
+}
+
+SynchronousInputEventFilter::~SynchronousInputEventFilter() {
+}
+
+InputEventAckState SynchronousInputEventFilter::HandleInputEvent(
+ int routing_id,
+ const WebKit::WebInputEvent* input_event) {
+ // Clear the result for the (unexpected) case that callbacks to
+ // did/didNotHandleInputEvent are not made synchronously.
+ event_result_ = INPUT_EVENT_ACK_STATE_UNKNOWN;
+
+ // It is expected that handler_ initiates a synchronous callback to
+ // Did/DidNotHandleInputEvent.
+ handler_.Run(routing_id, input_event);
+ DCHECK(event_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN);
+
+ return event_result_;
+}
+
+void SynchronousInputEventFilter::DidHandleInputEvent() {
+ event_result_ = INPUT_EVENT_ACK_STATE_CONSUMED;
+}
+
+void SynchronousInputEventFilter::DidNotHandleInputEvent(bool send_to_widget) {
+ event_result_ = send_to_widget ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED
+ : INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698