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