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

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

Issue 660663002: Clear pending events upon main frame navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates Created 6 years, 1 month 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 in_flight_event_count_(0), 179 in_flight_event_count_(0),
180 in_get_backing_store_(false), 180 in_get_backing_store_(false),
181 ignore_input_events_(false), 181 ignore_input_events_(false),
182 input_method_active_(false), 182 input_method_active_(false),
183 text_direction_updated_(false), 183 text_direction_updated_(false),
184 text_direction_(blink::WebTextDirectionLeftToRight), 184 text_direction_(blink::WebTextDirectionLeftToRight),
185 text_direction_canceled_(false), 185 text_direction_canceled_(false),
186 suppress_next_char_events_(false), 186 suppress_next_char_events_(false),
187 pending_mouse_lock_request_(false), 187 pending_mouse_lock_request_(false),
188 allow_privileged_mouse_lock_(false), 188 allow_privileged_mouse_lock_(false),
189 has_touch_handler_(false),
190 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32), 189 last_input_number_(static_cast<int64>(GetProcess()->GetID()) << 32),
191 next_browser_snapshot_id_(1), 190 next_browser_snapshot_id_(1),
192 browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize), 191 browser_composite_latency_history_(kBrowserCompositeLatencyHistorySize),
193 weak_factory_(this) { 192 weak_factory_(this) {
194 CHECK(delegate_); 193 CHECK(delegate_);
195 if (routing_id_ == MSG_ROUTING_NONE) { 194 if (routing_id_ == MSG_ROUTING_NONE) {
196 routing_id_ = process_->GetNextRoutingID(); 195 routing_id_ = process_->GetNextRoutingID();
197 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( 196 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer(
198 process_->GetID(), 197 process_->GetID(),
199 routing_id_); 198 routing_id_);
(...skipping 15 matching lines...) Expand all
215 g_routing_id_widget_map.Get().insert(std::make_pair( 214 g_routing_id_widget_map.Get().insert(std::make_pair(
216 RenderWidgetHostID(process->GetID(), routing_id_), this)); 215 RenderWidgetHostID(process->GetID(), routing_id_), this));
217 CHECK(result.second) << "Inserting a duplicate item!"; 216 CHECK(result.second) << "Inserting a duplicate item!";
218 process_->AddRoute(routing_id_, this); 217 process_->AddRoute(routing_id_, this);
219 218
220 // If we're initially visible, tell the process host that we're alive. 219 // If we're initially visible, tell the process host that we're alive.
221 // Otherwise we'll notify the process host when we are first shown. 220 // Otherwise we'll notify the process host when we are first shown.
222 if (!hidden) 221 if (!hidden)
223 process_->WidgetRestored(); 222 process_->WidgetRestored();
224 223
225 input_router_.reset(new InputRouterImpl( 224 ResetInputRouter();
226 process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
227
228 touch_emulator_.reset();
229 225
230 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 226 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
231 IsRenderView() ? RenderViewHost::From(this) : NULL); 227 IsRenderView() ? RenderViewHost::From(this) : NULL);
232 if (BrowserPluginGuest::IsGuest(rvh) || 228 if (BrowserPluginGuest::IsGuest(rvh) ||
233 !base::CommandLine::ForCurrentProcess()->HasSwitch( 229 !base::CommandLine::ForCurrentProcess()->HasSwitch(
234 switches::kDisableHangMonitor)) { 230 switches::kDisableHangMonitor)) {
235 hang_monitor_timeout_.reset(new TimeoutMonitor( 231 hang_monitor_timeout_.reset(new TimeoutMonitor(
236 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive, 232 base::Bind(&RenderWidgetHostImpl::RendererIsUnresponsive,
237 weak_factory_.GetWeakPtr()))); 233 weak_factory_.GetWeakPtr())));
238 } 234 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); 380 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_));
385 if (delegate_) 381 if (delegate_)
386 delegate_->DidSendScreenRects(this); 382 delegate_->DidSendScreenRects(this);
387 waiting_for_screen_rects_ack_ = true; 383 waiting_for_screen_rects_ack_ = true;
388 } 384 }
389 385
390 void RenderWidgetHostImpl::SuppressNextCharEvents() { 386 void RenderWidgetHostImpl::SuppressNextCharEvents() {
391 suppress_next_char_events_ = true; 387 suppress_next_char_events_ = true;
392 } 388 }
393 389
390 void RenderWidgetHostImpl::ResetPendingInput() {
391 if (input_router_->HasPendingEvents())
392 ResetInputRouter();
393 }
394
394 void RenderWidgetHostImpl::FlushInput() { 395 void RenderWidgetHostImpl::FlushInput() {
395 input_router_->Flush(); 396 input_router_->RequestFlushedNotification();
396 if (synthetic_gesture_controller_) 397 if (synthetic_gesture_controller_)
397 synthetic_gesture_controller_->Flush(base::TimeTicks::Now()); 398 synthetic_gesture_controller_->Flush(base::TimeTicks::Now());
398 } 399 }
399 400
400 void RenderWidgetHostImpl::SetNeedsFlush() { 401 void RenderWidgetHostImpl::SetNeedsFlushInput() {
401 if (view_) 402 if (view_)
402 view_->OnSetNeedsFlushInput(); 403 view_->OnSetNeedsFlushInput();
403 } 404 }
404 405
405 void RenderWidgetHostImpl::Init() { 406 void RenderWidgetHostImpl::Init() {
406 DCHECK(process_->HasConnection()); 407 DCHECK(process_->HasConnection());
407 408
408 renderer_initialized_ = true; 409 renderer_initialized_ = true;
409 410
410 GpuSurfaceTracker::Get()->SetSurfaceHandle( 411 GpuSurfaceTracker::Get()->SetSurfaceHandle(
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 void RenderWidgetHostImpl::ForwardWheelEvent( 890 void RenderWidgetHostImpl::ForwardWheelEvent(
890 const WebMouseWheelEvent& wheel_event) { 891 const WebMouseWheelEvent& wheel_event) {
891 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo()); 892 ForwardWheelEventWithLatencyInfo(wheel_event, ui::LatencyInfo());
892 } 893 }
893 894
894 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( 895 void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
895 const blink::WebMouseWheelEvent& wheel_event, 896 const blink::WebMouseWheelEvent& wheel_event,
896 const ui::LatencyInfo& ui_latency) { 897 const ui::LatencyInfo& ui_latency) {
897 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent"); 898 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent");
898 899
900 if (IgnoreInputEvents())
901 return;
902
899 ui::LatencyInfo::InputCoordinate logical_coordinate(wheel_event.x, 903 ui::LatencyInfo::InputCoordinate logical_coordinate(wheel_event.x,
900 wheel_event.y); 904 wheel_event.y);
901 905
902 ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist( 906 ui::LatencyInfo latency_info = CreateInputEventLatencyInfoIfNotExist(
903 &ui_latency, wheel_event.type, &logical_coordinate, 1); 907 &ui_latency, wheel_event.type, &logical_coordinate, 1);
904 908
905 if (IgnoreInputEvents())
906 return;
907
908 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event)) 909 if (touch_emulator_ && touch_emulator_->HandleMouseWheelEvent(wheel_event))
909 return; 910 return;
910 911
911 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event, 912 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo(wheel_event,
912 latency_info)); 913 latency_info));
913 } 914 }
914 915
915 void RenderWidgetHostImpl::ForwardGestureEvent( 916 void RenderWidgetHostImpl::ForwardGestureEvent(
916 const blink::WebGestureEvent& gesture_event) { 917 const blink::WebGestureEvent& gesture_event) {
917 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo()); 918 ForwardGestureEventWithLatencyInfo(gesture_event, ui::LatencyInfo());
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 gfx::GLSurfaceHandle()); 1281 gfx::GLSurfaceHandle());
1281 view_->RenderProcessGone(status, exit_code); 1282 view_->RenderProcessGone(status, exit_code);
1282 view_ = NULL; // The View should be deleted by RenderProcessGone. 1283 view_ = NULL; // The View should be deleted by RenderProcessGone.
1283 view_weak_.reset(); 1284 view_weak_.reset();
1284 } 1285 }
1285 1286
1286 // Reconstruct the input router to ensure that it has fresh state for a new 1287 // Reconstruct the input router to ensure that it has fresh state for a new
1287 // renderer. Otherwise it may be stuck waiting for the old renderer to ack an 1288 // renderer. Otherwise it may be stuck waiting for the old renderer to ack an
1288 // event. (In particular, the above call to view_->RenderProcessGone will 1289 // event. (In particular, the above call to view_->RenderProcessGone will
1289 // destroy the aura window, which may dispatch a synthetic mouse move.) 1290 // destroy the aura window, which may dispatch a synthetic mouse move.)
1290 input_router_.reset(new InputRouterImpl( 1291 ResetInputRouter();
1291 process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
1292 1292
1293 synthetic_gesture_controller_.reset(); 1293 synthetic_gesture_controller_.reset();
1294 } 1294 }
1295 1295
1296 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) { 1296 void RenderWidgetHostImpl::UpdateTextDirection(WebTextDirection direction) {
1297 text_direction_updated_ = true; 1297 text_direction_updated_ = true;
1298 text_direction_ = direction; 1298 text_direction_ = direction;
1299 } 1299 }
1300 1300
1301 void RenderWidgetHostImpl::CancelUpdateTextDirection() { 1301 void RenderWidgetHostImpl::CancelUpdateTextDirection() {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 NotifyRendererUnresponsive(); 1409 NotifyRendererUnresponsive();
1410 } 1410 }
1411 1411
1412 void RenderWidgetHostImpl::RendererIsResponsive() { 1412 void RenderWidgetHostImpl::RendererIsResponsive() {
1413 if (is_unresponsive_) { 1413 if (is_unresponsive_) {
1414 is_unresponsive_ = false; 1414 is_unresponsive_ = false;
1415 NotifyRendererResponsive(); 1415 NotifyRendererResponsive();
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 void RenderWidgetHostImpl::ResetInputRouter() {
1420 base::AutoReset<bool> reset_ignore_input_events(&ignore_input_events_, true);
1421 input_router_.reset(new InputRouterImpl(
1422 process_, this, this, routing_id_, GetInputRouterConfigForPlatform()));
1423 }
1424
1419 void RenderWidgetHostImpl::OnRenderViewReady() { 1425 void RenderWidgetHostImpl::OnRenderViewReady() {
1420 SendScreenRects(); 1426 SendScreenRects();
1421 WasResized(); 1427 WasResized();
1422 } 1428 }
1423 1429
1424 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { 1430 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) {
1425 // TODO(evanm): This synchronously ends up calling "delete this". 1431 // TODO(evanm): This synchronously ends up calling "delete this".
1426 // Is that really what we want in response to this message? I'm matching 1432 // Is that really what we want in response to this message? I'm matching
1427 // previous behavior of the code here. 1433 // previous behavior of the code here.
1428 Destroy(); 1434 Destroy();
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 DCHECK_GE(in_flight_event_count_, 0); 1856 DCHECK_GE(in_flight_event_count_, 0);
1851 if (decrement_in_flight_event_count() <= 0) { 1857 if (decrement_in_flight_event_count() <= 0) {
1852 // Cancel pending hung renderer checks since the renderer is responsive. 1858 // Cancel pending hung renderer checks since the renderer is responsive.
1853 StopHangMonitorTimeout(); 1859 StopHangMonitorTimeout();
1854 } else { 1860 } else {
1855 // The renderer is responsive, but there are in-flight events to wait for. 1861 // The renderer is responsive, but there are in-flight events to wait for.
1856 RestartHangMonitorTimeout(); 1862 RestartHangMonitorTimeout();
1857 } 1863 }
1858 } 1864 }
1859 1865
1860 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) {
1861 has_touch_handler_ = has_handlers;
1862 }
1863
1864 void RenderWidgetHostImpl::DidFlush() { 1866 void RenderWidgetHostImpl::DidFlush() {
1865 if (synthetic_gesture_controller_) 1867 if (synthetic_gesture_controller_)
1866 synthetic_gesture_controller_->OnDidFlushInput(); 1868 synthetic_gesture_controller_->OnDidFlushInput();
1867 if (view_)
1868 view_->OnDidFlushInput();
1869 } 1869 }
1870 1870
1871 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) { 1871 void RenderWidgetHostImpl::DidOverscroll(const DidOverscrollParams& params) {
1872 if (view_) 1872 if (view_)
1873 view_->DidOverscroll(params); 1873 view_->DidOverscroll(params);
1874 } 1874 }
1875 1875
1876 void RenderWidgetHostImpl::OnKeyboardEventAck( 1876 void RenderWidgetHostImpl::OnKeyboardEventAck(
1877 const NativeWebKeyboardEvent& event, 1877 const NativeWebKeyboardEvent& event,
1878 InputEventAckState ack_result) { 1878 InputEventAckState ack_result) {
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 } 2421 }
2422 #endif 2422 #endif
2423 2423
2424 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { 2424 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() {
2425 if (view_) 2425 if (view_)
2426 return view_->PreferredReadbackFormat(); 2426 return view_->PreferredReadbackFormat();
2427 return kN32_SkColorType; 2427 return kN32_SkColorType;
2428 } 2428 }
2429 2429
2430 } // namespace content 2430 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698