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

Side by Side Diff: content/renderer/input/main_thread_event_queue.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/input/main_thread_event_queue.h" 5 #include "content/renderer/input/main_thread_event_queue.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "content/common/input/event_with_latency_info.h" 8 #include "content/common/input/event_with_latency_info.h"
9 #include "content/common/input_messages.h" 9 #include "content/common/input_messages.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 namespace { 13 namespace {
14 14
15 const size_t kTenSeconds = 10 * 1000 * 1000; 15 const size_t kTenSeconds = 10 * 1000 * 1000;
16 16
17 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) { 17 bool IsContinuousEvent(const std::unique_ptr<EventWithDispatchType>& event) {
18 switch (event->event().type) { 18 switch (event->event().type()) {
19 case blink::WebInputEvent::MouseMove: 19 case blink::WebInputEvent::MouseMove:
20 case blink::WebInputEvent::MouseWheel: 20 case blink::WebInputEvent::MouseWheel:
21 case blink::WebInputEvent::TouchMove: 21 case blink::WebInputEvent::TouchMove:
22 return true; 22 return true;
23 default: 23 default:
24 return false; 24 return false;
25 } 25 }
26 } 26 }
27 27
28 } // namespace 28 } // namespace
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 InputEventDispatchType original_dispatch_type, 83 InputEventDispatchType original_dispatch_type,
84 InputEventAckState ack_result) { 84 InputEventAckState ack_result) {
85 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING || 85 DCHECK(original_dispatch_type == DISPATCH_TYPE_BLOCKING ||
86 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING); 86 original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING);
87 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING || 87 DCHECK(ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING ||
88 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || 88 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING ||
89 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 89 ack_result == INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
90 90
91 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING || 91 bool non_blocking = original_dispatch_type == DISPATCH_TYPE_NON_BLOCKING ||
92 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING; 92 ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING;
93 bool is_wheel = event->type == blink::WebInputEvent::MouseWheel; 93 bool is_wheel = event->type() == blink::WebInputEvent::MouseWheel;
94 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type); 94 bool is_touch = blink::WebInputEvent::isTouchEventType(event->type());
95 95
96 if (is_touch) { 96 if (is_touch) {
97 blink::WebTouchEvent* touch_event = 97 blink::WebTouchEvent* touch_event =
98 static_cast<blink::WebTouchEvent*>(event.get()); 98 static_cast<blink::WebTouchEvent*>(event.get());
99 99
100 // Adjust the |dispatchType| on the event since the compositor 100 // Adjust the |dispatchType| on the event since the compositor
101 // determined all event listeners are passive. 101 // determined all event listeners are passive.
102 if (non_blocking) { 102 if (non_blocking) {
103 touch_event->dispatchType = 103 touch_event->dispatchType =
104 blink::WebInputEvent::ListenersNonBlockingPassive; 104 blink::WebInputEvent::ListenersNonBlockingPassive;
105 } 105 }
106 if (touch_event->type == blink::WebInputEvent::TouchStart) 106 if (touch_event->type() == blink::WebInputEvent::TouchStart)
107 last_touch_start_forced_nonblocking_due_to_fling_ = false; 107 last_touch_start_forced_nonblocking_due_to_fling_ = false;
108 108
109 if (enable_fling_passive_listener_flag_ && 109 if (enable_fling_passive_listener_flag_ &&
110 touch_event->touchStartOrFirstTouchMove && 110 touch_event->touchStartOrFirstTouchMove &&
111 touch_event->dispatchType == blink::WebInputEvent::Blocking) { 111 touch_event->dispatchType == blink::WebInputEvent::Blocking) {
112 // If the touch start is forced to be passive due to fling, its following 112 // If the touch start is forced to be passive due to fling, its following
113 // touch move should also be passive. 113 // touch move should also be passive.
114 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING || 114 if (ack_result == INPUT_EVENT_ACK_STATE_SET_NON_BLOCKING_DUE_TO_FLING ||
115 last_touch_start_forced_nonblocking_due_to_fling_) { 115 last_touch_start_forced_nonblocking_due_to_fling_) {
116 touch_event->dispatchType = 116 touch_event->dispatchType =
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (needs_main_frame) 323 if (needs_main_frame)
324 client_->NeedsMainFrame(routing_id_); 324 client_->NeedsMainFrame(routing_id_);
325 } 325 }
326 326
327 bool MainThreadEventQueue::IsRafAlignedInputDisabled() { 327 bool MainThreadEventQueue::IsRafAlignedInputDisabled() {
328 return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_; 328 return !handle_raf_aligned_mouse_input_ && !handle_raf_aligned_touch_input_;
329 } 329 }
330 330
331 bool MainThreadEventQueue::IsRafAlignedEvent( 331 bool MainThreadEventQueue::IsRafAlignedEvent(
332 const blink::WebInputEvent& event) { 332 const blink::WebInputEvent& event) {
333 switch (event.type) { 333 switch (event.type()) {
334 case blink::WebInputEvent::MouseMove: 334 case blink::WebInputEvent::MouseMove:
335 case blink::WebInputEvent::MouseWheel: 335 case blink::WebInputEvent::MouseWheel:
336 return handle_raf_aligned_mouse_input_; 336 return handle_raf_aligned_mouse_input_;
337 case blink::WebInputEvent::TouchMove: 337 case blink::WebInputEvent::TouchMove:
338 return handle_raf_aligned_touch_input_; 338 return handle_raf_aligned_touch_input_;
339 default: 339 default:
340 return false; 340 return false;
341 } 341 }
342 } 342 }
343 343
344 } // namespace content 344 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_manager.cc ('k') | content/renderer/input/main_thread_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698