Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 ignore_input_events_(false), | 275 ignore_input_events_(false), |
| 276 text_direction_updated_(false), | 276 text_direction_updated_(false), |
| 277 text_direction_(blink::WebTextDirectionLeftToRight), | 277 text_direction_(blink::WebTextDirectionLeftToRight), |
| 278 text_direction_canceled_(false), | 278 text_direction_canceled_(false), |
| 279 suppress_events_until_keydown_(false), | 279 suppress_events_until_keydown_(false), |
| 280 pending_mouse_lock_request_(false), | 280 pending_mouse_lock_request_(false), |
| 281 allow_privileged_mouse_lock_(false), | 281 allow_privileged_mouse_lock_(false), |
| 282 has_touch_handler_(false), | 282 has_touch_handler_(false), |
| 283 is_in_touchpad_gesture_scroll_(false), | 283 is_in_touchpad_gesture_scroll_(false), |
| 284 is_in_touchscreen_gesture_scroll_(false), | 284 is_in_touchscreen_gesture_scroll_(false), |
| 285 is_in_touchpad_gesture_fling_(false), | |
| 285 latency_tracker_(), | 286 latency_tracker_(), |
| 286 next_browser_snapshot_id_(1), | 287 next_browser_snapshot_id_(1), |
| 287 owned_by_render_frame_host_(false), | 288 owned_by_render_frame_host_(false), |
| 288 is_focused_(false), | 289 is_focused_(false), |
| 289 hung_renderer_delay_( | 290 hung_renderer_delay_( |
| 290 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 291 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 291 hang_monitor_event_type_(blink::WebInputEvent::Undefined), | 292 hang_monitor_event_type_(blink::WebInputEvent::Undefined), |
| 292 last_event_type_(blink::WebInputEvent::Undefined), | 293 last_event_type_(blink::WebInputEvent::Undefined), |
| 293 new_content_rendering_delay_( | 294 new_content_rendering_delay_( |
| 294 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 295 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 // It is possible for a compositor frame to arrive before the browser is | 1012 // It is possible for a compositor frame to arrive before the browser is |
| 1012 // notified about the page being committed, in which case no timer is | 1013 // notified about the page being committed, in which case no timer is |
| 1013 // necessary. | 1014 // necessary. |
| 1014 if (last_received_content_source_id_ >= current_content_source_id_) | 1015 if (last_received_content_source_id_ >= current_content_source_id_) |
| 1015 return; | 1016 return; |
| 1016 | 1017 |
| 1017 new_content_rendering_timeout_->Start(new_content_rendering_delay_); | 1018 new_content_rendering_timeout_->Start(new_content_rendering_delay_); |
| 1018 } | 1019 } |
| 1019 | 1020 |
| 1020 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 1021 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 1022 if (GetView()->IsInVR() && | |
|
dtapuska
2017/04/13 14:48:25
Can we put a comment here indicating why we are do
asimjour1
2017/04/13 16:31:35
Done.
| |
| 1023 (is_in_touchpad_gesture_scroll_ || is_in_touchpad_gesture_fling_)) { | |
| 1024 return; | |
| 1025 } | |
| 1026 | |
| 1021 ForwardMouseEventWithLatencyInfo(mouse_event, | 1027 ForwardMouseEventWithLatencyInfo(mouse_event, |
| 1022 ui::LatencyInfo(ui::SourceEventType::OTHER)); | 1028 ui::LatencyInfo(ui::SourceEventType::OTHER)); |
| 1023 if (owner_delegate_) | 1029 if (owner_delegate_) |
| 1024 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); | 1030 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); |
| 1025 } | 1031 } |
| 1026 | 1032 |
| 1027 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 1033 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| 1028 const blink::WebMouseEvent& mouse_event, | 1034 const blink::WebMouseEvent& mouse_event, |
| 1029 const ui::LatencyInfo& ui_latency) { | 1035 const ui::LatencyInfo& ui_latency) { |
| 1030 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x", | 1036 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x", |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1104 *is_in_gesture_scroll = true; | 1110 *is_in_gesture_scroll = true; |
| 1105 } else if (gesture_event.type() == blink::WebInputEvent::GestureScrollEnd || | 1111 } else if (gesture_event.type() == blink::WebInputEvent::GestureScrollEnd || |
| 1106 gesture_event.type() == blink::WebInputEvent::GestureFlingStart) { | 1112 gesture_event.type() == blink::WebInputEvent::GestureFlingStart) { |
| 1107 // TODO(wjmaclean): Re-enable the following DCHECK once crbug.com/695187 | 1113 // TODO(wjmaclean): Re-enable the following DCHECK once crbug.com/695187 |
| 1108 // is fixed. | 1114 // is fixed. |
| 1109 // DCHECK(*is_in_gesture_scroll || | 1115 // DCHECK(*is_in_gesture_scroll || |
| 1110 // (gesture_event.type() == blink::WebInputEvent::GestureFlingStart && | 1116 // (gesture_event.type() == blink::WebInputEvent::GestureFlingStart && |
| 1111 // gesture_event.sourceDevice == | 1117 // gesture_event.sourceDevice == |
| 1112 // blink::WebGestureDevice::WebGestureDeviceTouchpad)); | 1118 // blink::WebGestureDevice::WebGestureDeviceTouchpad)); |
| 1113 *is_in_gesture_scroll = false; | 1119 *is_in_gesture_scroll = false; |
| 1120 if (gesture_event.type() == blink::WebInputEvent::GestureFlingStart) | |
|
dtapuska
2017/04/13 14:48:25
I think this needs a check that the source device
asimjour1
2017/04/13 16:31:35
Done.
| |
| 1121 is_in_touchpad_gesture_fling_ = true; | |
| 1114 } | 1122 } |
| 1115 | 1123 |
| 1116 bool scroll_update_needs_wrapping = | 1124 bool scroll_update_needs_wrapping = |
| 1117 gesture_event.type() == blink::WebInputEvent::GestureScrollUpdate && | 1125 gesture_event.type() == blink::WebInputEvent::GestureScrollUpdate && |
| 1118 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); | 1126 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); |
| 1119 | 1127 |
| 1120 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- | 1128 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- |
| 1121 // Bubble to test the resending logic of gesture events. | 1129 // Bubble to test the resending logic of gesture events. |
| 1122 if (scroll_update_needs_wrapping) { | 1130 if (scroll_update_needs_wrapping) { |
| 1123 ForwardGestureEventWithLatencyInfo( | 1131 ForwardGestureEventWithLatencyInfo( |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2212 synthetic_gesture_controller_->OnDidFlushInput(); | 2220 synthetic_gesture_controller_->OnDidFlushInput(); |
| 2213 } | 2221 } |
| 2214 | 2222 |
| 2215 void RenderWidgetHostImpl::DidOverscroll( | 2223 void RenderWidgetHostImpl::DidOverscroll( |
| 2216 const ui::DidOverscrollParams& params) { | 2224 const ui::DidOverscrollParams& params) { |
| 2217 if (view_) | 2225 if (view_) |
| 2218 view_->DidOverscroll(params); | 2226 view_->DidOverscroll(params); |
| 2219 } | 2227 } |
| 2220 | 2228 |
| 2221 void RenderWidgetHostImpl::DidStopFlinging() { | 2229 void RenderWidgetHostImpl::DidStopFlinging() { |
| 2230 is_in_touchpad_gesture_fling_ = false; | |
| 2222 if (view_) | 2231 if (view_) |
| 2223 view_->DidStopFlinging(); | 2232 view_->DidStopFlinging(); |
| 2224 } | 2233 } |
| 2225 | 2234 |
| 2226 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( | 2235 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( |
| 2227 const blink::WebInputEvent& event, | 2236 const blink::WebInputEvent& event, |
| 2228 ui::LatencyInfo* latency) { | 2237 ui::LatencyInfo* latency) { |
| 2229 latency_tracker_.OnInputEvent(event, latency); | 2238 latency_tracker_.OnInputEvent(event, latency); |
| 2230 for (auto& observer : input_event_observers_) | 2239 for (auto& observer : input_event_observers_) |
| 2231 observer.OnInputEvent(event); | 2240 observer.OnInputEvent(event); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2713 RenderProcessHost* rph = GetProcess(); | 2722 RenderProcessHost* rph = GetProcess(); |
| 2714 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); | 2723 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); |
| 2715 i != messages.end(); ++i) { | 2724 i != messages.end(); ++i) { |
| 2716 rph->OnMessageReceived(*i); | 2725 rph->OnMessageReceived(*i); |
| 2717 if (i->dispatch_error()) | 2726 if (i->dispatch_error()) |
| 2718 rph->OnBadMessageReceived(*i); | 2727 rph->OnBadMessageReceived(*i); |
| 2719 } | 2728 } |
| 2720 } | 2729 } |
| 2721 | 2730 |
| 2722 } // namespace content | 2731 } // namespace content |
| OLD | NEW |