| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ignore_input_events_(false), | 277 ignore_input_events_(false), |
| 278 text_direction_updated_(false), | 278 text_direction_updated_(false), |
| 279 text_direction_(blink::kWebTextDirectionLeftToRight), | 279 text_direction_(blink::kWebTextDirectionLeftToRight), |
| 280 text_direction_canceled_(false), | 280 text_direction_canceled_(false), |
| 281 suppress_events_until_keydown_(false), | 281 suppress_events_until_keydown_(false), |
| 282 pending_mouse_lock_request_(false), | 282 pending_mouse_lock_request_(false), |
| 283 allow_privileged_mouse_lock_(false), | 283 allow_privileged_mouse_lock_(false), |
| 284 has_touch_handler_(false), | 284 has_touch_handler_(false), |
| 285 is_in_touchpad_gesture_scroll_(false), | 285 is_in_touchpad_gesture_scroll_(false), |
| 286 is_in_touchscreen_gesture_scroll_(false), | 286 is_in_touchscreen_gesture_scroll_(false), |
| 287 is_in_touchpad_gesture_fling_(false), |
| 287 latency_tracker_(), | 288 latency_tracker_(), |
| 288 next_browser_snapshot_id_(1), | 289 next_browser_snapshot_id_(1), |
| 289 owned_by_render_frame_host_(false), | 290 owned_by_render_frame_host_(false), |
| 290 is_focused_(false), | 291 is_focused_(false), |
| 291 hung_renderer_delay_( | 292 hung_renderer_delay_( |
| 292 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 293 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 293 hang_monitor_event_type_(blink::WebInputEvent::kUndefined), | 294 hang_monitor_event_type_(blink::WebInputEvent::kUndefined), |
| 294 last_event_type_(blink::WebInputEvent::kUndefined), | 295 last_event_type_(blink::WebInputEvent::kUndefined), |
| 295 new_content_rendering_delay_( | 296 new_content_rendering_delay_( |
| 296 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 297 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 // It is possible for a compositor frame to arrive before the browser is | 1019 // It is possible for a compositor frame to arrive before the browser is |
| 1019 // notified about the page being committed, in which case no timer is | 1020 // notified about the page being committed, in which case no timer is |
| 1020 // necessary. | 1021 // necessary. |
| 1021 if (last_received_content_source_id_ >= current_content_source_id_) | 1022 if (last_received_content_source_id_ >= current_content_source_id_) |
| 1022 return; | 1023 return; |
| 1023 | 1024 |
| 1024 new_content_rendering_timeout_->Start(new_content_rendering_delay_); | 1025 new_content_rendering_timeout_->Start(new_content_rendering_delay_); |
| 1025 } | 1026 } |
| 1026 | 1027 |
| 1027 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 1028 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 1029 // VrController moves the pointer during the scrolling and fling. To ensure |
| 1030 // that scroll performance is not affected we drop mouse events during |
| 1031 // scroll/fling. |
| 1032 if (GetView()->IsInVR() && |
| 1033 (is_in_touchpad_gesture_scroll_ || is_in_touchpad_gesture_fling_)) { |
| 1034 return; |
| 1035 } |
| 1036 |
| 1028 ForwardMouseEventWithLatencyInfo(mouse_event, | 1037 ForwardMouseEventWithLatencyInfo(mouse_event, |
| 1029 ui::LatencyInfo(ui::SourceEventType::OTHER)); | 1038 ui::LatencyInfo(ui::SourceEventType::OTHER)); |
| 1030 if (owner_delegate_) | 1039 if (owner_delegate_) |
| 1031 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); | 1040 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); |
| 1032 } | 1041 } |
| 1033 | 1042 |
| 1034 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 1043 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| 1035 const blink::WebMouseEvent& mouse_event, | 1044 const blink::WebMouseEvent& mouse_event, |
| 1036 const ui::LatencyInfo& ui_latency) { | 1045 const ui::LatencyInfo& ui_latency) { |
| 1037 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x", | 1046 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", "x", |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 blink::WebInputEvent::kGestureScrollEnd || | 1122 blink::WebInputEvent::kGestureScrollEnd || |
| 1114 gesture_event.GetType() == | 1123 gesture_event.GetType() == |
| 1115 blink::WebInputEvent::kGestureFlingStart) { | 1124 blink::WebInputEvent::kGestureFlingStart) { |
| 1116 // TODO(wjmaclean): Re-enable the following DCHECK once crbug.com/695187 | 1125 // TODO(wjmaclean): Re-enable the following DCHECK once crbug.com/695187 |
| 1117 // is fixed. | 1126 // is fixed. |
| 1118 // DCHECK(*is_in_gesture_scroll || | 1127 // DCHECK(*is_in_gesture_scroll || |
| 1119 // (gesture_event.type() == blink::WebInputEvent::GestureFlingStart && | 1128 // (gesture_event.type() == blink::WebInputEvent::GestureFlingStart && |
| 1120 // gesture_event.sourceDevice == | 1129 // gesture_event.sourceDevice == |
| 1121 // blink::WebGestureDevice::WebGestureDeviceTouchpad)); | 1130 // blink::WebGestureDevice::WebGestureDeviceTouchpad)); |
| 1122 *is_in_gesture_scroll = false; | 1131 *is_in_gesture_scroll = false; |
| 1132 if (gesture_event.GetType() == blink::WebInputEvent::kGestureFlingStart && |
| 1133 gesture_event.source_device == |
| 1134 blink::WebGestureDevice::kWebGestureDeviceTouchpad) { |
| 1135 is_in_touchpad_gesture_fling_ = true; |
| 1136 } |
| 1123 } | 1137 } |
| 1124 | 1138 |
| 1125 bool scroll_update_needs_wrapping = | 1139 bool scroll_update_needs_wrapping = |
| 1126 gesture_event.GetType() == blink::WebInputEvent::kGestureScrollUpdate && | 1140 gesture_event.GetType() == blink::WebInputEvent::kGestureScrollUpdate && |
| 1127 gesture_event.resending_plugin_id != -1 && !(*is_in_gesture_scroll); | 1141 gesture_event.resending_plugin_id != -1 && !(*is_in_gesture_scroll); |
| 1128 | 1142 |
| 1129 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- | 1143 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- |
| 1130 // Bubble to test the resending logic of gesture events. | 1144 // Bubble to test the resending logic of gesture events. |
| 1131 if (scroll_update_needs_wrapping) { | 1145 if (scroll_update_needs_wrapping) { |
| 1132 ForwardGestureEventWithLatencyInfo( | 1146 ForwardGestureEventWithLatencyInfo( |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2197 synthetic_gesture_controller_->OnDidFlushInput(); | 2211 synthetic_gesture_controller_->OnDidFlushInput(); |
| 2198 } | 2212 } |
| 2199 | 2213 |
| 2200 void RenderWidgetHostImpl::DidOverscroll( | 2214 void RenderWidgetHostImpl::DidOverscroll( |
| 2201 const ui::DidOverscrollParams& params) { | 2215 const ui::DidOverscrollParams& params) { |
| 2202 if (view_) | 2216 if (view_) |
| 2203 view_->DidOverscroll(params); | 2217 view_->DidOverscroll(params); |
| 2204 } | 2218 } |
| 2205 | 2219 |
| 2206 void RenderWidgetHostImpl::DidStopFlinging() { | 2220 void RenderWidgetHostImpl::DidStopFlinging() { |
| 2221 is_in_touchpad_gesture_fling_ = false; |
| 2207 if (view_) | 2222 if (view_) |
| 2208 view_->DidStopFlinging(); | 2223 view_->DidStopFlinging(); |
| 2209 } | 2224 } |
| 2210 | 2225 |
| 2211 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( | 2226 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( |
| 2212 const blink::WebInputEvent& event, | 2227 const blink::WebInputEvent& event, |
| 2213 ui::LatencyInfo* latency) { | 2228 ui::LatencyInfo* latency) { |
| 2214 latency_tracker_.OnInputEvent(event, latency); | 2229 latency_tracker_.OnInputEvent(event, latency); |
| 2215 for (auto& observer : input_event_observers_) | 2230 for (auto& observer : input_event_observers_) |
| 2216 observer.OnInputEvent(event); | 2231 observer.OnInputEvent(event); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 RenderProcessHost* rph = GetProcess(); | 2731 RenderProcessHost* rph = GetProcess(); |
| 2717 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); | 2732 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); |
| 2718 i != messages.end(); ++i) { | 2733 i != messages.end(); ++i) { |
| 2719 rph->OnMessageReceived(*i); | 2734 rph->OnMessageReceived(*i); |
| 2720 if (i->dispatch_error()) | 2735 if (i->dispatch_error()) |
| 2721 rph->OnBadMessageReceived(*i); | 2736 rph->OnBadMessageReceived(*i); |
| 2722 } | 2737 } |
| 2723 } | 2738 } |
| 2724 | 2739 |
| 2725 } // namespace content | 2740 } // namespace content |
| OLD | NEW |