| 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 } | 639 } |
| 640 | 640 |
| 641 void RenderWidget::OnDisableDeviceEmulation() { | 641 void RenderWidget::OnDisableDeviceEmulation() { |
| 642 screen_metrics_emulator_.reset(); | 642 screen_metrics_emulator_.reset(); |
| 643 } | 643 } |
| 644 | 644 |
| 645 void RenderWidget::OnWasHidden() { | 645 void RenderWidget::OnWasHidden() { |
| 646 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); | 646 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
| 647 // Go into a mode where we stop generating paint and scrolling events. | 647 // Go into a mode where we stop generating paint and scrolling events. |
| 648 SetHidden(true); | 648 SetHidden(true); |
| 649 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 649 for (auto& observer : render_frames_) |
| 650 WasHidden()); | 650 observer.WasHidden(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void RenderWidget::OnWasShown(bool needs_repainting, | 653 void RenderWidget::OnWasShown(bool needs_repainting, |
| 654 const ui::LatencyInfo& latency_info) { | 654 const ui::LatencyInfo& latency_info) { |
| 655 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); | 655 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); |
| 656 // During shutdown we can just ignore this message. | 656 // During shutdown we can just ignore this message. |
| 657 if (!GetWebWidget()) | 657 if (!GetWebWidget()) |
| 658 return; | 658 return; |
| 659 | 659 |
| 660 // See OnWasHidden | 660 // See OnWasHidden |
| 661 SetHidden(false); | 661 SetHidden(false); |
| 662 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 662 for (auto& observer : render_frames_) |
| 663 WasShown()); | 663 observer.WasShown(); |
| 664 | 664 |
| 665 if (!needs_repainting) | 665 if (!needs_repainting) |
| 666 return; | 666 return; |
| 667 | 667 |
| 668 // Generate a full repaint. | 668 // Generate a full repaint. |
| 669 if (compositor_) { | 669 if (compositor_) { |
| 670 ui::LatencyInfo swap_latency_info(latency_info); | 670 ui::LatencyInfo swap_latency_info(latency_info); |
| 671 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( | 671 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( |
| 672 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); | 672 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); |
| 673 compositor_->SetNeedsForcedRedraw(); | 673 compositor_->SetNeedsForcedRedraw(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 const EditCommands& edit_commands) { | 706 const EditCommands& edit_commands) { |
| 707 edit_commands_ = edit_commands; | 707 edit_commands_ = edit_commands; |
| 708 } | 708 } |
| 709 | 709 |
| 710 void RenderWidget::OnSetFocus(bool enable) { | 710 void RenderWidget::OnSetFocus(bool enable) { |
| 711 has_focus_ = enable; | 711 has_focus_ = enable; |
| 712 | 712 |
| 713 if (GetWebWidget()) | 713 if (GetWebWidget()) |
| 714 GetWebWidget()->setFocus(enable); | 714 GetWebWidget()->setFocus(enable); |
| 715 | 715 |
| 716 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 716 for (auto& observer : render_frames_) |
| 717 RenderWidgetSetFocus(enable)); | 717 observer.RenderWidgetSetFocus(enable); |
| 718 } | 718 } |
| 719 | 719 |
| 720 void RenderWidget::SetNeedsMainFrame() { | 720 void RenderWidget::SetNeedsMainFrame() { |
| 721 RenderWidgetCompositor* rwc = compositor(); | 721 RenderWidgetCompositor* rwc = compositor(); |
| 722 if (!rwc) | 722 if (!rwc) |
| 723 return; | 723 return; |
| 724 rwc->setNeedsBeginFrame(); | 724 rwc->setNeedsBeginFrame(); |
| 725 } | 725 } |
| 726 | 726 |
| 727 /////////////////////////////////////////////////////////////////////////////// | 727 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 30 matching lines...) Expand all Loading... |
| 758 return RenderThreadImpl::current()->CreateCompositorFrameSink( | 758 return RenderThreadImpl::current()->CreateCompositorFrameSink( |
| 759 fallback, routing_id_, frame_swap_message_queue_, | 759 fallback, routing_id_, frame_swap_message_queue_, |
| 760 GetURLForGraphicsContext3D()); | 760 GetURLForGraphicsContext3D()); |
| 761 } | 761 } |
| 762 | 762 |
| 763 void RenderWidget::DidCommitAndDrawCompositorFrame() { | 763 void RenderWidget::DidCommitAndDrawCompositorFrame() { |
| 764 // NOTE: Tests may break if this event is renamed or moved. See | 764 // NOTE: Tests may break if this event is renamed or moved. See |
| 765 // tab_capture_performancetest.cc. | 765 // tab_capture_performancetest.cc. |
| 766 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); | 766 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); |
| 767 | 767 |
| 768 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 768 for (auto& observer : render_frames_) |
| 769 DidCommitAndDrawCompositorFrame()); | 769 observer.DidCommitAndDrawCompositorFrame(); |
| 770 | 770 |
| 771 // Notify subclasses that we initiated the paint operation. | 771 // Notify subclasses that we initiated the paint operation. |
| 772 DidInitiatePaint(); | 772 DidInitiatePaint(); |
| 773 } | 773 } |
| 774 | 774 |
| 775 void RenderWidget::DidCommitCompositorFrame() { | 775 void RenderWidget::DidCommitCompositorFrame() { |
| 776 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 776 for (auto& observer : render_frames_) |
| 777 DidCommitCompositorFrame()); | 777 observer.DidCommitCompositorFrame(); |
| 778 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, | 778 for (auto& observer : render_frame_proxies_) |
| 779 DidCommitCompositorFrame()); | 779 observer.DidCommitCompositorFrame(); |
| 780 input_handler_->FlushPendingInputEventAck(); | 780 input_handler_->FlushPendingInputEventAck(); |
| 781 } | 781 } |
| 782 | 782 |
| 783 void RenderWidget::DidCompletePageScaleAnimation() {} | 783 void RenderWidget::DidCompletePageScaleAnimation() {} |
| 784 | 784 |
| 785 void RenderWidget::DidCompleteSwapBuffers() { | 785 void RenderWidget::DidCompleteSwapBuffers() { |
| 786 TRACE_EVENT0("renderer", "RenderWidget::DidCompleteSwapBuffers"); | 786 TRACE_EVENT0("renderer", "RenderWidget::DidCompleteSwapBuffers"); |
| 787 | 787 |
| 788 // Notify subclasses threaded composited rendering was flushed to the screen. | 788 // Notify subclasses threaded composited rendering was flushed to the screen. |
| 789 DidFlushPaint(); | 789 DidFlushPaint(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 | 836 |
| 837 void RenderWidget::WillBeginCompositorFrame() { | 837 void RenderWidget::WillBeginCompositorFrame() { |
| 838 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 838 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 839 | 839 |
| 840 // The UpdateTextInputState can result in further layout and possibly | 840 // The UpdateTextInputState can result in further layout and possibly |
| 841 // enable GPU acceleration so they need to be called before any painting | 841 // enable GPU acceleration so they need to be called before any painting |
| 842 // is done. | 842 // is done. |
| 843 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 843 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
| 844 UpdateSelectionBounds(); | 844 UpdateSelectionBounds(); |
| 845 | 845 |
| 846 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, | 846 for (auto& observer : render_frame_proxies_) |
| 847 WillBeginCompositorFrame()); | 847 observer.WillBeginCompositorFrame(); |
| 848 } | 848 } |
| 849 | 849 |
| 850 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest( | 850 std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest( |
| 851 std::unique_ptr<cc::CopyOutputRequest> request) { | 851 std::unique_ptr<cc::CopyOutputRequest> request) { |
| 852 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest( | 852 return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest( |
| 853 routing_id_, std::move(request)); | 853 routing_id_, std::move(request)); |
| 854 } | 854 } |
| 855 | 855 |
| 856 /////////////////////////////////////////////////////////////////////////////// | 856 /////////////////////////////////////////////////////////////////////////////// |
| 857 // RenderWidgetInputHandlerDelegate | 857 // RenderWidgetInputHandlerDelegate |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 } | 994 } |
| 995 | 995 |
| 996 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { | 996 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { |
| 997 if (owner_delegate_) | 997 if (owner_delegate_) |
| 998 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); | 998 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); |
| 999 | 999 |
| 1000 return false; | 1000 return false; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { | 1003 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { |
| 1004 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 1004 for (auto& observer : render_frames_) |
| 1005 RenderWidgetWillHandleMouseEvent()); | 1005 observer.RenderWidgetWillHandleMouseEvent(); |
| 1006 | 1006 |
| 1007 if (owner_delegate_) | 1007 if (owner_delegate_) |
| 1008 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event); | 1008 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event); |
| 1009 | 1009 |
| 1010 return false; | 1010 return false; |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 /////////////////////////////////////////////////////////////////////////////// | 1013 /////////////////////////////////////////////////////////////////////////////// |
| 1014 // RenderWidgetScreenMetricsDelegate | 1014 // RenderWidgetScreenMetricsDelegate |
| 1015 | 1015 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1163 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1164 return compositor_.get(); | 1164 return compositor_.get(); |
| 1165 } | 1165 } |
| 1166 | 1166 |
| 1167 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { | 1167 void RenderWidget::didMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { |
| 1168 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { | 1168 if (layout_type == blink::WebMeaningfulLayout::VisuallyNonEmpty) { |
| 1169 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), | 1169 QueueMessage(new ViewHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_), |
| 1170 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); | 1170 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 1173 for (auto& observer : render_frames_) |
| 1174 DidMeaningfulLayout(layout_type)); | 1174 observer.DidMeaningfulLayout(layout_type); |
| 1175 } | 1175 } |
| 1176 | 1176 |
| 1177 void RenderWidget::ScheduleComposite() { | 1177 void RenderWidget::ScheduleComposite() { |
| 1178 if (compositor_ && | 1178 if (compositor_ && |
| 1179 compositor_deps_->GetCompositorImplThreadTaskRunner().get()) { | 1179 compositor_deps_->GetCompositorImplThreadTaskRunner().get()) { |
| 1180 compositor_->setNeedsCompositorUpdate(); | 1180 compositor_->setNeedsCompositorUpdate(); |
| 1181 } | 1181 } |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 void RenderWidget::ScheduleCompositeWithForcedRedraw() { | 1184 void RenderWidget::ScheduleCompositeWithForcedRedraw() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_rect_)); | 1269 Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_rect_)); |
| 1270 SetPendingWindowRect(initial_rect_); | 1270 SetPendingWindowRect(initial_rect_); |
| 1271 } | 1271 } |
| 1272 | 1272 |
| 1273 void RenderWidget::DoDeferredClose() { | 1273 void RenderWidget::DoDeferredClose() { |
| 1274 WillCloseLayerTreeView(); | 1274 WillCloseLayerTreeView(); |
| 1275 Send(new ViewHostMsg_Close(routing_id_)); | 1275 Send(new ViewHostMsg_Close(routing_id_)); |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 void RenderWidget::NotifyOnClose() { | 1278 void RenderWidget::NotifyOnClose() { |
| 1279 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, WidgetWillClose()); | 1279 for (auto& observer : render_frames_) |
| 1280 observer.WidgetWillClose(); |
| 1280 } | 1281 } |
| 1281 | 1282 |
| 1282 void RenderWidget::closeWidgetSoon() { | 1283 void RenderWidget::closeWidgetSoon() { |
| 1283 DCHECK(content::RenderThread::Get()); | 1284 DCHECK(content::RenderThread::Get()); |
| 1284 if (is_swapped_out_) { | 1285 if (is_swapped_out_) { |
| 1285 // This widget is currently swapped out, and the active widget is in a | 1286 // This widget is currently swapped out, and the active widget is in a |
| 1286 // different process. Have the browser route the close request to the | 1287 // different process. Have the browser route the close request to the |
| 1287 // active widget instead, so that the correct unload handlers are run. | 1288 // active widget instead, so that the correct unload handlers are run. |
| 1288 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1289 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
| 1289 return; | 1290 return; |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 bool RenderWidget::isPointerLocked() { | 2178 bool RenderWidget::isPointerLocked() { |
| 2178 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2179 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2179 webwidget_mouse_lock_target_.get()); | 2180 webwidget_mouse_lock_target_.get()); |
| 2180 } | 2181 } |
| 2181 | 2182 |
| 2182 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2183 blink::WebWidget* RenderWidget::GetWebWidget() const { |
| 2183 return webwidget_internal_; | 2184 return webwidget_internal_; |
| 2184 } | 2185 } |
| 2185 | 2186 |
| 2186 } // namespace content | 2187 } // namespace content |
| OLD | NEW |