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