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 21 matching lines...) Expand all Loading... | |
32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 32 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
33 #include "content/browser/gpu/gpu_surface_tracker.h" | 33 #include "content/browser/gpu/gpu_surface_tracker.h" |
34 #include "content/browser/renderer_host/dip_util.h" | 34 #include "content/browser/renderer_host/dip_util.h" |
35 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 35 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
36 #include "content/browser/renderer_host/input/input_router_impl.h" | 36 #include "content/browser/renderer_host/input/input_router_impl.h" |
37 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 37 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
38 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 38 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
39 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 39 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
40 #include "content/browser/renderer_host/input/timeout_monitor.h" | 40 #include "content/browser/renderer_host/input/timeout_monitor.h" |
41 #include "content/browser/renderer_host/input/touch_emulator.h" | 41 #include "content/browser/renderer_host/input/touch_emulator.h" |
42 #include "content/browser/renderer_host/overscroll_controller.h" | |
43 #include "content/browser/renderer_host/render_process_host_impl.h" | 42 #include "content/browser/renderer_host/render_process_host_impl.h" |
44 #include "content/browser/renderer_host/render_view_host_impl.h" | 43 #include "content/browser/renderer_host/render_view_host_impl.h" |
45 #include "content/browser/renderer_host/render_widget_helper.h" | 44 #include "content/browser/renderer_host/render_widget_helper.h" |
46 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 45 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
47 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 46 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
48 #include "content/common/accessibility_messages.h" | 47 #include "content/common/accessibility_messages.h" |
49 #include "content/common/content_constants_internal.h" | 48 #include "content/common/content_constants_internal.h" |
50 #include "content/common/cursors/webcursor.h" | 49 #include "content/common/cursors/webcursor.h" |
51 #include "content/common/gpu/gpu_messages.h" | 50 #include "content/common/gpu/gpu_messages.h" |
52 #include "content/common/host_shared_bitmap_manager.h" | 51 #include "content/common/host_shared_bitmap_manager.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 process_->WidgetRestored(); | 225 process_->WidgetRestored(); |
227 | 226 |
228 accessibility_mode_ = | 227 accessibility_mode_ = |
229 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); | 228 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); |
230 | 229 |
231 input_router_.reset(new InputRouterImpl( | 230 input_router_.reset(new InputRouterImpl( |
232 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 231 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
233 | 232 |
234 touch_emulator_.reset(); | 233 touch_emulator_.reset(); |
235 | 234 |
236 #if defined(USE_AURA) | |
237 bool overscroll_enabled = CommandLine::ForCurrentProcess()-> | |
238 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | |
239 SetOverscrollControllerEnabled(overscroll_enabled); | |
240 #endif | |
241 | |
242 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 235 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
243 IsRenderView() ? RenderViewHost::From(this) : NULL); | 236 IsRenderView() ? RenderViewHost::From(this) : NULL); |
244 if (BrowserPluginGuest::IsGuest(rvh) || | 237 if (BrowserPluginGuest::IsGuest(rvh) || |
245 !CommandLine::ForCurrentProcess()->HasSwitch( | 238 !CommandLine::ForCurrentProcess()->HasSwitch( |
246 switches::kDisableHangMonitor)) { | 239 switches::kDisableHangMonitor)) { |
247 hang_monitor_timeout_.reset(new TimeoutMonitor( | 240 hang_monitor_timeout_.reset(new TimeoutMonitor( |
248 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, | 241 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, |
249 weak_factory_.GetWeakPtr()))); | 242 weak_factory_.GetWeakPtr()))); |
250 } | 243 } |
251 } | 244 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 | 380 |
388 last_view_screen_rect_ = view_->GetViewBounds(); | 381 last_view_screen_rect_ = view_->GetViewBounds(); |
389 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); | 382 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); |
390 Send(new ViewMsg_UpdateScreenRects( | 383 Send(new ViewMsg_UpdateScreenRects( |
391 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); | 384 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); |
392 if (delegate_) | 385 if (delegate_) |
393 delegate_->DidSendScreenRects(this); | 386 delegate_->DidSendScreenRects(this); |
394 waiting_for_screen_rects_ack_ = true; | 387 waiting_for_screen_rects_ack_ = true; |
395 } | 388 } |
396 | 389 |
397 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { | |
398 if (!enabled) | |
399 overscroll_controller_.reset(); | |
400 else if (!overscroll_controller_) | |
401 overscroll_controller_.reset(new OverscrollController()); | |
402 } | |
403 | |
404 void RenderWidgetHostImpl::SuppressNextCharEvents() { | 390 void RenderWidgetHostImpl::SuppressNextCharEvents() { |
405 suppress_next_char_events_ = true; | 391 suppress_next_char_events_ = true; |
406 } | 392 } |
407 | 393 |
408 void RenderWidgetHostImpl::FlushInput() { | 394 void RenderWidgetHostImpl::FlushInput() { |
409 input_router_->Flush(); | 395 input_router_->Flush(); |
410 if (synthetic_gesture_controller_) | 396 if (synthetic_gesture_controller_) |
411 synthetic_gesture_controller_->Flush(base::TimeTicks::Now()); | 397 synthetic_gesture_controller_->Flush(base::TimeTicks::Now()); |
412 } | 398 } |
413 | 399 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 Send(new InputMsg_SetFocus(routing_id_, true)); | 630 Send(new InputMsg_SetFocus(routing_id_, true)); |
645 } | 631 } |
646 | 632 |
647 void RenderWidgetHostImpl::Blur() { | 633 void RenderWidgetHostImpl::Blur() { |
648 // If there is a pending mouse lock request, we don't want to reject it at | 634 // If there is a pending mouse lock request, we don't want to reject it at |
649 // this point. The user can switch focus back to this view and approve the | 635 // this point. The user can switch focus back to this view and approve the |
650 // request later. | 636 // request later. |
651 if (IsMouseLocked()) | 637 if (IsMouseLocked()) |
652 view_->UnlockMouse(); | 638 view_->UnlockMouse(); |
653 | 639 |
654 // If there is a pending overscroll, then that should be cancelled. | |
655 if (overscroll_controller_) | |
656 overscroll_controller_->Cancel(); | |
657 | |
658 if (touch_emulator_) | 640 if (touch_emulator_) |
659 touch_emulator_->CancelTouch(); | 641 touch_emulator_->CancelTouch(); |
660 | 642 |
661 Send(new InputMsg_SetFocus(routing_id_, false)); | 643 Send(new InputMsg_SetFocus(routing_id_, false)); |
662 } | 644 } |
663 | 645 |
664 void RenderWidgetHostImpl::LostCapture() { | 646 void RenderWidgetHostImpl::LostCapture() { |
665 if (touch_emulator_) | 647 if (touch_emulator_) |
666 touch_emulator_->CancelTouch(); | 648 touch_emulator_->CancelTouch(); |
667 | 649 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 // Clearing this flag causes us to re-create the renderer when recovering | 1186 // Clearing this flag causes us to re-create the renderer when recovering |
1205 // from a crashed renderer. | 1187 // from a crashed renderer. |
1206 renderer_initialized_ = false; | 1188 renderer_initialized_ = false; |
1207 | 1189 |
1208 waiting_for_screen_rects_ack_ = false; | 1190 waiting_for_screen_rects_ack_ = false; |
1209 | 1191 |
1210 // Reset to ensure that input routing works with a new renderer. | 1192 // Reset to ensure that input routing works with a new renderer. |
1211 input_router_.reset(new InputRouterImpl( | 1193 input_router_.reset(new InputRouterImpl( |
1212 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 1194 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
1213 | 1195 |
1214 if (overscroll_controller_) | 1196 // Must reset these to ensure that keyboard events work with a new renderer. |
1215 overscroll_controller_->Reset(); | |
1216 | |
1217 // Must reset these to ensure that keyboard events work with a new renderer. | |
1218 suppress_next_char_events_ = false; | 1197 suppress_next_char_events_ = false; |
1219 | 1198 |
1220 // Reset some fields in preparation for recovering from a crash. | 1199 // Reset some fields in preparation for recovering from a crash. |
1221 ResetSizeAndRepaintPendingFlags(); | 1200 ResetSizeAndRepaintPendingFlags(); |
1222 current_size_.SetSize(0, 0); | 1201 current_size_.SetSize(0, 0); |
1223 is_hidden_ = false; | 1202 is_hidden_ = false; |
1224 | 1203 |
1225 // Reset this to ensure the hung renderer mechanism is working properly. | 1204 // Reset this to ensure the hung renderer mechanism is working properly. |
1226 in_flight_event_count_ = 0; | 1205 in_flight_event_count_ = 0; |
1227 | 1206 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1803 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 1782 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
1804 } | 1783 } |
1805 | 1784 |
1806 void RenderWidgetHostImpl::IncrementInFlightEventCount() { | 1785 void RenderWidgetHostImpl::IncrementInFlightEventCount() { |
1807 StartHangMonitorTimeout( | 1786 StartHangMonitorTimeout( |
1808 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 1787 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
1809 increment_in_flight_event_count(); | 1788 increment_in_flight_event_count(); |
1810 } | 1789 } |
1811 | 1790 |
1812 void RenderWidgetHostImpl::DecrementInFlightEventCount() { | 1791 void RenderWidgetHostImpl::DecrementInFlightEventCount() { |
1813 DCHECK(in_flight_event_count_ >= 0); | 1792 DCHECK(in_flight_event_count_ >= 0); |
sadrul
2014/06/02 20:56:00
DCHECK_GE
| |
1814 // Cancel pending hung renderer checks since the renderer is responsive. | 1793 // Cancel pending hung renderer checks since the renderer is responsive. |
1815 if (decrement_in_flight_event_count() <= 0) | 1794 if (decrement_in_flight_event_count() <= 0) |
1816 StopHangMonitorTimeout(); | 1795 StopHangMonitorTimeout(); |
1817 } | 1796 } |
1818 | 1797 |
1819 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { | 1798 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { |
1820 has_touch_handler_ = has_handlers; | 1799 has_touch_handler_ = has_handlers; |
1821 } | 1800 } |
1822 | 1801 |
1823 OverscrollController* RenderWidgetHostImpl::GetOverscrollController() const { | |
1824 return overscroll_controller_.get(); | |
1825 } | |
1826 | |
1827 void RenderWidgetHostImpl::DidFlush() { | 1802 void RenderWidgetHostImpl::DidFlush() { |
1828 if (synthetic_gesture_controller_) | 1803 if (synthetic_gesture_controller_) |
1829 synthetic_gesture_controller_->OnDidFlushInput(); | 1804 synthetic_gesture_controller_->OnDidFlushInput(); |
1830 if (view_) | 1805 if (view_) |
1831 view_->OnDidFlushInput(); | 1806 view_->OnDidFlushInput(); |
1832 } | 1807 } |
1833 | 1808 |
1834 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { | 1809 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { |
1835 if (view_) | 1810 if (view_) |
1836 view_->DidOverscroll(params); | 1811 view_->DidOverscroll(params); |
(...skipping 25 matching lines...) Expand all Loading... | |
1862 InputEventAckState ack_result) { | 1837 InputEventAckState ack_result) { |
1863 if (!wheel_event.latency.FindLatency( | 1838 if (!wheel_event.latency.FindLatency( |
1864 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | 1839 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { |
1865 // MouseWheelEvent latency ends when it is acked but does not cause any | 1840 // MouseWheelEvent latency ends when it is acked but does not cause any |
1866 // rendering scheduled. | 1841 // rendering scheduled. |
1867 ui::LatencyInfo latency = wheel_event.latency; | 1842 ui::LatencyInfo latency = wheel_event.latency; |
1868 latency.AddLatencyNumber( | 1843 latency.AddLatencyNumber( |
1869 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); | 1844 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); |
1870 } | 1845 } |
1871 | 1846 |
1872 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 1847 if (!is_hidden() && view_) { |
1873 if (!processed && !is_hidden() && view_) { | 1848 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED && |
1874 if (!delegate_->HandleWheelEvent(wheel_event.event)) | 1849 delegate_->HandleWheelEvent(wheel_event.event)) { |
1875 view_->UnhandledWheelEvent(wheel_event.event); | 1850 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED; |
1851 } | |
1852 view_->WheelEventAck(wheel_event.event, ack_result); | |
1876 } | 1853 } |
1877 } | 1854 } |
1878 | 1855 |
1879 void RenderWidgetHostImpl::OnGestureEventAck( | 1856 void RenderWidgetHostImpl::OnGestureEventAck( |
1880 const GestureEventWithLatencyInfo& event, | 1857 const GestureEventWithLatencyInfo& event, |
1881 InputEventAckState ack_result) { | 1858 InputEventAckState ack_result) { |
1882 if (!event.latency.FindLatency( | 1859 if (!event.latency.FindLatency( |
1883 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | 1860 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { |
1884 // GestureEvent latency ends when it is acked but does not cause any | 1861 // GestureEvent latency ends when it is acked but does not cause any |
1885 // rendering scheduled. | 1862 // rendering scheduled. |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2327 } | 2304 } |
2328 } | 2305 } |
2329 | 2306 |
2330 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2307 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
2331 if (view_) | 2308 if (view_) |
2332 return view_->PreferredReadbackFormat(); | 2309 return view_->PreferredReadbackFormat(); |
2333 return SkBitmap::kARGB_8888_Config; | 2310 return SkBitmap::kARGB_8888_Config; |
2334 } | 2311 } |
2335 | 2312 |
2336 } // namespace content | 2313 } // namespace content |
OLD | NEW |