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

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: 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 #undef CASE_TYPE 116 #undef CASE_TYPE
117 } 117 }
118 118
119 void LogPassiveLatency(int64_t latency) { 119 void LogPassiveLatency(int64_t latency) {
120 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1, 120 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1,
121 10000000, 100); 121 10000000, 100);
122 } 122 }
123 123
124 void LogPassiveEventListenersUma(WebInputEventResult result, 124 void LogPassiveEventListenersUma(WebInputEventResult result,
tdresser 2016/04/18 15:12:02 Could we add some kind of test for this? Worst cas
dtapuska 2016/04/18 19:19:33 Done.
125 bool non_blocking, 125 WebInputEvent::DispatchType dispatch_type,
126 bool cancelable,
127 double event_timestamp, 126 double event_timestamp,
128 const ui::LatencyInfo& latency_info) { 127 const ui::LatencyInfo& latency_info) {
129 enum { 128 enum {
130 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 129 PASSIVE_LISTENER_UMA_ENUM_PASSIVE,
131 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 130 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
132 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 131 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED,
133 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 132 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE,
134 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 133 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED,
134 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING,
135 PASSIVE_LISTENER_UMA_ENUM_COUNT 135 PASSIVE_LISTENER_UMA_ENUM_COUNT
136 }; 136 };
137 137
138 int enum_value; 138 int enum_value;
139 if (non_blocking) 139 switch (dispatch_type) {
140 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; 140 case WebInputEvent::NonBlockingForced:
141 else if (!cancelable) 141 enum_value = PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING;
142 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; 142 break;
143 else if (result == WebInputEventResult::HandledApplication) 143 case WebInputEvent::NonBlockingPassive:
144 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; 144 enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE;
145 else if (result == WebInputEventResult::HandledSuppressed) 145 break;
146 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED; 146 case WebInputEvent::NonBlocking:
147 else 147 enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE;
148 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; 148 break;
149 case WebInputEvent::Blocking:
150 if (result == WebInputEventResult::HandledApplication)
151 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED;
152 else if (result == WebInputEventResult::HandledSuppressed)
153 enum_value = PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED;
154 else
155 enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE;
156 break;
157 default:
158 NOTREACHED();
159 return;
160 }
149 161
150 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, 162 UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value,
151 PASSIVE_LISTENER_UMA_ENUM_COUNT); 163 PASSIVE_LISTENER_UMA_ENUM_COUNT);
152 164
153 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE && 165 if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE &&
154 base::TimeTicks::IsHighResolution()) { 166 base::TimeTicks::IsHighResolution()) {
155 base::TimeTicks now = base::TimeTicks::Now(); 167 base::TimeTicks now = base::TimeTicks::Now();
156 LogPassiveLatency(GetEventLatencyMicros(event_timestamp, now)); 168 LogPassiveLatency(GetEventLatencyMicros(event_timestamp, now));
157 } 169 }
158 } 170 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 310
299 WebInputEventResult processed = prevent_default 311 WebInputEventResult processed = prevent_default
300 ? WebInputEventResult::HandledSuppressed 312 ? WebInputEventResult::HandledSuppressed
301 : WebInputEventResult::NotHandled; 313 : WebInputEventResult::NotHandled;
302 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) { 314 if (input_event.type != WebInputEvent::Char || !suppress_next_char_events_) {
303 suppress_next_char_events_ = false; 315 suppress_next_char_events_ = false;
304 if (processed == WebInputEventResult::NotHandled && widget_->webwidget()) 316 if (processed == WebInputEventResult::NotHandled && widget_->webwidget())
305 processed = widget_->webwidget()->handleInputEvent(input_event); 317 processed = widget_->webwidget()->handleInputEvent(input_event);
306 } 318 }
307 319
308 bool non_blocking =
309 dispatch_type ==
310 InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN ||
311 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING;
312 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start 320 // TODO(dtapuska): Use the input_event.timeStampSeconds as the start
313 // ideally this should be when the event was sent by the compositor to the 321 // ideally this should be when the event was sent by the compositor to the
314 // renderer. crbug.com/565348 322 // renderer. crbug.com/565348
315 if (input_event.type == WebInputEvent::TouchStart || 323 if (input_event.type == WebInputEvent::TouchStart ||
316 input_event.type == WebInputEvent::TouchMove || 324 input_event.type == WebInputEvent::TouchMove ||
317 input_event.type == WebInputEvent::TouchEnd) { 325 input_event.type == WebInputEvent::TouchEnd) {
318 LogPassiveEventListenersUma( 326 LogPassiveEventListenersUma(
319 processed, non_blocking, 327 processed, static_cast<const WebTouchEvent&>(input_event).dispatchType,
320 static_cast<const WebTouchEvent&>(input_event).cancelable,
321 input_event.timeStampSeconds, latency_info); 328 input_event.timeStampSeconds, latency_info);
322 } else if (input_event.type == WebInputEvent::MouseWheel) { 329 } else if (input_event.type == WebInputEvent::MouseWheel) {
323 LogPassiveEventListenersUma(processed, non_blocking, !non_blocking, 330 bool non_blocking =
324 input_event.timeStampSeconds, latency_info); 331 dispatch_type ==
332 InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING_NOTIFY_MAIN ||
tdresser 2016/04/18 15:12:03 Would it be clearer to negate this boolean?
dtapuska 2016/04/18 19:19:33 can I leave this for now. It is going away in a fo
tdresser 2016/04/18 19:40:45 SGTM.
333 dispatch_type == InputEventDispatchType::DISPATCH_TYPE_NON_BLOCKING;
334 LogPassiveEventListenersUma(
335 processed,
336 non_blocking ? WebInputEvent::NonBlocking : WebInputEvent::Blocking,
337 input_event.timeStampSeconds, latency_info);
325 } 338 }
326 339
327 // If this RawKeyDown event corresponds to a browser keyboard shortcut and 340 // If this RawKeyDown event corresponds to a browser keyboard shortcut and
328 // it's not processed by webkit, then we need to suppress the upcoming Char 341 // it's not processed by webkit, then we need to suppress the upcoming Char
329 // events. 342 // events.
330 bool is_keyboard_shortcut = 343 bool is_keyboard_shortcut =
331 input_event.type == WebInputEvent::RawKeyDown && 344 input_event.type == WebInputEvent::RawKeyDown &&
332 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut; 345 static_cast<const WebKeyboardEvent&>(input_event).isBrowserShortcut;
333 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut) 346 if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut)
334 suppress_next_char_events_ = true; 347 suppress_next_char_events_ = true;
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 if (pending_input_event_ack_) { 545 if (pending_input_event_ack_) {
533 TRACE_EVENT_ASYNC_END0("input", 546 TRACE_EVENT_ASYNC_END0("input",
534 "RenderWidgetInputHandler::ThrottledInputEventAck", 547 "RenderWidgetInputHandler::ThrottledInputEventAck",
535 pending_input_event_ack_.get()); 548 pending_input_event_ack_.get());
536 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); 549 delegate_->OnInputEventAck(std::move(pending_input_event_ack_));
537 } 550 }
538 total_input_handling_time_this_frame_ = base::TimeDelta(); 551 total_input_handling_time_this_frame_ = base::TimeDelta();
539 } 552 }
540 553
541 } // namespace content 554 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698