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

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

Issue 1888163003: Articulate the cancel behavior in the WebTouchEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and non-const ref passed back Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/render_widget_input_handler.h" 5 #include "content/renderer/input/render_widget_input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 #undef CASE_TYPE 117 #undef CASE_TYPE
118 } 118 }
119 119
120 void LogPassiveLatency(int64_t latency) { 120 void LogPassiveLatency(int64_t latency) {
121 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1, 121 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1,
122 10000000, 100); 122 10000000, 100);
123 } 123 }
124 124
125 void LogPassiveEventListenersUma(WebInputEventResult result, 125 void LogPassiveEventListenersUma(WebInputEventResult result,
126 bool non_blocking, 126 WebInputEvent::DispatchType dispatch_type,
127 bool cancelable,
128 double event_timestamp, 127 double event_timestamp,
129 const ui::LatencyInfo& latency_info) { 128 const ui::LatencyInfo& latency_info) {
130 enum { 129 enum {
131 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 130 PASSIVE_LISTENER_UMA_ENUM_PASSIVE,
132 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 131 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
133 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 132 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED,
134 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 133 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE,
135 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 134 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED,
135 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING,
136 PASSIVE_LISTENER_UMA_ENUM_COUNT 136 PASSIVE_LISTENER_UMA_ENUM_COUNT
137 }; 137 };
138 138
139 int enum_value; 139 int enum_value;
140 if (non_blocking) 140 switch (dispatch_type) {
141 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; 141 case WebInputEvent::ListenersForcedNonBlockingPassive:
142 else if (!cancelable) 142 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING;
143 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; 143 break;
144 else if (result == WebInputEventResult::HandledApplication) 144 case WebInputEvent::ListenersNonBlockingPassive:
145 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; 145 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE;
146 else if (result == WebInputEventResult::HandledSuppressed) 146 break;
147 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; 147 case WebInputEvent::EventNonBlocking:
148 else 148 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE;
149 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; 149 break;
150 case WebInputEvent::Blocking:
151 if (result == WebInputEventResult::HandledApplication)
152 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED;
153 else if (result == WebInputEventResult::HandledSuppressed)
154 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED;
155 else
156 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE;
157 break;
158 default:
159 NOTREACHED();
160 return;
161 }
150 162
151 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, 163 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value,
152 PASSIVE_LISTENER_UMA_ENUM_COUNT); 164 PASSIVE_LISTENER_UMA_ENUM_COUNT);
153 165
154 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE && 166 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE &&
155 base::TimeTicks::IsHighResolution()) { 167 base::TimeTicks::IsHighResolution()) {
156 base::TimeTicks now = base::TimeTicks::Now(); 168 base::TimeTicks now = base::TimeTicks::Now();
157 LogPassiveLatency(GetEventLatencyMicros(event_timestamp, now)); 169 LogPassiveLatency(GetEventLatencyMicros(event_timestamp, now));
158 } 170 }
159 } 171 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 311
300 WebInputEventResult processed = prevent_default 312 WebInputEventResult processed = prevent_default
301 ? WebInputEventResult::HandledSuppressed 313 ? WebInputEventResult::HandledSuppressed
302 : WebInputEventResult::NotHandled; 314 : WebInputEventResult::NotHandled;
303 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) { 315 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) {
304 suppress_next_char_events_ = false; 316 suppress_next_char_events_ = false;
305 if (processed == WebInputEventResult::NotHandled && widget_->webwidget()) 317 if (processed == WebInputEventResult::NotHandled && widget_->webwidget())
306 processed = widget_->webwidget()->handleInputEvent(input_event); 318 processed = widget_->webwidget()->handleInputEvent(input_event);
307 } 319 }
308 320
309 bool non_blocking =
310 dispatch_type ==
311 InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN ||
312 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING;
313 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start 321 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start
314 // ideally this should be when the event was sent by the compositor to the 322 // ideally this should be when the event was sent by the compositor to the
315 // renderer. crbug.com/565348 323 // renderer. crbug.com/565348
316 if (input_event.type == WebInputEvent::TouchStart || 324 if (input_event.type == WebInputEvent::TouchStart ||
317 input_event.type == WebInputEvent::TouchMove || 325 input_event.type == WebInputEvent::TouchMove ||
318 input_event.type == WebInputEvent::TouchEnd) { 326 input_event.type == WebInputEvent::TouchEnd) {
319 LogPassiveEventListenersUma( 327 LogPassiveEventListenersUma(
320 processed, non_blocking, 328 processed, static_cast<const WebTouchEvent&>(input_event).dispatchType,
321 static_cast<const WebTouchEvent&>(input_event).cancelable,
322 input_event.timeStampSeconds, latency_info); 329 input_event.timeStampSeconds, latency_info);
323 } else if (input_event.type == WebInputEvent::MouseWheel) { 330 } else if (input_event.type == WebInputEvent::MouseWheel) {
324 LogPassiveEventListenersUma(processed, non_blocking, !non_blocking, 331 bool non_blocking =
332 dispatch_type ==
333 InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN ||
334 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING;
335 LogPassiveEventListenersUma(processed,
336 non_blocking ? WebInputEvent::EventNonBlocking
337 : WebInputEvent::Blocking,
325 input_event.timeStampSeconds, latency_info); 338 input_event.timeStampSeconds, latency_info);
326 } 339 }
327 340
328 // If this RawKeyDown event corresponds to a browser keyboard shortcut and 341 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
329 // it's not processed by webkit, then we need to suppress the upcoming Char 342 // it's not processed by webkit, then we need to suppress the upcoming Char
330 // events. 343 // events.
331 bool is_keyboard_shortcut = 344 bool is_keyboard_shortcut =
332 input_event.type == WebInputEvent::RawKeyDown && 345 input_event.type == WebInputEvent::RawKeyDown &&
333 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut; 346 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut;
334 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut) 347 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 if (pending_input_event_ack_) { 546 if (pending_input_event_ack_) {
534 TRACE_EVENT_ASYNC_END0("input", 547 TRACE_EVENT_ASYNC_END0("input",
535 "RenderWidgetInputHandler::ThrottledInputEventAck", 548 "RenderWidgetInputHandler::ThrottledInputEventAck",
536 pending_input_event_ack_.get()); 549 pending_input_event_ack_.get());
537 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); 550 delegate_->OnInputEventAck(std::move(pending_input_event_ack_));
538 } 551 }
539 total_input_handling_time_this_frame_ = base::TimeDelta(); 552 total_input_handling_time_this_frame_ = base::TimeDelta();
540 } 553 }
541 554
542 } // namespace content 555 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/main_thread_event_queue_unittest.cc ('k') | content/renderer/render_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698