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 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return host; | 131 return host; |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 std::vector<RenderWidgetHostID> hosts_; | 135 std::vector<RenderWidgetHostID> hosts_; |
136 size_t current_index_; | 136 size_t current_index_; |
137 | 137 |
138 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostIteratorImpl); | 138 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostIteratorImpl); |
139 }; | 139 }; |
140 | 140 |
| 141 inline blink::WebGestureEvent CreateScrollBeginForWrapping( |
| 142 const blink::WebGestureEvent& gesture_event) { |
| 143 DCHECK(gesture_event.type == blink::WebInputEvent::GestureScrollUpdate); |
| 144 |
| 145 blink::WebGestureEvent wrap_gesture_scroll_begin; |
| 146 wrap_gesture_scroll_begin.type = blink::WebInputEvent::GestureScrollBegin; |
| 147 wrap_gesture_scroll_begin.data.scrollBegin.deltaXHint = 0; |
| 148 wrap_gesture_scroll_begin.data.scrollBegin.deltaYHint = 0; |
| 149 wrap_gesture_scroll_begin.resendingPluginId = gesture_event.resendingPluginId; |
| 150 |
| 151 return wrap_gesture_scroll_begin; |
| 152 } |
| 153 |
| 154 inline blink::WebGestureEvent CreateScrollEndForWrapping( |
| 155 const blink::WebGestureEvent& gesture_event) { |
| 156 DCHECK(gesture_event.type == blink::WebInputEvent::GestureScrollUpdate); |
| 157 |
| 158 blink::WebGestureEvent wrap_gesture_scroll_end; |
| 159 wrap_gesture_scroll_end.type = blink::WebInputEvent::GestureScrollEnd; |
| 160 wrap_gesture_scroll_end.resendingPluginId = gesture_event.resendingPluginId; |
| 161 |
| 162 return wrap_gesture_scroll_end; |
| 163 } |
| 164 |
141 } // namespace | 165 } // namespace |
142 | 166 |
143 /////////////////////////////////////////////////////////////////////////////// | 167 /////////////////////////////////////////////////////////////////////////////// |
144 // RenderWidgetHostImpl | 168 // RenderWidgetHostImpl |
145 | 169 |
146 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 170 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
147 RenderProcessHost* process, | 171 RenderProcessHost* process, |
148 int32_t routing_id, | 172 int32_t routing_id, |
149 int32_t surface_id, | 173 int32_t surface_id, |
150 bool hidden) | 174 bool hidden) |
(...skipping 19 matching lines...) Expand all Loading... |
170 in_flight_event_count_(0), | 194 in_flight_event_count_(0), |
171 in_get_backing_store_(false), | 195 in_get_backing_store_(false), |
172 ignore_input_events_(false), | 196 ignore_input_events_(false), |
173 text_direction_updated_(false), | 197 text_direction_updated_(false), |
174 text_direction_(blink::WebTextDirectionLeftToRight), | 198 text_direction_(blink::WebTextDirectionLeftToRight), |
175 text_direction_canceled_(false), | 199 text_direction_canceled_(false), |
176 suppress_next_char_events_(false), | 200 suppress_next_char_events_(false), |
177 pending_mouse_lock_request_(false), | 201 pending_mouse_lock_request_(false), |
178 allow_privileged_mouse_lock_(false), | 202 allow_privileged_mouse_lock_(false), |
179 has_touch_handler_(false), | 203 has_touch_handler_(false), |
| 204 is_in_gesture_scroll_(false), |
180 next_browser_snapshot_id_(1), | 205 next_browser_snapshot_id_(1), |
181 owned_by_render_frame_host_(false), | 206 owned_by_render_frame_host_(false), |
182 is_focused_(false), | 207 is_focused_(false), |
183 weak_factory_(this) { | 208 weak_factory_(this) { |
184 CHECK(delegate_); | 209 CHECK(delegate_); |
185 CHECK_NE(MSG_ROUTING_NONE, routing_id_); | 210 CHECK_NE(MSG_ROUTING_NONE, routing_id_); |
186 DCHECK_EQ(surface_id_, GpuSurfaceTracker::Get()->LookupSurfaceForRenderer( | 211 DCHECK_EQ(surface_id_, GpuSurfaceTracker::Get()->LookupSurfaceForRenderer( |
187 process_->GetID(), routing_id_)); | 212 process_->GetID(), routing_id_)); |
188 | 213 |
189 std::pair<RoutingIDWidgetMap::iterator, bool> result = | 214 std::pair<RoutingIDWidgetMap::iterator, bool> result = |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 } | 1016 } |
992 | 1017 |
993 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( | 1018 void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
994 const blink::WebGestureEvent& gesture_event, | 1019 const blink::WebGestureEvent& gesture_event, |
995 const ui::LatencyInfo& ui_latency) { | 1020 const ui::LatencyInfo& ui_latency) { |
996 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); | 1021 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); |
997 // Early out if necessary, prior to performing latency logic. | 1022 // Early out if necessary, prior to performing latency logic. |
998 if (IgnoreInputEvents()) | 1023 if (IgnoreInputEvents()) |
999 return; | 1024 return; |
1000 | 1025 |
| 1026 // TODO(wjmaclean) Remove the code for supporting resending gesture events |
| 1027 // when WebView transitions to OOPIF and BrowserPlugin is removed. |
| 1028 // http://crbug.com/533069 |
| 1029 if (gesture_event.type == blink::WebInputEvent::GestureScrollBegin) { |
| 1030 DCHECK(!is_in_gesture_scroll_); |
| 1031 is_in_gesture_scroll_ = true; |
| 1032 } else if (gesture_event.type == blink::WebInputEvent::GestureScrollEnd || |
| 1033 gesture_event.type == blink::WebInputEvent::GestureFlingStart) { |
| 1034 DCHECK(is_in_gesture_scroll_ || |
| 1035 (gesture_event.type == blink::WebInputEvent::GestureFlingStart && |
| 1036 gesture_event.sourceDevice == |
| 1037 blink::WebGestureDevice::WebGestureDeviceTouchpad)); |
| 1038 is_in_gesture_scroll_ = false; |
| 1039 } |
| 1040 |
| 1041 bool scroll_update_needs_wrapping = |
| 1042 gesture_event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 1043 gesture_event.resendingPluginId != -1 && !is_in_gesture_scroll_; |
| 1044 |
| 1045 if (scroll_update_needs_wrapping) { |
| 1046 ForwardGestureEventWithLatencyInfo( |
| 1047 CreateScrollBeginForWrapping(gesture_event), ui::LatencyInfo()); |
| 1048 } |
| 1049 |
1001 if (delegate_->PreHandleGestureEvent(gesture_event)) | 1050 if (delegate_->PreHandleGestureEvent(gesture_event)) |
1002 return; | 1051 return; |
1003 | 1052 |
1004 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); | 1053 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, ui_latency); |
1005 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency); | 1054 latency_tracker_.OnInputEvent(gesture_event, &gesture_with_latency.latency); |
1006 input_router_->SendGestureEvent(gesture_with_latency); | 1055 input_router_->SendGestureEvent(gesture_with_latency); |
| 1056 |
| 1057 if (scroll_update_needs_wrapping) { |
| 1058 ForwardGestureEventWithLatencyInfo( |
| 1059 CreateScrollEndForWrapping(gesture_event), ui::LatencyInfo()); |
| 1060 } |
1007 } | 1061 } |
1008 | 1062 |
1009 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( | 1063 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
1010 const blink::WebTouchEvent& touch_event) { | 1064 const blink::WebTouchEvent& touch_event) { |
1011 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); | 1065 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
1012 | 1066 |
1013 TouchEventWithLatencyInfo touch_with_latency(touch_event); | 1067 TouchEventWithLatencyInfo touch_with_latency(touch_event); |
1014 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); | 1068 latency_tracker_.OnInputEvent(touch_event, &touch_with_latency.latency); |
1015 input_router_->SendTouchEvent(touch_with_latency); | 1069 input_router_->SendTouchEvent(touch_with_latency); |
1016 } | 1070 } |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 } | 2213 } |
2160 | 2214 |
2161 #if defined(OS_WIN) | 2215 #if defined(OS_WIN) |
2162 gfx::NativeViewAccessible | 2216 gfx::NativeViewAccessible |
2163 RenderWidgetHostImpl::GetParentNativeViewAccessible() { | 2217 RenderWidgetHostImpl::GetParentNativeViewAccessible() { |
2164 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; | 2218 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; |
2165 } | 2219 } |
2166 #endif | 2220 #endif |
2167 | 2221 |
2168 } // namespace content | 2222 } // namespace content |
OLD | NEW |