| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 using blink::WebGestureEvent; | 91 using blink::WebGestureEvent; |
| 92 using blink::WebInputEvent; | 92 using blink::WebInputEvent; |
| 93 using blink::WebKeyboardEvent; | 93 using blink::WebKeyboardEvent; |
| 94 using blink::WebMouseEvent; | 94 using blink::WebMouseEvent; |
| 95 using blink::WebMouseWheelEvent; | 95 using blink::WebMouseWheelEvent; |
| 96 using blink::WebTextDirection; | 96 using blink::WebTextDirection; |
| 97 | 97 |
| 98 namespace content { | 98 namespace content { |
| 99 namespace { | 99 namespace { |
| 100 | 100 |
| 101 // The amount of time after a mouse wheel event is sent to the delegate | |
| 102 // OnUserInteraction method before another mouse wheel event will be sent. This | |
| 103 // interval is used by the Blink EventHandler in its orthogonal heuristic for | |
| 104 // detecting the end of a scroll event (if no event has been seen in 0.1 | |
| 105 // seconds, send an end scroll). | |
| 106 const double kMouseWheelCoalesceIntervalInSeconds = 0.1; | |
| 107 | |
| 108 bool g_check_for_pending_resize_ack = true; | 101 bool g_check_for_pending_resize_ack = true; |
| 109 | 102 |
| 110 // <process id, routing id> | 103 // <process id, routing id> |
| 111 using RenderWidgetHostID = std::pair<int32_t, int32_t>; | 104 using RenderWidgetHostID = std::pair<int32_t, int32_t>; |
| 112 using RoutingIDWidgetMap = | 105 using RoutingIDWidgetMap = |
| 113 base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>; | 106 base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*>; |
| 114 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = | 107 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = |
| 115 LAZY_INSTANCE_INITIALIZER; | 108 LAZY_INSTANCE_INITIALIZER; |
| 116 | 109 |
| 117 // Implements the RenderWidgetHostIterator interface. It keeps a list of | 110 // Implements the RenderWidgetHostIterator interface. It keeps a list of |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 is_in_gesture_scroll_(false), | 204 is_in_gesture_scroll_(false), |
| 212 received_paint_after_load_(false), | 205 received_paint_after_load_(false), |
| 213 next_browser_snapshot_id_(1), | 206 next_browser_snapshot_id_(1), |
| 214 owned_by_render_frame_host_(false), | 207 owned_by_render_frame_host_(false), |
| 215 is_focused_(false), | 208 is_focused_(false), |
| 216 scale_input_to_viewport_(IsUseZoomForDSFEnabled()), | 209 scale_input_to_viewport_(IsUseZoomForDSFEnabled()), |
| 217 hung_renderer_delay_( | 210 hung_renderer_delay_( |
| 218 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), | 211 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)), |
| 219 new_content_rendering_delay_( | 212 new_content_rendering_delay_( |
| 220 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), | 213 base::TimeDelta::FromMilliseconds(kNewContentRenderingDelayMs)), |
| 221 mouse_wheel_coalesce_timer_(new base::ElapsedTimer()), | |
| 222 weak_factory_(this) { | 214 weak_factory_(this) { |
| 223 CHECK(delegate_); | 215 CHECK(delegate_); |
| 224 CHECK_NE(MSG_ROUTING_NONE, routing_id_); | 216 CHECK_NE(MSG_ROUTING_NONE, routing_id_); |
| 225 | 217 |
| 226 std::pair<RoutingIDWidgetMap::iterator, bool> result = | 218 std::pair<RoutingIDWidgetMap::iterator, bool> result = |
| 227 g_routing_id_widget_map.Get().insert(std::make_pair( | 219 g_routing_id_widget_map.Get().insert(std::make_pair( |
| 228 RenderWidgetHostID(process->GetID(), routing_id_), this)); | 220 RenderWidgetHostID(process->GetID(), routing_id_), this)); |
| 229 CHECK(result.second) << "Inserting a duplicate item!"; | 221 CHECK(result.second) << "Inserting a duplicate item!"; |
| 230 process_->AddRoute(routing_id_, this); | 222 process_->AddRoute(routing_id_, this); |
| 231 | 223 |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { | 1885 const blink::WebInputEvent& event, const ui::LatencyInfo& latency_info) { |
| 1894 // Don't ignore touch cancel events, since they may be sent while input | 1886 // Don't ignore touch cancel events, since they may be sent while input |
| 1895 // events are being ignored in order to keep the renderer from getting | 1887 // events are being ignored in order to keep the renderer from getting |
| 1896 // confused about how many touches are active. | 1888 // confused about how many touches are active. |
| 1897 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) | 1889 if (ShouldDropInputEvents() && event.type != WebInputEvent::TouchCancel) |
| 1898 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 1890 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 1899 | 1891 |
| 1900 if (!process_->HasConnection()) | 1892 if (!process_->HasConnection()) |
| 1901 return INPUT_EVENT_ACK_STATE_UNKNOWN; | 1893 return INPUT_EVENT_ACK_STATE_UNKNOWN; |
| 1902 | 1894 |
| 1903 if (delegate_) { | 1895 if (delegate_ && (event.type == WebInputEvent::MouseDown || |
| 1904 if (event.type == WebInputEvent::MouseDown || | 1896 event.type == WebInputEvent::GestureScrollBegin || |
| 1905 event.type == WebInputEvent::GestureTapDown || | 1897 event.type == WebInputEvent::GestureTapDown || |
| 1906 event.type == WebInputEvent::RawKeyDown) { | 1898 event.type == WebInputEvent::RawKeyDown)) { |
| 1907 delegate_->OnUserInteraction(this, event.type); | 1899 delegate_->OnUserInteraction(this, event.type); |
| 1908 } else if (event.type == WebInputEvent::MouseWheel) { | |
| 1909 if (mouse_wheel_coalesce_timer_->Elapsed().InSecondsF() > | |
| 1910 kMouseWheelCoalesceIntervalInSeconds) { | |
| 1911 // TODO(dominickn): once GestureScrollBegin has landed on all platforms, | |
| 1912 // replace this branch and remove. | |
| 1913 delegate_->OnUserInteraction(this, event.type); | |
| 1914 } | |
| 1915 | |
| 1916 mouse_wheel_coalesce_timer_.reset(new base::ElapsedTimer()); | |
| 1917 } | |
| 1918 } | 1900 } |
| 1919 | 1901 |
| 1920 return view_ ? view_->FilterInputEvent(event) | 1902 return view_ ? view_->FilterInputEvent(event) |
| 1921 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1903 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 1922 } | 1904 } |
| 1923 | 1905 |
| 1924 void RenderWidgetHostImpl::IncrementInFlightEventCount() { | 1906 void RenderWidgetHostImpl::IncrementInFlightEventCount() { |
| 1925 increment_in_flight_event_count(); | 1907 increment_in_flight_event_count(); |
| 1926 if (!is_hidden_) | 1908 if (!is_hidden_) |
| 1927 StartHangMonitorTimeout(hung_renderer_delay_); | 1909 StartHangMonitorTimeout(hung_renderer_delay_); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2242 } | 2224 } |
| 2243 | 2225 |
| 2244 #if defined(OS_WIN) | 2226 #if defined(OS_WIN) |
| 2245 gfx::NativeViewAccessible | 2227 gfx::NativeViewAccessible |
| 2246 RenderWidgetHostImpl::GetParentNativeViewAccessible() { | 2228 RenderWidgetHostImpl::GetParentNativeViewAccessible() { |
| 2247 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; | 2229 return delegate_ ? delegate_->GetParentNativeViewAccessible() : NULL; |
| 2248 } | 2230 } |
| 2249 #endif | 2231 #endif |
| 2250 | 2232 |
| 2251 } // namespace content | 2233 } // namespace content |
| OLD | NEW |