Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 291003002: Move OverscrollController to RenderWidgetHostViewAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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
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
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::DidOverscroll(const DidOverscrollParams& params) { 1806 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) {
1832 if (view_) 1807 if (view_)
1833 view_->DidOverscroll(params); 1808 view_->DidOverscroll(params);
(...skipping 25 matching lines...) Expand all
1859 InputEventAckState ack_result) { 1834 InputEventAckState ack_result) {
1860 if (!wheel_event.latency.FindLatency( 1835 if (!wheel_event.latency.FindLatency(
1861 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { 1836 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
1862 // MouseWheelEvent latency ends when it is acked but does not cause any 1837 // MouseWheelEvent latency ends when it is acked but does not cause any
1863 // rendering scheduled. 1838 // rendering scheduled.
1864 ui::LatencyInfo latency = wheel_event.latency; 1839 ui::LatencyInfo latency = wheel_event.latency;
1865 latency.AddLatencyNumber( 1840 latency.AddLatencyNumber(
1866 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0); 1841 ui::INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, 0, 0);
1867 } 1842 }
1868 1843
1869 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 1844 if (!is_hidden() && view_) {
1870 if (!processed && !is_hidden() && view_) { 1845 if (ack_result != INPUT_EVENT_ACK_STATE_CONSUMED &&
1871 if (!delegate_->HandleWheelEvent(wheel_event.event)) 1846 delegate_->HandleWheelEvent(wheel_event.event)) {
1872 view_->UnhandledWheelEvent(wheel_event.event); 1847 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED;
1848 }
1849 view_->WheelEventAck(wheel_event.event, ack_result);
1873 } 1850 }
1874 } 1851 }
1875 1852
1876 void RenderWidgetHostImpl::OnGestureEventAck( 1853 void RenderWidgetHostImpl::OnGestureEventAck(
1877 const GestureEventWithLatencyInfo& event, 1854 const GestureEventWithLatencyInfo& event,
1878 InputEventAckState ack_result) { 1855 InputEventAckState ack_result) {
1879 if (!event.latency.FindLatency( 1856 if (!event.latency.FindLatency(
1880 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { 1857 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
1881 // GestureEvent latency ends when it is acked but does not cause any 1858 // GestureEvent latency ends when it is acked but does not cause any
1882 // rendering scheduled. 1859 // rendering scheduled.
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2320 } 2297 }
2321 } 2298 }
2322 2299
2323 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() { 2300 SkBitmap::Config RenderWidgetHostImpl::PreferredReadbackFormat() {
2324 if (view_) 2301 if (view_)
2325 return view_->PreferredReadbackFormat(); 2302 return view_->PreferredReadbackFormat();
2326 return SkBitmap::kARGB_8888_Config; 2303 return SkBitmap::kARGB_8888_Config;
2327 } 2304 }
2328 2305
2329 } // namespace content 2306 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698