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 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (!view_) | 482 if (!view_) |
483 return; | 483 return; |
484 | 484 |
485 last_view_screen_rect_ = view_->GetViewBounds(); | 485 last_view_screen_rect_ = view_->GetViewBounds(); |
486 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); | 486 last_window_screen_rect_ = view_->GetBoundsInRootWindow(); |
487 Send(new ViewMsg_UpdateScreenRects( | 487 Send(new ViewMsg_UpdateScreenRects( |
488 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); | 488 GetRoutingID(), last_view_screen_rect_, last_window_screen_rect_)); |
489 waiting_for_screen_rects_ack_ = true; | 489 waiting_for_screen_rects_ack_ = true; |
490 } | 490 } |
491 | 491 |
492 void RenderWidgetHostImpl::FlushInput() { | 492 void RenderWidgetHostImpl::OnBeginFrame() { |
493 input_router_->RequestNotificationWhenFlushed(); | 493 if (begin_frame_callback_) |
494 if (synthetic_gesture_controller_) | 494 std::move(begin_frame_callback_).Run(); |
495 synthetic_gesture_controller_->Flush(base::TimeTicks::Now()); | |
496 } | |
497 | |
498 void RenderWidgetHostImpl::SetNeedsFlush() { | |
499 if (view_) | |
500 view_->OnSetNeedsFlushInput(); | |
501 } | 495 } |
502 | 496 |
503 void RenderWidgetHostImpl::Init() { | 497 void RenderWidgetHostImpl::Init() { |
504 DCHECK(process_->HasConnection()); | 498 DCHECK(process_->HasConnection()); |
505 | 499 |
506 renderer_initialized_ = true; | 500 renderer_initialized_ = true; |
507 | 501 |
508 SendScreenRects(); | 502 SendScreenRects(); |
509 WasResized(); | 503 WasResized(); |
510 | 504 |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 Send( | 1303 Send( |
1310 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands)); | 1304 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands)); |
1311 } | 1305 } |
1312 input_router_->SendKeyboardEvent(key_event_with_latency); | 1306 input_router_->SendKeyboardEvent(key_event_with_latency); |
1313 } | 1307 } |
1314 | 1308 |
1315 void RenderWidgetHostImpl::QueueSyntheticGesture( | 1309 void RenderWidgetHostImpl::QueueSyntheticGesture( |
1316 std::unique_ptr<SyntheticGesture> synthetic_gesture, | 1310 std::unique_ptr<SyntheticGesture> synthetic_gesture, |
1317 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { | 1311 const base::Callback<void(SyntheticGesture::Result)>& on_complete) { |
1318 if (!synthetic_gesture_controller_ && view_) { | 1312 if (!synthetic_gesture_controller_ && view_) { |
1319 synthetic_gesture_controller_.reset( | 1313 synthetic_gesture_controller_ = |
1320 new SyntheticGestureController(view_->CreateSyntheticGestureTarget())); | 1314 base::MakeUnique<SyntheticGestureController>( |
| 1315 view_->CreateSyntheticGestureTarget(), |
| 1316 base::Bind( |
| 1317 &RenderWidgetHostImpl::RequestBeginFrameForSynthesizedInput, |
| 1318 base::Unretained(this))); |
1321 } | 1319 } |
1322 if (synthetic_gesture_controller_) { | 1320 if (synthetic_gesture_controller_) { |
1323 synthetic_gesture_controller_->QueueSyntheticGesture( | 1321 synthetic_gesture_controller_->QueueSyntheticGesture( |
1324 std::move(synthetic_gesture), on_complete); | 1322 std::move(synthetic_gesture), on_complete); |
1325 } | 1323 } |
1326 } | 1324 } |
1327 | 1325 |
1328 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { | 1326 void RenderWidgetHostImpl::SetCursor(const WebCursor& cursor) { |
1329 if (!view_) | 1327 if (!view_) |
1330 return; | 1328 return; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 weak_factory_.GetWeakPtr(), sequence_number), | 1853 weak_factory_.GetWeakPtr(), sequence_number), |
1856 base::TimeDelta::FromSecondsD(1. / 6)); | 1854 base::TimeDelta::FromSecondsD(1. / 6)); |
1857 #else | 1855 #else |
1858 WindowSnapshotReachedScreen(sequence_number); | 1856 WindowSnapshotReachedScreen(sequence_number); |
1859 #endif | 1857 #endif |
1860 } | 1858 } |
1861 | 1859 |
1862 latency_tracker_.OnGpuSwapBuffersCompleted(latency_info); | 1860 latency_tracker_.OnGpuSwapBuffersCompleted(latency_info); |
1863 } | 1861 } |
1864 | 1862 |
| 1863 void RenderWidgetHostImpl::RequestBeginFrameForSynthesizedInput( |
| 1864 base::OnceClosure begin_frame_callback) { |
| 1865 DCHECK(view_); |
| 1866 begin_frame_callback_ = std::move(begin_frame_callback); |
| 1867 view_->OnSetNeedsFlushInput(); |
| 1868 } |
| 1869 |
1865 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1870 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { |
1866 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case | 1871 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
1867 // it handles destruction. | 1872 // it handles destruction. |
1868 if (!owned_by_render_frame_host_) { | 1873 if (!owned_by_render_frame_host_) { |
1869 // TODO(evanm): This synchronously ends up calling "delete this". | 1874 // TODO(evanm): This synchronously ends up calling "delete this". |
1870 // Is that really what we want in response to this message? I'm matching | 1875 // Is that really what we want in response to this message? I'm matching |
1871 // previous behavior of the code here. | 1876 // previous behavior of the code here. |
1872 Destroy(true); | 1877 Destroy(true); |
1873 } else { | 1878 } else { |
1874 RendererExited(static_cast<base::TerminationStatus>(status), exit_code); | 1879 RendererExited(static_cast<base::TerminationStatus>(status), exit_code); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 if (ack_source == InputEventAckSource::MAIN_THREAD) | 2213 if (ack_source == InputEventAckSource::MAIN_THREAD) |
2209 RestartHangMonitorTimeoutIfNecessary(); | 2214 RestartHangMonitorTimeoutIfNecessary(); |
2210 } | 2215 } |
2211 } | 2216 } |
2212 | 2217 |
2213 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { | 2218 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { |
2214 has_touch_handler_ = has_handlers; | 2219 has_touch_handler_ = has_handlers; |
2215 } | 2220 } |
2216 | 2221 |
2217 void RenderWidgetHostImpl::DidFlush() { | 2222 void RenderWidgetHostImpl::DidFlush() { |
2218 if (synthetic_gesture_controller_) | |
2219 synthetic_gesture_controller_->OnDidFlushInput(); | |
2220 } | 2223 } |
2221 | 2224 |
2222 void RenderWidgetHostImpl::DidOverscroll( | 2225 void RenderWidgetHostImpl::DidOverscroll( |
2223 const ui::DidOverscrollParams& params) { | 2226 const ui::DidOverscrollParams& params) { |
2224 if (view_) | 2227 if (view_) |
2225 view_->DidOverscroll(params); | 2228 view_->DidOverscroll(params); |
2226 } | 2229 } |
2227 | 2230 |
2228 void RenderWidgetHostImpl::DidStopFlinging() { | 2231 void RenderWidgetHostImpl::DidStopFlinging() { |
2229 is_in_touchpad_gesture_fling_ = false; | 2232 is_in_touchpad_gesture_fling_ = false; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 RenderProcessHost* rph = GetProcess(); | 2648 RenderProcessHost* rph = GetProcess(); |
2646 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); | 2649 for (std::vector<IPC::Message>::const_iterator i = messages.begin(); |
2647 i != messages.end(); ++i) { | 2650 i != messages.end(); ++i) { |
2648 rph->OnMessageReceived(*i); | 2651 rph->OnMessageReceived(*i); |
2649 if (i->dispatch_error()) | 2652 if (i->dispatch_error()) |
2650 rph->OnBadMessageReceived(*i); | 2653 rph->OnBadMessageReceived(*i); |
2651 } | 2654 } |
2652 } | 2655 } |
2653 | 2656 |
2654 } // namespace content | 2657 } // namespace content |
OLD | NEW |