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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #include "content/public/common/content_constants.h" | 67 #include "content/public/common/content_constants.h" |
68 #include "content/public/common/content_switches.h" | 68 #include "content/public/common/content_switches.h" |
69 #include "content/public/common/result_codes.h" | 69 #include "content/public/common/result_codes.h" |
70 #include "content/public/common/web_preferences.h" | 70 #include "content/public/common/web_preferences.h" |
71 #include "gpu/GLES2/gl2extchromium.h" | 71 #include "gpu/GLES2/gl2extchromium.h" |
72 #include "gpu/command_buffer/service/gpu_switches.h" | 72 #include "gpu/command_buffer/service/gpu_switches.h" |
73 #include "gpu/ipc/common/gpu_messages.h" | 73 #include "gpu/ipc/common/gpu_messages.h" |
74 #include "skia/ext/image_operations.h" | 74 #include "skia/ext/image_operations.h" |
75 #include "skia/ext/platform_canvas.h" | 75 #include "skia/ext/platform_canvas.h" |
76 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 76 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 77 #include "ui/events/blink/web_input_event_traits.h" |
77 #include "ui/events/event.h" | 78 #include "ui/events/event.h" |
78 #include "ui/events/keycodes/keyboard_codes.h" | 79 #include "ui/events/keycodes/keyboard_codes.h" |
79 #include "ui/gfx/color_space.h" | 80 #include "ui/gfx/color_space.h" |
80 #include "ui/gfx/geometry/size_conversions.h" | 81 #include "ui/gfx/geometry/size_conversions.h" |
81 #include "ui/gfx/geometry/vector2d_conversions.h" | 82 #include "ui/gfx/geometry/vector2d_conversions.h" |
82 #include "ui/gfx/skbitmap_operations.h" | 83 #include "ui/gfx/skbitmap_operations.h" |
83 #include "ui/snapshot/snapshot.h" | 84 #include "ui/snapshot/snapshot.h" |
84 | 85 |
85 #if defined(OS_MACOSX) | 86 #if defined(OS_MACOSX) |
86 #include "device/power_save_blocker/power_save_blocker.h" | 87 #include "device/power_save_blocker/power_save_blocker.h" |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 new_content_rendering_timeout_->Stop(); | 951 new_content_rendering_timeout_->Stop(); |
951 } else { | 952 } else { |
952 received_paint_after_load_ = true; | 953 received_paint_after_load_ = true; |
953 } | 954 } |
954 | 955 |
955 if (delegate_) | 956 if (delegate_) |
956 delegate_->OnFirstPaintAfterLoad(this); | 957 delegate_->OnFirstPaintAfterLoad(this); |
957 } | 958 } |
958 | 959 |
959 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 960 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
960 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 961 ForwardMouseEventWithLatencyInfo(mouse_event, |
| 962 ui::LatencyInfo(ui::SourceEventType::OTHER)); |
961 if (owner_delegate_) | 963 if (owner_delegate_) |
962 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); | 964 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); |
963 } | 965 } |
964 | 966 |
965 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 967 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
966 const blink::WebMouseEvent& mouse_event, | 968 const blink::WebMouseEvent& mouse_event, |
967 const ui::LatencyInfo& ui_latency) { | 969 const ui::LatencyInfo& ui_latency) { |
968 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 970 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
969 "x", mouse_event.x, "y", mouse_event.y); | 971 "x", mouse_event.x, "y", mouse_event.y); |
970 | 972 |
971 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { | 973 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
972 if (mouse_event_callbacks_[i].Run(mouse_event)) | 974 if (mouse_event_callbacks_[i].Run(mouse_event)) |
973 return; | 975 return; |
974 } | 976 } |
975 | 977 |
976 if (ShouldDropInputEvents()) | 978 if (ShouldDropInputEvents()) |
977 return; | 979 return; |
978 | 980 |
979 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) | 981 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) |
980 return; | 982 return; |
981 | 983 |
982 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); | 984 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); |
983 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); | 985 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); |
984 input_router_->SendMouseEvent(mouse_with_latency); | 986 input_router_->SendMouseEvent(mouse_with_latency); |
985 } | 987 } |
986 | 988 |
987 void RenderWidgetHostImpl::ForwardWheelEvent( | 989 void RenderWidgetHostImpl::ForwardWheelEvent( |
988 const WebMouseWheelEvent& wheel_event) { | 990 const WebMouseWheelEvent& wheel_event) { |
989 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); | 991 ForwardWheelEventWithLatencyInfo(wheel_event, |
| 992 ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
990 } | 993 } |
991 | 994 |
992 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( | 995 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
993 const blink::WebMouseWheelEvent& wheel_event, | 996 const blink::WebMouseWheelEvent& wheel_event, |
994 const ui::LatencyInfo& ui_latency) { | 997 const ui::LatencyInfo& ui_latency) { |
995 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", | 998 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", |
996 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); | 999 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); |
997 | 1000 |
998 if (ShouldDropInputEvents()) | 1001 if (ShouldDropInputEvents()) |
999 return; | 1002 return; |
1000 | 1003 |
1001 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) | 1004 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) |
1002 return; | 1005 return; |
1003 | 1006 |
1004 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); | 1007 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); |
1005 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); | 1008 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); |
1006 input_router_->SendWheelEvent(wheel_with_latency); | 1009 input_router_->SendWheelEvent(wheel_with_latency); |
1007 } | 1010 } |
1008 | 1011 |
1009 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( | 1012 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( |
1010 const blink::WebGestureEvent& gesture_event) { | 1013 const blink::WebGestureEvent& gesture_event) { |
1011 ForwardGestureEvent(gesture_event); | 1014 ForwardGestureEvent(gesture_event); |
1012 } | 1015 } |
1013 | 1016 |
1014 void RenderWidgetHostImpl::ForwardGestureEvent( | 1017 void RenderWidgetHostImpl::ForwardGestureEvent( |
1015 const blink::WebGestureEvent& gesture_event) { | 1018 const blink::WebGestureEvent& gesture_event) { |
1016 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); | 1019 ForwardGestureEventWithLatencyInfo( |
| 1020 gesture_event, |
| 1021 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1022 gesture_event)); |
1017 } | 1023 } |
1018 | 1024 |
1019 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( | 1025 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
1020 const blink::WebGestureEvent& gesture_event, | 1026 const blink::WebGestureEvent& gesture_event, |
1021 const ui::LatencyInfo& ui_latency) { | 1027 const ui::LatencyInfo& ui_latency) { |
1022 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 1028 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
1023 // Early out if necessary, prior to performing latency logic. | 1029 // Early out if necessary, prior to performing latency logic. |
1024 if (ShouldDropInputEvents()) | 1030 if (ShouldDropInputEvents()) |
1025 return; | 1031 return; |
1026 | 1032 |
(...skipping 18 matching lines...) Expand all Loading... |
1045 } | 1051 } |
1046 | 1052 |
1047 bool scroll_update_needs_wrapping = | 1053 bool scroll_update_needs_wrapping = |
1048 gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 1054 gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
1049 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); | 1055 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); |
1050 | 1056 |
1051 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- | 1057 // TODO(crbug.com/544782): Fix WebViewGuestScrollTest.TestGuestWheelScrolls- |
1052 // Bubble to test the resending logic of gesture events. | 1058 // Bubble to test the resending logic of gesture events. |
1053 if (scroll_update_needs_wrapping) { | 1059 if (scroll_update_needs_wrapping) { |
1054 ForwardGestureEventWithLatencyInfo( | 1060 ForwardGestureEventWithLatencyInfo( |
1055 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); | 1061 CreateScrollBeginForWrapping(gesture_event), |
| 1062 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1063 gesture_event)); |
1056 } | 1064 } |
1057 | 1065 |
1058 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. | 1066 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. |
1059 if (delegate_->PreHandleGestureEvent(gesture_event)) | 1067 if (delegate_->PreHandleGestureEvent(gesture_event)) |
1060 return; | 1068 return; |
1061 | 1069 |
1062 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); | 1070 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); |
1063 DispatchInputEventWithLatencyInfo(gesture_event, | 1071 DispatchInputEventWithLatencyInfo(gesture_event, |
1064 &gesture_with_latency.latency); | 1072 &gesture_with_latency.latency); |
1065 input_router_->SendGestureEvent(gesture_with_latency); | 1073 input_router_->SendGestureEvent(gesture_with_latency); |
1066 | 1074 |
1067 if (scroll_update_needs_wrapping) { | 1075 if (scroll_update_needs_wrapping) { |
1068 ForwardGestureEventWithLatencyInfo( | 1076 ForwardGestureEventWithLatencyInfo( |
1069 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); | 1077 CreateScrollEndForWrapping(gesture_event), |
| 1078 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1079 gesture_event)); |
1070 } | 1080 } |
1071 } | 1081 } |
1072 | 1082 |
1073 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( | 1083 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
1074 const blink::WebTouchEvent& touch_event) { | 1084 const blink::WebTouchEvent& touch_event) { |
1075 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); | 1085 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
1076 | 1086 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); |
1077 TouchEventWithLatencyInfo touch_with_latency(touch_event); | 1087 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
1078 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); | 1088 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); |
1079 input_router_->SendTouchEvent(touch_with_latency); | 1089 input_router_->SendTouchEvent(touch_with_latency); |
1080 } | 1090 } |
1081 | 1091 |
1082 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( | 1092 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
1083 const blink::WebTouchEvent& touch_event, | 1093 const blink::WebTouchEvent& touch_event, |
1084 const ui::LatencyInfo& ui_latency) { | 1094 const ui::LatencyInfo& ui_latency) { |
1085 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); | 1095 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); |
1086 | 1096 |
1087 // Always forward TouchEvents for touch stream consistency. They will be | 1097 // Always forward TouchEvents for touch stream consistency. They will be |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 // a hung/malicious renderer from interfering. | 1166 // a hung/malicious renderer from interfering. |
1157 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) | 1167 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) |
1158 return; | 1168 return; |
1159 | 1169 |
1160 if (key_event.type == WebKeyboardEvent::RawKeyDown) | 1170 if (key_event.type == WebKeyboardEvent::RawKeyDown) |
1161 suppress_next_char_events_ = false; | 1171 suppress_next_char_events_ = false; |
1162 } | 1172 } |
1163 | 1173 |
1164 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) | 1174 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
1165 return; | 1175 return; |
1166 | 1176 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
1167 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); | 1177 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, |
| 1178 latency_info); |
1168 key_event_with_latency.event.isBrowserShortcut = is_shortcut; | 1179 key_event_with_latency.event.isBrowserShortcut = is_shortcut; |
1169 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); | 1180 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); |
1170 input_router_->SendKeyboardEvent(key_event_with_latency); | 1181 input_router_->SendKeyboardEvent(key_event_with_latency); |
1171 } | 1182 } |
1172 | 1183 |
1173 void RenderWidgetHostImpl::QueueSyntheticGesture( | 1184 void RenderWidgetHostImpl::QueueSyntheticGesture( |
1174 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 1185 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
1175 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { | 1186 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { |
1176 if (!synthetic_gesture_controller_ && view_) { | 1187 if (!synthetic_gesture_controller_ && view_) { |
1177 synthetic_gesture_controller_.reset( | 1188 synthetic_gesture_controller_.reset( |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2221 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
2211 } | 2222 } |
2212 | 2223 |
2213 BrowserAccessibilityManager* | 2224 BrowserAccessibilityManager* |
2214 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2225 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2215 return delegate_ ? | 2226 return delegate_ ? |
2216 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2227 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
2217 } | 2228 } |
2218 | 2229 |
2219 } // namespace content | 2230 } // namespace content |
OLD | NEW |