Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index a4020cdce464401523d63ee87736c61dc06676f8..394d274d9d4513051702b8bbe15f1687d8b0b5d9 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -241,6 +241,46 @@ void LogInputEventLatencyUma(const WebInputEvent& event, base::TimeTicks now, |
| } |
| } |
| +void LogPassiveLatency(int64 latency) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS("Event.PassiveListeners.Latency", latency, 1, |
| + 10000000, 100); |
| +} |
| + |
| +void LogPassiveEventListenersUma(WebInputEventResult result, |
| + bool passive, |
| + bool cancelable, |
| + double event_timestamp, |
| + base::TimeTicks now, |
| + const ui::LatencyInfo& latency_info) { |
| + enum { |
| + PASSIVE_LISTENER_UMA_ENUM_PASSIVE, |
| + PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, |
| + PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, |
| + PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, |
| + PASSIVE_LISTENER_UMA_ENUM_COUNT |
| + }; |
| + |
| + int enum_value; |
| + if (passive) |
| + enum_value = PASSIVE_LISTENER_UMA_ENUM_PASSIVE; |
| + else if (!cancelable) |
| + enum_value = PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE; |
| + else if (result == WebInputEventResult::HandledScript) |
| + enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED; |
| + else |
| + enum_value = PASSIVE_LISTENER_UMA_ENUM_CANCELABLE; |
| + |
| + UMA_HISTOGRAM_ENUMERATION("Event.PassiveListeners", enum_value, |
| + PASSIVE_LISTENER_UMA_ENUM_COUNT); |
| + |
| + if (enum_value == PASSIVE_LISTENER_UMA_ENUM_CANCELABLE && !now.is_null()) { |
| + LogPassiveLatency(GetEventLatencyMicros(event_timestamp, now)); |
| + for (size_t i = 0; i < latency_info.coalesced_events_size(); i++) |
| + LogPassiveLatency(GetEventLatencyMicros( |
| + latency_info.timestamps_of_coalesced_events()[i], now)); |
| + } |
| +} |
| + |
| } // namespace |
| namespace content { |
| @@ -1093,6 +1133,7 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| const ui::LatencyInfo& latency_info) { |
| if (!input_event) |
| return; |
| + bool passive = false; |
|
tdresser
2015/11/23 21:14:34
Add a comment linking to the bug indicating that t
dtapuska
2015/11/27 20:05:25
Done.
|
| base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_, |
| true); |
| base::AutoReset<WebInputEvent::Type> handling_event_type_resetter( |
| @@ -1178,12 +1219,26 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| prevent_default = prevent_default || WillHandleGestureEvent(gesture_event); |
| } |
| - bool processed = prevent_default; |
| + WebInputEventResult processed = |
| + prevent_default ? WebInputEventResult::HandledDefaultHandler |
| + : WebInputEventResult::NotHandled; |
| if (input_event->type != WebInputEvent::Char || !suppress_next_char_events_) { |
| suppress_next_char_events_ = false; |
| - if (!processed && webwidget_) |
| - processed = webwidget_->handleInputEvent(*input_event) != |
| - WebInputEventResult::NotHandled; |
| + if (processed == WebInputEventResult::NotHandled && webwidget_) |
| + processed = webwidget_->handleInputEvent(*input_event); |
| + } |
| + |
| + if (input_event->type == WebInputEvent::TouchStart || |
| + input_event->type == WebInputEvent::TouchMove || |
| + input_event->type == WebInputEvent::TouchEnd) { |
|
tdresser
2015/11/23 21:14:34
Does isTouchEventType work for you?
https://code.g
dtapuska
2015/11/23 21:33:57
I didn't necessarily want to capture TouchCancel s
|
| + LogPassiveEventListenersUma( |
| + processed, passive, |
| + static_cast<const WebTouchEvent*>(input_event)->cancelable, |
| + input_event->timeStampSeconds, start_time, latency_info); |
| + } else if (input_event->type == WebInputEvent::MouseWheel) { |
| + LogPassiveEventListenersUma(processed, passive, !passive, |
|
tdresser
2015/11/23 21:14:34
Does this make it more difficult to draw conclusio
dtapuska
2015/11/23 21:33:57
UMA would only record a non-cancelable event for t
|
| + input_event->timeStampSeconds, start_time, |
| + latency_info); |
| } |
| // If this RawKeyDown event corresponds to a browser keyboard shortcut and |
| @@ -1192,12 +1247,14 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| bool is_keyboard_shortcut = |
| input_event->type == WebInputEvent::RawKeyDown && |
| static_cast<const WebKeyboardEvent*>(input_event)->isBrowserShortcut; |
| - if (!processed && is_keyboard_shortcut) |
| + if (processed == WebInputEventResult::NotHandled && is_keyboard_shortcut) |
| suppress_next_char_events_ = true; |
| - InputEventAckState ack_result = processed ? |
| - INPUT_EVENT_ACK_STATE_CONSUMED : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| - if (!processed && input_event->type == WebInputEvent::TouchStart) { |
| + InputEventAckState ack_result = processed == WebInputEventResult::NotHandled |
| + ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED |
| + : INPUT_EVENT_ACK_STATE_CONSUMED; |
| + if (processed == WebInputEventResult::NotHandled && |
| + input_event->type == WebInputEvent::TouchStart) { |
| const WebTouchEvent& touch_event = |
| *static_cast<const WebTouchEvent*>(input_event); |
| // Hit-test for all the pressed touch points. If there is a touch-handler |
| @@ -1221,7 +1278,7 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| static_cast<const WebMouseWheelEvent&>(*input_event), |
| event_overscroll ? event_overscroll->latest_overscroll_delta |
| : gfx::Vector2dF(), |
| - processed); |
| + processed != WebInputEventResult::NotHandled); |
| } |
| bool frame_pending = compositor_ && compositor_->BeginMainFrameRequested(); |
| @@ -1288,13 +1345,15 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| #if defined(OS_ANDROID) |
| // Allow the IME to be shown when the focus changes as a consequence |
| // of a processed touch end event. |
| - if (input_event->type == WebInputEvent::TouchEnd && processed) |
| + if (input_event->type == WebInputEvent::TouchEnd && |
| + processed != WebInputEventResult::NotHandled) |
|
tdresser
2015/11/23 21:14:34
I'm a fan of braces when the condition is multi-li
dtapuska
2015/11/23 21:33:57
woops; that is me not checking git cl format.
dtapuska
2015/11/27 20:05:25
Done.
|
| UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); |
| #elif defined(USE_AURA) |
| // Show the virtual keyboard if enabled and a user gesture triggers a focus |
| // change. |
| - if (processed && (input_event->type == WebInputEvent::TouchEnd || |
| - input_event->type == WebInputEvent::MouseUp)) { |
| + if (processed != WebInputEventResult::NotHandled && |
| + (input_event->type == WebInputEvent::TouchEnd || |
| + input_event->type == WebInputEvent::MouseUp)) { |
| UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_IME); |
| } |
| #endif |
| @@ -1308,8 +1367,9 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event, |
| // virtual keyboard. |
| #if !defined(OS_ANDROID) |
| // Virtual keyboard is not supported, so react to focus change immediately. |
| - if (processed && (input_event->type == WebInputEvent::TouchEnd || |
| - input_event->type == WebInputEvent::MouseUp)) { |
| + if (processed != WebInputEventResult::NotHandled && |
| + (input_event->type == WebInputEvent::TouchEnd || |
| + input_event->type == WebInputEvent::MouseUp)) { |
| FocusChangeComplete(); |
| } |
| #endif |