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

Unified Diff: content/renderer/input/non_blocking_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: Renamed enum value as per wez@ request Created 4 years, 10 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/non_blocking_event_queue.cc
diff --git a/content/renderer/input/non_blocking_event_queue.cc b/content/renderer/input/non_blocking_event_queue.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4fc5d11b6119dbb649877443a52c14f442711bb0
--- /dev/null
+++ b/content/renderer/input/non_blocking_event_queue.cc
@@ -0,0 +1,60 @@
+// 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/non_blocking_event_queue.h"
+
+namespace content {
+
+NonBlockingEventQueue::NonBlockingEventQueue(
+ int routing_id,
+ NonBlockingEventQueueClient* client)
+ : routing_id_(routing_id), client_(client) {}
+
+NonBlockingEventQueue::~NonBlockingEventQueue() {}
+
+void NonBlockingEventQueue::HandleEvent(const blink::WebInputEvent* event,
+ const ui::LatencyInfo& latency) {
+ if (event->type == blink::WebInputEvent::MouseWheel) {
+ if (wheel_events_.state() == WebInputEventQueueState::ITEM_PENDING) {
+ wheel_events_.Queue(MouseWheelEventWithLatencyInfo(
+ *static_cast<const blink::WebMouseWheelEvent*>(event), latency));
+ } else {
+ wheel_events_.set_state(WebInputEventQueueState::ITEM_PENDING);
+ client_->SendNonBlockingEvent(routing_id_, event, latency);
+ }
+ } else if (blink::WebInputEvent::isTouchEventType(event->type)) {
+ if (touch_events_.state() == WebInputEventQueueState::ITEM_PENDING) {
+ touch_events_.Queue(TouchEventWithLatencyInfo(
+ *static_cast<const blink::WebTouchEvent*>(event), latency));
+ } else {
+ touch_events_.set_state(WebInputEventQueueState::ITEM_PENDING);
+ client_->SendNonBlockingEvent(routing_id_, event, latency);
+ }
+ } else {
+ NOTREACHED() << "Invalid passive event type";
+ }
+}
+
+void NonBlockingEventQueue::EventHandled(blink::WebInputEvent::Type type) {
+ if (type == blink::WebInputEvent::MouseWheel) {
+ if (!wheel_events_.empty()) {
+ scoped_ptr<MouseWheelEventWithLatencyInfo> event = wheel_events_.Pop();
+
+ client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency);
+ } else {
+ wheel_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
+ }
+ } else if (blink::WebInputEvent::isTouchEventType(type)) {
+ if (!touch_events_.empty()) {
+ scoped_ptr<TouchEventWithLatencyInfo> event = touch_events_.Pop();
+ client_->SendNonBlockingEvent(routing_id_, &event->event, event->latency);
+ } else {
+ touch_events_.set_state(WebInputEventQueueState::ITEM_NOT_PENDING);
+ }
+ } else {
+ NOTREACHED() << "Invalid passive event type";
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698