| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 popup_origin_scale_for_emulation_(0.f), | 368 popup_origin_scale_for_emulation_(0.f), |
| 369 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 369 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
| 370 resizing_mode_selector_(new ResizingModeSelector()), | 370 resizing_mode_selector_(new ResizingModeSelector()), |
| 371 has_host_context_menu_location_(false), | 371 has_host_context_menu_location_(false), |
| 372 has_added_input_handler_(false), | 372 has_added_input_handler_(false), |
| 373 has_focus_(false), | 373 has_focus_(false), |
| 374 #if defined(OS_MACOSX) | 374 #if defined(OS_MACOSX) |
| 375 text_input_client_observer_(new TextInputClientObserver(this)), | 375 text_input_client_observer_(new TextInputClientObserver(this)), |
| 376 #endif | 376 #endif |
| 377 focused_pepper_plugin_(nullptr), | 377 focused_pepper_plugin_(nullptr), |
| 378 time_to_first_active_paint_recorded_(true), |
| 379 was_shown_time_(base::TimeTicks::Now()), |
| 378 weak_ptr_factory_(this) { | 380 weak_ptr_factory_(this) { |
| 379 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); | 381 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
| 380 if (!swapped_out) | 382 if (!swapped_out) |
| 381 RenderProcess::current()->AddRefProcess(); | 383 RenderProcess::current()->AddRefProcess(); |
| 382 DCHECK(RenderThread::Get()); | 384 DCHECK(RenderThread::Get()); |
| 383 | 385 |
| 384 // In tests there may not be a RenderThreadImpl. | 386 // In tests there may not be a RenderThreadImpl. |
| 385 if (RenderThreadImpl::current()) { | 387 if (RenderThreadImpl::current()) { |
| 386 render_widget_scheduling_state_ = RenderThreadImpl::current() | 388 render_widget_scheduling_state_ = RenderThreadImpl::current() |
| 387 ->GetRendererScheduler() | 389 ->GetRendererScheduler() |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 observer.WasHidden(); | 768 observer.WasHidden(); |
| 767 } | 769 } |
| 768 | 770 |
| 769 void RenderWidget::OnWasShown(bool needs_repainting, | 771 void RenderWidget::OnWasShown(bool needs_repainting, |
| 770 const ui::LatencyInfo& latency_info) { | 772 const ui::LatencyInfo& latency_info) { |
| 771 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); | 773 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); |
| 772 // During shutdown we can just ignore this message. | 774 // During shutdown we can just ignore this message. |
| 773 if (!GetWebWidget()) | 775 if (!GetWebWidget()) |
| 774 return; | 776 return; |
| 775 | 777 |
| 778 was_shown_time_ = base::TimeTicks::Now(); |
| 776 // See OnWasHidden | 779 // See OnWasHidden |
| 777 SetHidden(false); | 780 SetHidden(false); |
| 778 for (auto& observer : render_frames_) | 781 for (auto& observer : render_frames_) |
| 779 observer.WasShown(); | 782 observer.WasShown(); |
| 780 | 783 |
| 781 if (!needs_repainting) | 784 if (!needs_repainting) |
| 782 return; | 785 return; |
| 783 | 786 |
| 784 // Generate a full repaint. | 787 // Generate a full repaint. |
| 785 if (compositor_) { | 788 if (compositor_) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 bool RenderWidget::IsClosing() const { | 925 bool RenderWidget::IsClosing() const { |
| 923 return host_closing_; | 926 return host_closing_; |
| 924 } | 927 } |
| 925 | 928 |
| 926 void RenderWidget::RequestScheduleAnimation() { | 929 void RenderWidget::RequestScheduleAnimation() { |
| 927 scheduleAnimation(); | 930 scheduleAnimation(); |
| 928 } | 931 } |
| 929 | 932 |
| 930 void RenderWidget::UpdateVisualState() { | 933 void RenderWidget::UpdateVisualState() { |
| 931 GetWebWidget()->updateAllLifecyclePhases(); | 934 GetWebWidget()->updateAllLifecyclePhases(); |
| 935 |
| 936 if (time_to_first_active_paint_recorded_) |
| 937 return; |
| 938 |
| 939 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 940 if (!render_thread_impl->NeedsToRecordFirstActivePaint()) |
| 941 return; |
| 942 |
| 943 time_to_first_active_paint_recorded_ = true; |
| 944 base::TimeDelta sample = base::TimeTicks::Now() - was_shown_time_; |
| 945 UMA_HISTOGRAM_TIMES("PurgeAndSuspend.Experimental.TimeToFirstActivePaint", |
| 946 sample); |
| 932 } | 947 } |
| 933 | 948 |
| 934 void RenderWidget::WillBeginCompositorFrame() { | 949 void RenderWidget::WillBeginCompositorFrame() { |
| 935 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 950 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 936 | 951 |
| 937 // The UpdateTextInputState can result in further layout and possibly | 952 // The UpdateTextInputState can result in further layout and possibly |
| 938 // enable GPU acceleration so they need to be called before any painting | 953 // enable GPU acceleration so they need to be called before any painting |
| 939 // is done. | 954 // is done. |
| 940 UpdateTextInputState(); | 955 UpdateTextInputState(); |
| 941 UpdateSelectionBounds(); | 956 UpdateSelectionBounds(); |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 } | 1890 } |
| 1876 | 1891 |
| 1877 void RenderWidget::SetHidden(bool hidden) { | 1892 void RenderWidget::SetHidden(bool hidden) { |
| 1878 if (is_hidden_ == hidden) | 1893 if (is_hidden_ == hidden) |
| 1879 return; | 1894 return; |
| 1880 | 1895 |
| 1881 // The status has changed. Tell the RenderThread about it and ensure | 1896 // The status has changed. Tell the RenderThread about it and ensure |
| 1882 // throttled acks are released in case frame production ceases. | 1897 // throttled acks are released in case frame production ceases. |
| 1883 is_hidden_ = hidden; | 1898 is_hidden_ = hidden; |
| 1884 | 1899 |
| 1885 if (is_hidden_) | 1900 if (is_hidden_) { |
| 1886 RenderThreadImpl::current()->WidgetHidden(); | 1901 RenderThreadImpl::current()->WidgetHidden(); |
| 1887 else | 1902 time_to_first_active_paint_recorded_ = false; |
| 1903 } else |
| 1888 RenderThreadImpl::current()->WidgetRestored(); | 1904 RenderThreadImpl::current()->WidgetRestored(); |
| 1889 | 1905 |
| 1890 if (render_widget_scheduling_state_) | 1906 if (render_widget_scheduling_state_) |
| 1891 render_widget_scheduling_state_->SetHidden(hidden); | 1907 render_widget_scheduling_state_->SetHidden(hidden); |
| 1892 } | 1908 } |
| 1893 | 1909 |
| 1894 void RenderWidget::DidToggleFullscreen() { | 1910 void RenderWidget::DidToggleFullscreen() { |
| 1895 if (!GetWebWidget()) | 1911 if (!GetWebWidget()) |
| 1896 return; | 1912 return; |
| 1897 | 1913 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 // browser side (https://crbug.com/669219). | 2309 // browser side (https://crbug.com/669219). |
| 2294 // If there is no WebFrameWidget, then there will be no | 2310 // If there is no WebFrameWidget, then there will be no |
| 2295 // InputMethodControllers for a WebLocalFrame. | 2311 // InputMethodControllers for a WebLocalFrame. |
| 2296 return nullptr; | 2312 return nullptr; |
| 2297 } | 2313 } |
| 2298 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2314 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| 2299 ->getActiveWebInputMethodController(); | 2315 ->getActiveWebInputMethodController(); |
| 2300 } | 2316 } |
| 2301 | 2317 |
| 2302 } // namespace content | 2318 } // namespace content |
| OLD | NEW |