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

Unified Diff: content/renderer/input/passive_event_queue.cc

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Set dependency correctly Created 4 years, 11 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/input/passive_event_queue.cc
diff --git a/content/renderer/input/passive_event_queue.cc b/content/renderer/input/passive_event_queue.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6120e4b05e3ee76f884333826ba4bca4fdfefb89
--- /dev/null
+++ b/content/renderer/input/passive_event_queue.cc
@@ -0,0 +1,70 @@
+// Copyright 2016 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/input/passive_event_queue.h"
+
+namespace content {
+
+PassiveEventQueue::PassiveEventQueue(int routing_id,
+ PassiveEventQueueClient* client)
+ : routing_id_(routing_id), client_(client) {}
+
+PassiveEventQueue::~PassiveEventQueue() {}
+
+void PassiveEventQueue::HandleNonBlockingEvent(
+ const blink::WebInputEvent* event,
+ const ui::LatencyInfo& latency) {
+ if (event->type == blink::WebInputEvent::MouseWheel) {
+ if (wheel_events_.state() ==
+ WebInputEventQueue<
+ MouseWheelEventWithLatencyInfo>::State::ITEM_PENDING) {
+ wheel_events_.Queue(MouseWheelEventWithLatencyInfo(
Rick Byers 2016/01/26 19:17:21 I think you'll need to coalesce events somewhere j
Rick Byers 2016/01/26 19:20:52 Oh, I see it now in WebInputEventQueue. That clas
+ *static_cast<const blink::WebMouseWheelEvent*>(event), latency));
+ } else {
+ wheel_events_.set_state(
+ WebInputEventQueue<
+ MouseWheelEventWithLatencyInfo>::State::ITEM_PENDING);
+ client_->SendPassiveEvent(routing_id_, event, latency);
+ }
+ } else if (blink::WebInputEvent::isTouchEventType(event->type)) {
+ if (touch_events_.state() ==
+ WebInputEventQueue<TouchEventWithLatencyInfo>::State::ITEM_PENDING) {
+ touch_events_.Queue(TouchEventWithLatencyInfo(
+ *static_cast<const blink::WebTouchEvent*>(event), latency));
+ } else {
+ touch_events_.set_state(
+ WebInputEventQueue<TouchEventWithLatencyInfo>::State::ITEM_PENDING);
+ client_->SendPassiveEvent(routing_id_, event, latency);
+ }
+ } else {
+ NOTREACHED() << "Invalid passive event type";
+ }
+}
+
+void PassiveEventQueue::EventHandled(blink::WebInputEvent::Type type) {
+ if (type == blink::WebInputEvent::MouseWheel) {
+ if (!wheel_events_.empty()) {
+ scoped_ptr<MouseWheelEventWithLatencyInfo> event = wheel_events_.Deque();
+
+ client_->SendPassiveEvent(routing_id_, &event->event, event->latency);
+ } else {
+ wheel_events_.set_state(
+ WebInputEventQueue<
+ MouseWheelEventWithLatencyInfo>::State::ITEM_NOT_PENDING);
+ }
+ } else if (blink::WebInputEvent::isTouchEventType(type)) {
+ if (!touch_events_.empty()) {
+ scoped_ptr<TouchEventWithLatencyInfo> event = touch_events_.Deque();
+ client_->SendPassiveEvent(routing_id_, &event->event, event->latency);
+ } else {
+ touch_events_.set_state(
+ WebInputEventQueue<
+ TouchEventWithLatencyInfo>::State::ITEM_NOT_PENDING);
+ }
+ } else {
+ NOTREACHED() << "Invalid passive event type";
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698