| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 Send(new InputMsg_SetFocus(routing_id_, true)); | 627 Send(new InputMsg_SetFocus(routing_id_, true)); |
| 642 } | 628 } |
| 643 | 629 |
| 644 void RenderWidgetHostImpl::Blur() { | 630 void RenderWidgetHostImpl::Blur() { |
| 645 // If there is a pending mouse lock request, we don't want to reject it at | 631 // If there is a pending mouse lock request, we don't want to reject it at |
| 646 // this point. The user can switch focus back to this view and approve the | 632 // this point. The user can switch focus back to this view and approve the |
| 647 // request later. | 633 // request later. |
| 648 if (IsMouseLocked()) | 634 if (IsMouseLocked()) |
| 649 view_->UnlockMouse(); | 635 view_->UnlockMouse(); |
| 650 | 636 |
| 651 // If there is a pending overscroll, then that should be cancelled. | |
| 652 if (overscroll_controller_) | |
| 653 overscroll_controller_->Cancel(); | |
| 654 | |
| 655 if (touch_emulator_) | 637 if (touch_emulator_) |
| 656 touch_emulator_->CancelTouch(); | 638 touch_emulator_->CancelTouch(); |
| 657 | 639 |
| 658 Send(new InputMsg_SetFocus(routing_id_, false)); | 640 Send(new InputMsg_SetFocus(routing_id_, false)); |
| 659 } | 641 } |
| 660 | 642 |
| 661 void RenderWidgetHostImpl::LostCapture() { | 643 void RenderWidgetHostImpl::LostCapture() { |
| 662 if (touch_emulator_) | 644 if (touch_emulator_) |
| 663 touch_emulator_->CancelTouch(); | 645 touch_emulator_->CancelTouch(); |
| 664 | 646 |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 // Clearing this flag causes us to re-create the renderer when recovering | 1183 // Clearing this flag causes us to re-create the renderer when recovering |
| 1202 // from a crashed renderer. | 1184 // from a crashed renderer. |
| 1203 renderer_initialized_ = false; | 1185 renderer_initialized_ = false; |
| 1204 | 1186 |
| 1205 waiting_for_screen_rects_ack_ = false; | 1187 waiting_for_screen_rects_ack_ = false; |
| 1206 | 1188 |
| 1207 // Reset to ensure that input routing works with a new renderer. | 1189 // Reset to ensure that input routing works with a new renderer. |
| 1208 input_router_.reset(new InputRouterImpl( | 1190 input_router_.reset(new InputRouterImpl( |
| 1209 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); | 1191 process_, this, this, routing_id_, GetInputRouterConfigForPlatform())); |
| 1210 | 1192 |
| 1211 if (overscroll_controller_) | 1193 // Must reset these to ensure that keyboard events work with a new renderer. |
| 1212 overscroll_controller_->Reset(); | |
| 1213 | |
| 1214 // Must reset these to ensure that keyboard events work with a new renderer. | |
| 1215 suppress_next_char_events_ = false; | 1194 suppress_next_char_events_ = false; |
| 1216 | 1195 |
| 1217 // Reset some fields in preparation for recovering from a crash. | 1196 // Reset some fields in preparation for recovering from a crash. |
| 1218 ResetSizeAndRepaintPendingFlags(); | 1197 ResetSizeAndRepaintPendingFlags(); |
| 1219 current_size_.SetSize(0, 0); | 1198 current_size_.SetSize(0, 0); |
| 1220 is_hidden_ = false; | 1199 is_hidden_ = false; |
| 1221 | 1200 |
| 1222 // Reset this to ensure the hung renderer mechanism is working properly. | 1201 // Reset this to ensure the hung renderer mechanism is working properly. |
| 1223 in_flight_event_count_ = 0; | 1202 in_flight_event_count_ = 0; |
| 1224 | 1203 |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 DCHECK(in_flight_event_count_ >= 0); | 1789 DCHECK(in_flight_event_count_ >= 0); |
| 1811 // Cancel pending hung renderer checks since the renderer is responsive. | 1790 // Cancel pending hung renderer checks since the renderer is responsive. |
| 1812 if (decrement_in_flight_event_count() <= 0) | 1791 if (decrement_in_flight_event_count() <= 0) |
| 1813 StopHangMonitorTimeout(); | 1792 StopHangMonitorTimeout(); |
| 1814 } | 1793 } |
| 1815 | 1794 |
| 1816 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { | 1795 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { |
| 1817 has_touch_handler_ = has_handlers; | 1796 has_touch_handler_ = has_handlers; |
| 1818 } | 1797 } |
| 1819 | 1798 |
| 1820 OverscrollController* RenderWidgetHostImpl::GetOverscrollController() const { | |
| 1821 return overscroll_controller_.get(); | |
| 1822 } | |
| 1823 | |
| 1824 void RenderWidgetHostImpl::DidFlush() { | 1799 void RenderWidgetHostImpl::DidFlush() { |
| 1825 if (synthetic_gesture_controller_) | 1800 if (synthetic_gesture_controller_) |
| 1826 synthetic_gesture_controller_->OnDidFlushInput(); | 1801 synthetic_gesture_controller_->OnDidFlushInput(); |
| 1827 if (view_) | 1802 if (view_) |
| 1828 view_->OnDidFlushInput(); | 1803 view_->OnDidFlushInput(); |
| 1829 } | 1804 } |
| 1830 | 1805 |
| 1831 void RenderWidgetHostImpl::OnKeyboardEventAck( | 1806 void RenderWidgetHostImpl::OnKeyboardEventAck( |
| 1832 const NativeWebKeyboardEvent& event, | 1807 const NativeWebKeyboardEvent& event, |
| 1833 InputEventAckState ack_result) { | 1808 InputEventAckState ack_result) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1854 InputEventAckState ack_result) { | 1829 InputEventAckState ack_result) { |
| 1855 if (!wheel_event.latency.FindLatency( | 1830 if (!wheel_event.latency.FindLatency( |
| 1856 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | 1831 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { |
| 1857 // MouseWheelEvent latency ends when it is acked but does not cause any | 1832 // MouseWheelEvent latency ends when it is acked but does not cause any |
| 1858 // rendering scheduled. | 1833 // rendering scheduled. |
| 1859 ui::LatencyInfo latency = wheel_event.latency; | 1834 ui::LatencyInfo latency = wheel_event.latency; |
| 1860 latency.AddLatencyNumber( | 1835 latency.AddLatencyNumber( |
| 1861 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); | 1836 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); |
| 1862 } | 1837 } |
| 1863 | 1838 |
| 1864 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); | 1839 if (!is_hidden() && view_) { |
| 1865 if (!processed && !is_hidden() && view_) { | 1840 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED && |
| 1866 if (!delegate_->HandleWheelEvent(wheel_event.event)) | 1841 delegate_->HandleWheelEvent(wheel_event.event)) { |
| 1867 view_->UnhandledWheelEvent(wheel_event.event); | 1842 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED; |
| 1843 } |
| 1844 view_->WheelEventAck(wheel_event.event, ack_result); |
| 1868 } | 1845 } |
| 1869 } | 1846 } |
| 1870 | 1847 |
| 1871 void RenderWidgetHostImpl::OnGestureEventAck( | 1848 void RenderWidgetHostImpl::OnGestureEventAck( |
| 1872 const GestureEventWithLatencyInfo& event, | 1849 const GestureEventWithLatencyInfo& event, |
| 1873 InputEventAckState ack_result) { | 1850 InputEventAckState ack_result) { |
| 1874 if (!event.latency.FindLatency( | 1851 if (!event.latency.FindLatency( |
| 1875 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | 1852 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { |
| 1876 // GestureEvent latency ends when it is acked but does not cause any | 1853 // GestureEvent latency ends when it is acked but does not cause any |
| 1877 // rendering scheduled. | 1854 // rendering scheduled. |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 } | 2292 } |
| 2316 } | 2293 } |
| 2317 | 2294 |
| 2318 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { | 2295 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2319 if (view_) | 2296 if (view_) |
| 2320 return view_->PreferredReadbackFormat(); | 2297 return view_->PreferredReadbackFormat(); |
| 2321 return SkBitmap::kARGB_8888_Config; | 2298 return SkBitmap::kARGB_8888_Config; |
| 2322 } | 2299 } |
| 2323 | 2300 |
| 2324 } // namespace content | 2301 } // namespace content |
| OLD | NEW |