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 <utility> | 10 #include <utility> |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 return; | 967 return; |
968 } | 968 } |
969 | 969 |
970 if (ShouldDropInputEvents()) | 970 if (ShouldDropInputEvents()) |
971 return; | 971 return; |
972 | 972 |
973 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) | 973 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) |
974 return; | 974 return; |
975 | 975 |
976 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); | 976 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); |
977 latency_tracker_.OnInputEvent(mouse_event, &mouse_with_latency.latency); | 977 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); |
978 input_router_->SendMouseEvent(mouse_with_latency); | 978 input_router_->SendMouseEvent(mouse_with_latency); |
979 } | 979 } |
980 | 980 |
981 void RenderWidgetHostImpl::ForwardWheelEvent( | 981 void RenderWidgetHostImpl::ForwardWheelEvent( |
982 const WebMouseWheelEvent& wheel_event) { | 982 const WebMouseWheelEvent& wheel_event) { |
983 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); | 983 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); |
984 } | 984 } |
985 | 985 |
986 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( | 986 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
987 const blink::WebMouseWheelEvent& wheel_event, | 987 const blink::WebMouseWheelEvent& wheel_event, |
988 const ui::LatencyInfo& ui_latency) { | 988 const ui::LatencyInfo& ui_latency) { |
989 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", | 989 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", |
990 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); | 990 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); |
991 | 991 |
992 if (ShouldDropInputEvents()) | 992 if (ShouldDropInputEvents()) |
993 return; | 993 return; |
994 | 994 |
995 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) | 995 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) |
996 return; | 996 return; |
997 | 997 |
998 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); | 998 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); |
999 latency_tracker_.OnInputEvent(wheel_event, &wheel_with_latency.latency); | 999 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); |
1000 input_router_->SendWheelEvent(wheel_with_latency); | 1000 input_router_->SendWheelEvent(wheel_with_latency); |
1001 } | 1001 } |
1002 | 1002 |
1003 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( | 1003 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( |
1004 const blink::WebGestureEvent& gesture_event) { | 1004 const blink::WebGestureEvent& gesture_event) { |
1005 ForwardGestureEvent(gesture_event); | 1005 ForwardGestureEvent(gesture_event); |
1006 } | 1006 } |
1007 | 1007 |
1008 void RenderWidgetHostImpl::ForwardGestureEvent( | 1008 void RenderWidgetHostImpl::ForwardGestureEvent( |
1009 const blink::WebGestureEvent& gesture_event) { | 1009 const blink::WebGestureEvent& gesture_event) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 if (scroll_update_needs_wrapping) { | 1045 if (scroll_update_needs_wrapping) { |
1046 ForwardGestureEventWithLatencyInfo( | 1046 ForwardGestureEventWithLatencyInfo( |
1047 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); | 1047 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); |
1048 } | 1048 } |
1049 | 1049 |
1050 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. | 1050 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. |
1051 if (delegate_->PreHandleGestureEvent(gesture_event)) | 1051 if (delegate_->PreHandleGestureEvent(gesture_event)) |
1052 return; | 1052 return; |
1053 | 1053 |
1054 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); | 1054 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); |
1055 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency); | 1055 DispatchInputEventWithLatencyInfo(gesture_event, |
| 1056 &gesture_with_latency.latency); |
1056 input_router_->SendGestureEvent(gesture_with_latency); | 1057 input_router_->SendGestureEvent(gesture_with_latency); |
1057 | 1058 |
1058 if (scroll_update_needs_wrapping) { | 1059 if (scroll_update_needs_wrapping) { |
1059 ForwardGestureEventWithLatencyInfo( | 1060 ForwardGestureEventWithLatencyInfo( |
1060 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); | 1061 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); |
1061 } | 1062 } |
1062 } | 1063 } |
1063 | 1064 |
1064 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( | 1065 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
1065 const blink::WebTouchEvent& touch_event) { | 1066 const blink::WebTouchEvent& touch_event) { |
1066 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); | 1067 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
1067 | 1068 |
1068 TouchEventWithLatencyInfo touch_with_latency(touch_event); | 1069 TouchEventWithLatencyInfo touch_with_latency(touch_event); |
1069 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); | 1070 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); |
1070 input_router_->SendTouchEvent(touch_with_latency); | 1071 input_router_->SendTouchEvent(touch_with_latency); |
1071 } | 1072 } |
1072 | 1073 |
1073 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( | 1074 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
1074 const blink::WebTouchEvent& touch_event, | 1075 const blink::WebTouchEvent& touch_event, |
1075 const ui::LatencyInfo& ui_latency) { | 1076 const ui::LatencyInfo& ui_latency) { |
1076 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); | 1077 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); |
1077 | 1078 |
1078 // Always forward TouchEvents for touch stream consistency. They will be | 1079 // Always forward TouchEvents for touch stream consistency. They will be |
1079 // ignored if appropriate in FilterInputEvent(). | 1080 // ignored if appropriate in FilterInputEvent(). |
1080 | 1081 |
1081 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency); | 1082 TouchEventWithLatencyInfo touch_with_latency(touch_event, ui_latency); |
1082 if (touch_emulator_ && | 1083 if (touch_emulator_ && |
1083 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { | 1084 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { |
1084 if (view_) { | 1085 if (view_) { |
1085 view_->ProcessAckedTouchEvent( | 1086 view_->ProcessAckedTouchEvent( |
1086 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); | 1087 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); |
1087 } | 1088 } |
1088 return; | 1089 return; |
1089 } | 1090 } |
1090 | 1091 |
1091 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); | 1092 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); |
1092 input_router_->SendTouchEvent(touch_with_latency); | 1093 input_router_->SendTouchEvent(touch_with_latency); |
1093 } | 1094 } |
1094 | 1095 |
1095 void RenderWidgetHostImpl::ForwardKeyboardEvent( | 1096 void RenderWidgetHostImpl::ForwardKeyboardEvent( |
1096 const NativeWebKeyboardEvent& key_event) { | 1097 const NativeWebKeyboardEvent& key_event) { |
1097 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); | 1098 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
1098 if (owner_delegate_ && | 1099 if (owner_delegate_ && |
1099 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { | 1100 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { |
1100 return; | 1101 return; |
1101 } | 1102 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 | 1151 |
1151 if (key_event.type == WebKeyboardEvent::RawKeyDown) | 1152 if (key_event.type == WebKeyboardEvent::RawKeyDown) |
1152 suppress_next_char_events_ = false; | 1153 suppress_next_char_events_ = false; |
1153 } | 1154 } |
1154 | 1155 |
1155 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) | 1156 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
1156 return; | 1157 return; |
1157 | 1158 |
1158 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); | 1159 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); |
1159 key_event_with_latency.event.isBrowserShortcut = is_shortcut; | 1160 key_event_with_latency.event.isBrowserShortcut = is_shortcut; |
1160 latency_tracker_.OnInputEvent(key_event, &key_event_with_latency.latency); | 1161 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); |
1161 input_router_->SendKeyboardEvent(key_event_with_latency); | 1162 input_router_->SendKeyboardEvent(key_event_with_latency); |
1162 } | 1163 } |
1163 | 1164 |
1164 void RenderWidgetHostImpl::QueueSyntheticGesture( | 1165 void RenderWidgetHostImpl::QueueSyntheticGesture( |
1165 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 1166 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
1166 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { | 1167 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { |
1167 if (!synthetic_gesture_controller_ && view_) { | 1168 if (!synthetic_gesture_controller_ && view_) { |
1168 synthetic_gesture_controller_.reset( | 1169 synthetic_gesture_controller_.reset( |
1169 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); | 1170 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); |
1170 } | 1171 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 void RenderWidgetHostImpl::RemoveMouseEventCallback( | 1223 void RenderWidgetHostImpl::RemoveMouseEventCallback( |
1223 const MouseEventCallback& callback) { | 1224 const MouseEventCallback& callback) { |
1224 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { | 1225 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
1225 if (mouse_event_callbacks_[i].Equals(callback)) { | 1226 if (mouse_event_callbacks_[i].Equals(callback)) { |
1226 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); | 1227 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); |
1227 return; | 1228 return; |
1228 } | 1229 } |
1229 } | 1230 } |
1230 } | 1231 } |
1231 | 1232 |
| 1233 void RenderWidgetHostImpl::AddInputEventObserver( |
| 1234 RenderWidgetHost::InputEventObserver* observer) { |
| 1235 if (!input_event_observers_.HasObserver(observer)) |
| 1236 input_event_observers_.AddObserver(observer); |
| 1237 } |
| 1238 |
| 1239 void RenderWidgetHostImpl::RemoveInputEventObserver( |
| 1240 RenderWidgetHost::InputEventObserver* observer) { |
| 1241 input_event_observers_.RemoveObserver(observer); |
| 1242 } |
| 1243 |
1232 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) { | 1244 void RenderWidgetHostImpl::GetWebScreenInfo(blink::WebScreenInfo* result) { |
1233 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); | 1245 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); |
1234 if (view_) | 1246 if (view_) |
1235 view_->GetScreenInfo(result); | 1247 view_->GetScreenInfo(result); |
1236 else | 1248 else |
1237 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); | 1249 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); |
1238 // TODO(sievers): find a way to make this done another way so the method | 1250 // TODO(sievers): find a way to make this done another way so the method |
1239 // can be const. | 1251 // can be const. |
1240 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); | 1252 latency_tracker_.set_device_scale_factor(result->deviceScaleFactor); |
1241 if (IsUseZoomForDSFEnabled()) | 1253 if (IsUseZoomForDSFEnabled()) |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { | 1893 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { |
1882 if (view_) | 1894 if (view_) |
1883 view_->DidOverscroll(params); | 1895 view_->DidOverscroll(params); |
1884 } | 1896 } |
1885 | 1897 |
1886 void RenderWidgetHostImpl::DidStopFlinging() { | 1898 void RenderWidgetHostImpl::DidStopFlinging() { |
1887 if (view_) | 1899 if (view_) |
1888 view_->DidStopFlinging(); | 1900 view_->DidStopFlinging(); |
1889 } | 1901 } |
1890 | 1902 |
| 1903 void RenderWidgetHostImpl::DispatchInputEventWithLatencyInfo( |
| 1904 const blink::WebInputEvent& event, |
| 1905 ui::LatencyInfo* latency) { |
| 1906 latency_tracker_.OnInputEvent(event, latency); |
| 1907 FOR_EACH_OBSERVER(InputEventObserver, input_event_observers_, |
| 1908 OnInputEvent(event)); |
| 1909 } |
| 1910 |
1891 void RenderWidgetHostImpl::OnKeyboardEventAck( | 1911 void RenderWidgetHostImpl::OnKeyboardEventAck( |
1892 const NativeWebKeyboardEventWithLatencyInfo& event, | 1912 const NativeWebKeyboardEventWithLatencyInfo& event, |
1893 InputEventAckState ack_result) { | 1913 InputEventAckState ack_result) { |
1894 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); | 1914 latency_tracker_.OnInputEventAck(event.event, &event.latency, ack_result); |
1895 | 1915 |
1896 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 1916 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); |
1897 | 1917 |
1898 // We only send unprocessed key event upwards if we are not hidden, | 1918 // We only send unprocessed key event upwards if we are not hidden, |
1899 // because the user has moved away from us and no longer expect any effect | 1919 // because the user has moved away from us and no longer expect any effect |
1900 // of this key event. | 1920 // of this key event. |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2184 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2165 } | 2185 } |
2166 | 2186 |
2167 BrowserAccessibilityManager* | 2187 BrowserAccessibilityManager* |
2168 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2188 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2169 return delegate_ ? | 2189 return delegate_ ? |
2170 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2190 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2171 } | 2191 } |
2172 | 2192 |
2173 } // namespace content | 2193 } // namespace content |
OLD | NEW |