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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 #include "base/trace_event/trace_event_synthetic_delay.h" | 19 #include "base/trace_event/trace_event_synthetic_delay.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "cc/base/switches.h" | 21 #include "cc/base/switches.h" |
22 #include "cc/debug/benchmark_instrumentation.h" | 22 #include "cc/debug/benchmark_instrumentation.h" |
23 #include "cc/output/output_surface.h" | 23 #include "cc/output/output_surface.h" |
24 #include "cc/trees/layer_tree_host.h" | 24 #include "cc/trees/layer_tree_host.h" |
25 #include "components/scheduler/renderer/renderer_scheduler.h" | 25 #include "components/scheduler/renderer/renderer_scheduler.h" |
26 #include "content/child/npapi/webplugin.h" | 26 #include "content/child/npapi/webplugin.h" |
27 #include "content/common/content_switches_internal.h" | |
27 #include "content/common/gpu/client/context_provider_command_buffer.h" | 28 #include "content/common/gpu/client/context_provider_command_buffer.h" |
28 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 29 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
29 #include "content/common/gpu/gpu_process_launch_causes.h" | 30 #include "content/common/gpu/gpu_process_launch_causes.h" |
30 #include "content/common/input/synthetic_gesture_packet.h" | 31 #include "content/common/input/synthetic_gesture_packet.h" |
31 #include "content/common/input/web_input_event_traits.h" | 32 #include "content/common/input/web_input_event_traits.h" |
32 #include "content/common/input_messages.h" | 33 #include "content/common/input_messages.h" |
33 #include "content/common/swapped_out_messages.h" | 34 #include "content/common/swapped_out_messages.h" |
34 #include "content/common/view_messages.h" | 35 #include "content/common/view_messages.h" |
35 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
36 #include "content/public/common/context_menu_params.h" | 37 #include "content/public/common/context_menu_params.h" |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 // A resize ack shouldn't be requested if we have not ACK'd the previous | 762 // A resize ack shouldn't be requested if we have not ACK'd the previous |
762 // one. | 763 // one. |
763 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack()); | 764 DCHECK(resize_ack != SEND_RESIZE_ACK || !next_paint_is_resize_ack()); |
764 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK); | 765 DCHECK(resize_ack == SEND_RESIZE_ACK || resize_ack == NO_RESIZE_ACK); |
765 } | 766 } |
766 | 767 |
767 // Ignore this during shutdown. | 768 // Ignore this during shutdown. |
768 if (!webwidget_) | 769 if (!webwidget_) |
769 return; | 770 return; |
770 | 771 |
771 if (compositor_) { | 772 if (compositor_) |
772 compositor_->setViewportSize(new_size, physical_backing_size); | 773 compositor_->setViewportSize(physical_backing_size); |
773 } | |
774 | 774 |
775 bool resized = size_ != new_size || | |
776 physical_backing_size_ != physical_backing_size; | |
777 | |
778 size_ = new_size; | |
aelias_OOO_until_Jul13
2015/10/25 00:07:11
size_ should match WebView::size().
| |
775 physical_backing_size_ = physical_backing_size; | 779 physical_backing_size_ = physical_backing_size; |
780 | |
776 top_controls_shrink_blink_size_ = top_controls_shrink_blink_size; | 781 top_controls_shrink_blink_size_ = top_controls_shrink_blink_size; |
777 top_controls_height_ = top_controls_height; | 782 top_controls_height_ = top_controls_height; |
778 visible_viewport_size_ = visible_viewport_size; | 783 visible_viewport_size_ = visible_viewport_size; |
779 resizer_rect_ = resizer_rect; | 784 resizer_rect_ = resizer_rect; |
780 | 785 |
781 // NOTE: We may have entered fullscreen mode without changing our size. | 786 // NOTE: We may have entered fullscreen mode without changing our size. |
782 bool fullscreen_change = is_fullscreen_granted_ != is_fullscreen_granted; | 787 bool fullscreen_change = is_fullscreen_granted_ != is_fullscreen_granted; |
783 is_fullscreen_granted_ = is_fullscreen_granted; | 788 is_fullscreen_granted_ = is_fullscreen_granted; |
784 display_mode_ = display_mode; | 789 display_mode_ = display_mode; |
785 | 790 |
786 webwidget_->setTopControlsHeight(top_controls_height, | 791 webwidget_->setTopControlsHeight(top_controls_height, |
787 top_controls_shrink_blink_size_); | 792 top_controls_shrink_blink_size_); |
788 | 793 |
789 if (size_ != new_size) { | 794 if (resized) { |
790 size_ = new_size; | 795 gfx::Size new_widget_size = |
791 | 796 IsUseZoomForDSFEnabled() ? physical_backing_size_ : size_; |
aelias_OOO_until_Jul13
2015/10/25 00:07:11
Please do this in/near RenderWidgetHostViewAura in
| |
792 // When resizing, we want to wait to paint before ACK'ing the resize. This | 797 // When resizing, we want to wait to paint before ACK'ing the resize. This |
793 // ensures that we only resize as fast as we can paint. We only need to | 798 // ensures that we only resize as fast as we can paint. We only need to |
794 // send an ACK if we are resized to a non-empty rect. | 799 // send an ACK if we are resized to a non-empty rect. |
795 webwidget_->resize(new_size); | 800 webwidget_->resize(new_widget_size); |
801 } | |
802 WebSize pinch_viewport_size; | |
803 | |
804 if (IsUseZoomForDSFEnabled()) { | |
805 gfx::SizeF scaled_visible_viewport_size = | |
806 gfx::ScaleSize(gfx::SizeF(visible_viewport_size), device_scale_factor_); | |
aelias_OOO_until_Jul13
2015/10/25 00:07:11
Please set this in/near RenderWidgetHostViewAura (
| |
807 pinch_viewport_size = gfx::ToCeiledSize(scaled_visible_viewport_size); | |
808 } else { | |
809 pinch_viewport_size = visible_viewport_size_; | |
796 } | 810 } |
797 | 811 |
798 webwidget()->resizePinchViewport(gfx::Size( | 812 webwidget()->resizePinchViewport(pinch_viewport_size); |
799 visible_viewport_size.width(), | |
800 visible_viewport_size.height())); | |
801 | 813 |
802 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) { | 814 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) { |
803 // In this case there is no paint/composite and therefore no | 815 // In this case there is no paint/composite and therefore no |
804 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the | 816 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the |
805 // ack through a fake ViewHostMsg_UpdateRect or a different message. | 817 // ack through a fake ViewHostMsg_UpdateRect or a different message. |
806 DCHECK_EQ(resize_ack, NO_RESIZE_ACK); | 818 DCHECK_EQ(resize_ack, NO_RESIZE_ACK); |
807 } | 819 } |
808 | 820 |
809 // Send the Resize_ACK flag once we paint again if requested. | 821 // Send the Resize_ACK flag once we paint again if requested. |
810 if (resize_ack == SEND_RESIZE_ACK) | 822 if (resize_ack == SEND_RESIZE_ACK) |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 pending_input_event_ack_.get()); | 1315 pending_input_event_ack_.get()); |
1304 Send(pending_input_event_ack_.release()); | 1316 Send(pending_input_event_ack_.release()); |
1305 } | 1317 } |
1306 total_input_handling_time_this_frame_ = base::TimeDelta(); | 1318 total_input_handling_time_this_frame_ = base::TimeDelta(); |
1307 } | 1319 } |
1308 | 1320 |
1309 /////////////////////////////////////////////////////////////////////////////// | 1321 /////////////////////////////////////////////////////////////////////////////// |
1310 // WebWidgetClient | 1322 // WebWidgetClient |
1311 | 1323 |
1312 void RenderWidget::didAutoResize(const WebSize& new_size) { | 1324 void RenderWidget::didAutoResize(const WebSize& new_size) { |
1325 // TODO(oshima): support UseZoomForDSFEnabled() | |
1313 if (size_.width() != new_size.width || size_.height() != new_size.height) { | 1326 if (size_.width() != new_size.width || size_.height() != new_size.height) { |
1314 size_ = new_size; | 1327 size_ = new_size; |
1315 | 1328 |
1316 if (resizing_mode_selector_->is_synchronous_mode()) { | 1329 if (resizing_mode_selector_->is_synchronous_mode()) { |
1317 WebRect new_pos(rootWindowRect().x, | 1330 WebRect new_pos(rootWindowRect().x, |
1318 rootWindowRect().y, | 1331 rootWindowRect().y, |
1319 new_size.width, | 1332 new_size.width, |
1320 new_size.height); | 1333 new_size.height); |
1321 view_screen_rect_ = new_pos; | 1334 view_screen_rect_ = new_pos; |
1322 window_screen_rect_ = new_pos; | 1335 window_screen_rect_ = new_pos; |
1323 } | 1336 } |
1324 | 1337 |
1325 AutoResizeCompositor(); | 1338 AutoResizeCompositor(); |
1326 | 1339 |
1327 if (!resizing_mode_selector_->is_synchronous_mode()) | 1340 if (!resizing_mode_selector_->is_synchronous_mode()) |
1328 need_update_rect_for_auto_resize_ = true; | 1341 need_update_rect_for_auto_resize_ = true; |
1329 } | 1342 } |
1330 } | 1343 } |
1331 | 1344 |
1332 void RenderWidget::AutoResizeCompositor() { | 1345 void RenderWidget::AutoResizeCompositor() { |
1333 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); | 1346 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); |
1334 if (compositor_) | 1347 if (compositor_) |
1335 compositor_->setViewportSize(size_, physical_backing_size_); | 1348 compositor_->setViewportSize(physical_backing_size_); |
1336 } | 1349 } |
1337 | 1350 |
1338 void RenderWidget::initializeLayerTreeView() { | 1351 void RenderWidget::initializeLayerTreeView() { |
1339 DCHECK(!host_closing_); | 1352 DCHECK(!host_closing_); |
1340 | 1353 |
1341 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); | 1354 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); |
1342 compositor_->setViewportSize(size_, physical_backing_size_); | 1355 compositor_->setViewportSize(physical_backing_size_); |
1343 | 1356 |
1344 // For background pages and certain tests, we don't want to trigger | 1357 // For background pages and certain tests, we don't want to trigger |
1345 // OutputSurface creation. | 1358 // OutputSurface creation. |
1346 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1359 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1347 compositor_->SetNeverVisible(); | 1360 compositor_->SetNeverVisible(); |
1348 | 1361 |
1349 StartCompositor(); | 1362 StartCompositor(); |
1350 } | 1363 } |
1351 | 1364 |
1352 void RenderWidget::WillCloseLayerTreeView() { | 1365 void RenderWidget::WillCloseLayerTreeView() { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1590 | 1603 |
1591 return view_screen_rect_; | 1604 return view_screen_rect_; |
1592 } | 1605 } |
1593 | 1606 |
1594 void RenderWidget::setToolTipText(const blink::WebString& text, | 1607 void RenderWidget::setToolTipText(const blink::WebString& text, |
1595 WebTextDirection hint) { | 1608 WebTextDirection hint) { |
1596 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 1609 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
1597 } | 1610 } |
1598 | 1611 |
1599 void RenderWidget::setWindowRect(const WebRect& rect) { | 1612 void RenderWidget::setWindowRect(const WebRect& rect) { |
1613 // TODO(oshima): Scale back to DIP coordinates. | |
1600 WebRect window_rect = rect; | 1614 WebRect window_rect = rect; |
1601 if (popup_origin_scale_for_emulation_) { | 1615 if (popup_origin_scale_for_emulation_) { |
1602 float scale = popup_origin_scale_for_emulation_; | 1616 float scale = popup_origin_scale_for_emulation_; |
1603 window_rect.x = popup_screen_origin_for_emulation_.x() + | 1617 window_rect.x = popup_screen_origin_for_emulation_.x() + |
1604 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale; | 1618 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale; |
1605 window_rect.y = popup_screen_origin_for_emulation_.y() + | 1619 window_rect.y = popup_screen_origin_for_emulation_.y() + |
1606 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale; | 1620 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale; |
1607 } | 1621 } |
1608 | 1622 |
1609 if (!resizing_mode_selector_->is_synchronous_mode()) { | 1623 if (!resizing_mode_selector_->is_synchronous_mode()) { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1937 text_input_mode_ = new_mode; | 1951 text_input_mode_ = new_mode; |
1938 can_compose_inline_ = new_can_compose_inline; | 1952 can_compose_inline_ = new_can_compose_inline; |
1939 text_input_flags_ = new_info.flags; | 1953 text_input_flags_ = new_info.flags; |
1940 } | 1954 } |
1941 } | 1955 } |
1942 | 1956 |
1943 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 1957 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
1944 WebRect focus_webrect; | 1958 WebRect focus_webrect; |
1945 WebRect anchor_webrect; | 1959 WebRect anchor_webrect; |
1946 webwidget_->selectionBounds(focus_webrect, anchor_webrect); | 1960 webwidget_->selectionBounds(focus_webrect, anchor_webrect); |
1947 *focus = focus_webrect; | 1961 if (IsUseZoomForDSFEnabled()) { |
aelias_OOO_until_Jul13
2015/10/25 00:07:11
This is pretty ugly and looks like it will spread.
oshima
2015/10/27 20:28:09
Both Aura/Mac uses DIP at least. Android isn't usi
danakj
2015/10/27 20:33:47
I'm not sure why Aura is coming up here, but I pro
| |
1948 *anchor = anchor_webrect; | 1962 float inverse_scale = 1.f / device_scale_factor_; |
1963 gfx::RectF focus_rect(focus_webrect); | |
1964 *focus = gfx::ToEnclosingRect(gfx::ScaleRect(focus_rect, inverse_scale)); | |
1965 gfx::RectF anchor_rect(anchor_webrect); | |
1966 *anchor = gfx::ToEnclosingRect(gfx::ScaleRect(anchor_rect, inverse_scale)); | |
1967 } else { | |
1968 *focus = focus_webrect; | |
1969 *anchor = anchor_webrect; | |
1970 } | |
1949 } | 1971 } |
1950 | 1972 |
1951 void RenderWidget::UpdateSelectionBounds() { | 1973 void RenderWidget::UpdateSelectionBounds() { |
1952 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); | 1974 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); |
1953 if (!webwidget_) | 1975 if (!webwidget_) |
1954 return; | 1976 return; |
1955 if (handling_ime_event_) | 1977 if (handling_ime_event_) |
1956 return; | 1978 return; |
1957 | 1979 |
1958 #if defined(USE_AURA) | 1980 #if defined(USE_AURA) |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2382 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2404 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2383 video_hole_frames_.AddObserver(frame); | 2405 video_hole_frames_.AddObserver(frame); |
2384 } | 2406 } |
2385 | 2407 |
2386 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2408 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2387 video_hole_frames_.RemoveObserver(frame); | 2409 video_hole_frames_.RemoveObserver(frame); |
2388 } | 2410 } |
2389 #endif // defined(VIDEO_HOLE) | 2411 #endif // defined(VIDEO_HOLE) |
2390 | 2412 |
2391 } // namespace content | 2413 } // namespace content |
OLD | NEW |