| 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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 new_content_rendering_timeout_->Stop(); | 949 new_content_rendering_timeout_->Stop(); |
| 949 } else { | 950 } else { |
| 950 received_paint_after_load_ = true; | 951 received_paint_after_load_ = true; |
| 951 } | 952 } |
| 952 | 953 |
| 953 if (delegate_) | 954 if (delegate_) |
| 954 delegate_->OnFirstPaintAfterLoad(this); | 955 delegate_->OnFirstPaintAfterLoad(this); |
| 955 } | 956 } |
| 956 | 957 |
| 957 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 958 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
| 958 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); | 959 ForwardMouseEventWithLatencyInfo(mouse_event, |
| 960 ui::LatencyInfo(ui::SourceEventType::OTHER)); |
| 959 if (owner_delegate_) | 961 if (owner_delegate_) |
| 960 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); | 962 owner_delegate_->RenderWidgetDidForwardMouseEvent(mouse_event); |
| 961 } | 963 } |
| 962 | 964 |
| 963 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 965 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| 964 const blink::WebMouseEvent& mouse_event, | 966 const blink::WebMouseEvent& mouse_event, |
| 965 const ui::LatencyInfo& ui_latency) { | 967 const ui::LatencyInfo& ui_latency) { |
| 966 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 968 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
| 967 "x", mouse_event.x, "y", mouse_event.y); | 969 "x", mouse_event.x, "y", mouse_event.y); |
| 968 | 970 |
| 969 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { | 971 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
| 970 if (mouse_event_callbacks_[i].Run(mouse_event)) | 972 if (mouse_event_callbacks_[i].Run(mouse_event)) |
| 971 return; | 973 return; |
| 972 } | 974 } |
| 973 | 975 |
| 974 if (ShouldDropInputEvents()) | 976 if (ShouldDropInputEvents()) |
| 975 return; | 977 return; |
| 976 | 978 |
| 977 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) | 979 if (touch_emulator_ && touch_emulator_->HandleMouseEvent(mouse_event)) |
| 978 return; | 980 return; |
| 979 | 981 |
| 980 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); | 982 MouseEventWithLatencyInfo mouse_with_latency(mouse_event, ui_latency); |
| 981 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); | 983 DispatchInputEventWithLatencyInfo(mouse_event, &mouse_with_latency.latency); |
| 982 input_router_->SendMouseEvent(mouse_with_latency); | 984 input_router_->SendMouseEvent(mouse_with_latency); |
| 983 } | 985 } |
| 984 | 986 |
| 985 void RenderWidgetHostImpl::ForwardWheelEvent( | 987 void RenderWidgetHostImpl::ForwardWheelEvent( |
| 986 const WebMouseWheelEvent& wheel_event) { | 988 const WebMouseWheelEvent& wheel_event) { |
| 987 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); | 989 ForwardWheelEventWithLatencyInfo(wheel_event, |
| 990 ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
| 988 } | 991 } |
| 989 | 992 |
| 990 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( | 993 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
| 991 const blink::WebMouseWheelEvent& wheel_event, | 994 const blink::WebMouseWheelEvent& wheel_event, |
| 992 const ui::LatencyInfo& ui_latency) { | 995 const ui::LatencyInfo& ui_latency) { |
| 993 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", | 996 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardWheelEvent", |
| 994 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); | 997 "dx", wheel_event.deltaX, "dy", wheel_event.deltaY); |
| 995 | 998 |
| 996 if (ShouldDropInputEvents()) | 999 if (ShouldDropInputEvents()) |
| 997 return; | 1000 return; |
| 998 | 1001 |
| 999 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) | 1002 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) |
| 1000 return; | 1003 return; |
| 1001 | 1004 |
| 1002 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); | 1005 MouseWheelEventWithLatencyInfo wheel_with_latency(wheel_event, ui_latency); |
| 1003 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); | 1006 DispatchInputEventWithLatencyInfo(wheel_event, &wheel_with_latency.latency); |
| 1004 input_router_->SendWheelEvent(wheel_with_latency); | 1007 input_router_->SendWheelEvent(wheel_with_latency); |
| 1005 } | 1008 } |
| 1006 | 1009 |
| 1007 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( | 1010 void RenderWidgetHostImpl::ForwardEmulatedGestureEvent( |
| 1008 const blink::WebGestureEvent& gesture_event) { | 1011 const blink::WebGestureEvent& gesture_event) { |
| 1009 ForwardGestureEvent(gesture_event); | 1012 ForwardGestureEvent(gesture_event); |
| 1010 } | 1013 } |
| 1011 | 1014 |
| 1012 void RenderWidgetHostImpl::ForwardGestureEvent( | 1015 void RenderWidgetHostImpl::ForwardGestureEvent( |
| 1013 const blink::WebGestureEvent& gesture_event) { | 1016 const blink::WebGestureEvent& gesture_event) { |
| 1014 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); | 1017 ForwardGestureEventWithLatencyInfo( |
| 1018 gesture_event, |
| 1019 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1020 gesture_event)); |
| 1015 } | 1021 } |
| 1016 | 1022 |
| 1017 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( | 1023 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
| 1018 const blink::WebGestureEvent& gesture_event, | 1024 const blink::WebGestureEvent& gesture_event, |
| 1019 const ui::LatencyInfo& ui_latency) { | 1025 const ui::LatencyInfo& ui_latency) { |
| 1020 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 1026 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
| 1021 // Early out if necessary, prior to performing latency logic. | 1027 // Early out if necessary, prior to performing latency logic. |
| 1022 if (ShouldDropInputEvents()) | 1028 if (ShouldDropInputEvents()) |
| 1023 return; | 1029 return; |
| 1024 | 1030 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1041 blink::WebGestureDevice::WebGestureDeviceTouchpad)); | 1047 blink::WebGestureDevice::WebGestureDeviceTouchpad)); |
| 1042 *is_in_gesture_scroll = false; | 1048 *is_in_gesture_scroll = false; |
| 1043 } | 1049 } |
| 1044 | 1050 |
| 1045 bool scroll_update_needs_wrapping = | 1051 bool scroll_update_needs_wrapping = |
| 1046 gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && | 1052 gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 1047 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); | 1053 gesture_event.resendingPluginId != -1 && !(*is_in_gesture_scroll); |
| 1048 | 1054 |
| 1049 if (scroll_update_needs_wrapping) { | 1055 if (scroll_update_needs_wrapping) { |
| 1050 ForwardGestureEventWithLatencyInfo( | 1056 ForwardGestureEventWithLatencyInfo( |
| 1051 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); | 1057 CreateScrollBeginForWrapping(gesture_event), |
| 1058 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1059 gesture_event)); |
| 1052 } | 1060 } |
| 1053 | 1061 |
| 1054 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. | 1062 // Delegate must be non-null, due to |ShouldDropInputEvents()| test. |
| 1055 if (delegate_->PreHandleGestureEvent(gesture_event)) | 1063 if (delegate_->PreHandleGestureEvent(gesture_event)) |
| 1056 return; | 1064 return; |
| 1057 | 1065 |
| 1058 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); | 1066 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); |
| 1059 DispatchInputEventWithLatencyInfo(gesture_event, | 1067 DispatchInputEventWithLatencyInfo(gesture_event, |
| 1060 &gesture_with_latency.latency); | 1068 &gesture_with_latency.latency); |
| 1061 input_router_->SendGestureEvent(gesture_with_latency); | 1069 input_router_->SendGestureEvent(gesture_with_latency); |
| 1062 | 1070 |
| 1063 if (scroll_update_needs_wrapping) { | 1071 if (scroll_update_needs_wrapping) { |
| 1064 ForwardGestureEventWithLatencyInfo( | 1072 ForwardGestureEventWithLatencyInfo( |
| 1065 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); | 1073 CreateScrollEndForWrapping(gesture_event), |
| 1074 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent( |
| 1075 gesture_event)); |
| 1066 } | 1076 } |
| 1067 } | 1077 } |
| 1068 | 1078 |
| 1069 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( | 1079 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
| 1070 const blink::WebTouchEvent& touch_event) { | 1080 const blink::WebTouchEvent& touch_event) { |
| 1071 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); | 1081 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
| 1072 | 1082 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); |
| 1073 TouchEventWithLatencyInfo touch_with_latency(touch_event); | 1083 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
| 1074 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); | 1084 DispatchInputEventWithLatencyInfo(touch_event, &touch_with_latency.latency); |
| 1075 input_router_->SendTouchEvent(touch_with_latency); | 1085 input_router_->SendTouchEvent(touch_with_latency); |
| 1076 } | 1086 } |
| 1077 | 1087 |
| 1078 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( | 1088 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
| 1079 const blink::WebTouchEvent& touch_event, | 1089 const blink::WebTouchEvent& touch_event, |
| 1080 const ui::LatencyInfo& ui_latency) { | 1090 const ui::LatencyInfo& ui_latency) { |
| 1081 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); | 1091 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); |
| 1082 | 1092 |
| 1083 // Always forward TouchEvents for touch stream consistency. They will be | 1093 // Always forward TouchEvents for touch stream consistency. They will be |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 // a hung/malicious renderer from interfering. | 1162 // a hung/malicious renderer from interfering. |
| 1153 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) | 1163 if (delegate_->PreHandleKeyboardEvent(key_event, &is_shortcut)) |
| 1154 return; | 1164 return; |
| 1155 | 1165 |
| 1156 if (key_event.type == WebKeyboardEvent::RawKeyDown) | 1166 if (key_event.type == WebKeyboardEvent::RawKeyDown) |
| 1157 suppress_next_char_events_ = false; | 1167 suppress_next_char_events_ = false; |
| 1158 } | 1168 } |
| 1159 | 1169 |
| 1160 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) | 1170 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
| 1161 return; | 1171 return; |
| 1162 | 1172 ui::LatencyInfo latency_info(ui::SourceEventType::OTHER); |
| 1163 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event); | 1173 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, |
| 1174 latency_info); |
| 1164 key_event_with_latency.event.isBrowserShortcut = is_shortcut; | 1175 key_event_with_latency.event.isBrowserShortcut = is_shortcut; |
| 1165 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); | 1176 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); |
| 1166 input_router_->SendKeyboardEvent(key_event_with_latency); | 1177 input_router_->SendKeyboardEvent(key_event_with_latency); |
| 1167 } | 1178 } |
| 1168 | 1179 |
| 1169 void RenderWidgetHostImpl::QueueSyntheticGesture( | 1180 void RenderWidgetHostImpl::QueueSyntheticGesture( |
| 1170 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 1181 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
| 1171 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { | 1182 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { |
| 1172 if (!synthetic_gesture_controller_ && view_) { | 1183 if (!synthetic_gesture_controller_ && view_) { |
| 1173 synthetic_gesture_controller_.reset( | 1184 synthetic_gesture_controller_.reset( |
| (...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2219 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2209 } | 2220 } |
| 2210 | 2221 |
| 2211 BrowserAccessibilityManager* | 2222 BrowserAccessibilityManager* |
| 2212 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2223 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2213 return delegate_ ? | 2224 return delegate_ ? |
| 2214 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2225 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2215 } | 2226 } |
| 2216 | 2227 |
| 2217 } // namespace content | 2228 } // namespace content |
| OLD | NEW |