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

Side by Side Diff: content/renderer/render_widget.cc

Issue 1456753002: Compute the popup location/size correctly when use-zoom-for-dsf is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/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"
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 gfx::Size new_widget_size = 872 gfx::Size new_widget_size =
873 IsUseZoomForDSFEnabled() ? physical_backing_size_ : size_; 873 IsUseZoomForDSFEnabled() ? physical_backing_size_ : size_;
874 // When resizing, we want to wait to paint before ACK'ing the resize. This 874 // When resizing, we want to wait to paint before ACK'ing the resize. This
875 // ensures that we only resize as fast as we can paint. We only need to 875 // ensures that we only resize as fast as we can paint. We only need to
876 // send an ACK if we are resized to a non-empty rect. 876 // send an ACK if we are resized to a non-empty rect.
877 webwidget_->resize(new_widget_size); 877 webwidget_->resize(new_widget_size);
878 } 878 }
879 WebSize visual_viewport_size; 879 WebSize visual_viewport_size;
880 880
881 if (IsUseZoomForDSFEnabled()) { 881 if (IsUseZoomForDSFEnabled()) {
882 gfx::SizeF scaled_visible_viewport_size = 882 visual_viewport_size =
883 gfx::ScaleSize(gfx::SizeF(visible_viewport_size), device_scale_factor_); 883 gfx::ScaleToCeiledSize(visible_viewport_size, device_scale_factor_);
884 visual_viewport_size = gfx::ToCeiledSize(scaled_visible_viewport_size);
885 } else { 884 } else {
886 visual_viewport_size = visible_viewport_size_; 885 visual_viewport_size = visible_viewport_size_;
887 } 886 }
888 887
889 webwidget()->resizeVisualViewport(visual_viewport_size); 888 webwidget()->resizeVisualViewport(visual_viewport_size);
890 889
891 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) { 890 if (new_size.IsEmpty() || physical_backing_size.IsEmpty()) {
892 // In this case there is no paint/composite and therefore no 891 // In this case there is no paint/composite and therefore no
893 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the 892 // ViewHostMsg_UpdateRect to send the resize ack with. We'd need to send the
894 // ack through a fake ViewHostMsg_UpdateRect or a different message. 893 // ack through a fake ViewHostMsg_UpdateRect or a different message.
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); 1448 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_);
1450 if (compositor_) 1449 if (compositor_)
1451 compositor_->setViewportSize(physical_backing_size_); 1450 compositor_->setViewportSize(physical_backing_size_);
1452 } 1451 }
1453 1452
1454 void RenderWidget::initializeLayerTreeView() { 1453 void RenderWidget::initializeLayerTreeView() {
1455 DCHECK(!host_closing_); 1454 DCHECK(!host_closing_);
1456 1455
1457 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_); 1456 compositor_ = RenderWidgetCompositor::Create(this, compositor_deps_);
1458 compositor_->setViewportSize(physical_backing_size_); 1457 compositor_->setViewportSize(physical_backing_size_);
1459 1458 OnDeviceScaleFactorChanged();
1460 // For background pages and certain tests, we don't want to trigger 1459 // For background pages and certain tests, we don't want to trigger
1461 // OutputSurface creation. 1460 // OutputSurface creation.
1462 if (compositor_never_visible_ || !RenderThreadImpl::current()) 1461 if (compositor_never_visible_ || !RenderThreadImpl::current())
1463 compositor_->SetNeverVisible(); 1462 compositor_->SetNeverVisible();
1464 1463
1465 StartCompositor(); 1464 StartCompositor();
1466 } 1465 }
1467 1466
1468 void RenderWidget::WillCloseLayerTreeView() { 1467 void RenderWidget::WillCloseLayerTreeView() {
1469 if (host_closing_) 1468 if (host_closing_)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 return pending_window_rect_; 1704 return pending_window_rect_;
1706 1705
1707 return view_screen_rect_; 1706 return view_screen_rect_;
1708 } 1707 }
1709 1708
1710 void RenderWidget::setToolTipText(const blink::WebString& text, 1709 void RenderWidget::setToolTipText(const blink::WebString& text,
1711 WebTextDirection hint) { 1710 WebTextDirection hint) {
1712 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); 1711 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint));
1713 } 1712 }
1714 1713
1715 void RenderWidget::setWindowRect(const WebRect& rect) { 1714 void RenderWidget::setWindowRect(const WebRect& rect_in_screen) {
1716 // TODO(oshima): Scale back to DIP coordinates. 1715 WebRect window_rect = rect_in_screen;
1717 WebRect window_rect = rect;
1718 if (popup_origin_scale_for_emulation_) { 1716 if (popup_origin_scale_for_emulation_) {
1719 float scale = popup_origin_scale_for_emulation_; 1717 float scale = popup_origin_scale_for_emulation_;
1720 window_rect.x = popup_screen_origin_for_emulation_.x() + 1718 window_rect.x = popup_screen_origin_for_emulation_.x() +
1721 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale; 1719 (window_rect.x - popup_view_origin_for_emulation_.x()) * scale;
1722 window_rect.y = popup_screen_origin_for_emulation_.y() + 1720 window_rect.y = popup_screen_origin_for_emulation_.y() +
1723 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale; 1721 (window_rect.y - popup_view_origin_for_emulation_.y()) * scale;
1724 } 1722 }
1725 1723
1726 if (!resizing_mode_selector_->is_synchronous_mode()) { 1724 if (!resizing_mode_selector_->is_synchronous_mode()) {
1727 if (did_show_) { 1725 if (did_show_) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 if (text.length()) 1783 if (text.length())
1786 webwidget_->confirmComposition(text); 1784 webwidget_->confirmComposition(text);
1787 else if (keep_selection) 1785 else if (keep_selection)
1788 webwidget_->confirmComposition(WebWidget::KeepSelection); 1786 webwidget_->confirmComposition(WebWidget::KeepSelection);
1789 else 1787 else
1790 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); 1788 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
1791 handling_input_event_ = false; 1789 handling_input_event_ = false;
1792 UpdateCompositionInfo(true); 1790 UpdateCompositionInfo(true);
1793 } 1791 }
1794 1792
1793 void RenderWidget::OnDeviceScaleFactorChanged() {
1794 DCHECK(compositor_);
1795 if (IsUseZoomForDSFEnabled())
1796 compositor_->SetPaintedDeviceScaleFactor(device_scale_factor_);
1797 else
1798 compositor_->setDeviceScaleFactor(device_scale_factor_);
1799 }
1800
1795 void RenderWidget::OnRepaint(gfx::Size size_to_paint) { 1801 void RenderWidget::OnRepaint(gfx::Size size_to_paint) {
1796 // During shutdown we can just ignore this message. 1802 // During shutdown we can just ignore this message.
1797 if (!webwidget_) 1803 if (!webwidget_)
1798 return; 1804 return;
1799 1805
1800 // Even if the browser provides an empty damage rect, it's still expecting to 1806 // Even if the browser provides an empty damage rect, it's still expecting to
1801 // receive a repaint ack so just damage the entire widget bounds. 1807 // receive a repaint ack so just damage the entire widget bounds.
1802 if (size_to_paint.IsEmpty()) { 1808 if (size_to_paint.IsEmpty()) {
1803 size_to_paint = size_; 1809 size_to_paint = size_;
1804 } 1810 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 compositor_->OnHandleCompositorProto(proto); 1849 compositor_->OnHandleCompositorProto(proto);
1844 } 1850 }
1845 1851
1846 void RenderWidget::showImeIfNeeded() { 1852 void RenderWidget::showImeIfNeeded() {
1847 OnShowImeIfNeeded(); 1853 OnShowImeIfNeeded();
1848 } 1854 }
1849 1855
1850 void RenderWidget::convertViewportToWindow(blink::WebRect* rect) { 1856 void RenderWidget::convertViewportToWindow(blink::WebRect* rect) {
1851 if (IsUseZoomForDSFEnabled()) { 1857 if (IsUseZoomForDSFEnabled()) {
1852 float reverse = 1 / device_scale_factor_; 1858 float reverse = 1 / device_scale_factor_;
1853 // TODO(oshima): We may wait to allow pixel precision here as the the 1859 // TODO(oshima): We may need to allow pixel precision here as the the
1854 // anchor element can be placed at half pixel. 1860 // anchor element can be placed at half pixel.
1855 gfx::Rect window_rect = 1861 gfx::Rect window_rect =
1856 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse); 1862 gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse);
1857 rect->x = window_rect.x(); 1863 rect->x = window_rect.x();
1858 rect->y = window_rect.y(); 1864 rect->y = window_rect.y();
1859 rect->width = window_rect.width(); 1865 rect->width = window_rect.width();
1860 rect->height = window_rect.height(); 1866 rect->height = window_rect.height();
1861 } 1867 }
1862 } 1868 }
1863 1869
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 1926
1921 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() { 1927 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() {
1922 ignore_ack_for_mouse_move_from_debugger_ = true; 1928 ignore_ack_for_mouse_move_from_debugger_ = true;
1923 } 1929 }
1924 1930
1925 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { 1931 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
1926 if (device_scale_factor_ == device_scale_factor) 1932 if (device_scale_factor_ == device_scale_factor)
1927 return; 1933 return;
1928 1934
1929 device_scale_factor_ = device_scale_factor; 1935 device_scale_factor_ = device_scale_factor;
1936
1937 OnDeviceScaleFactorChanged();
1938
1930 ScheduleComposite(); 1939 ScheduleComposite();
1931 } 1940 }
1932 1941
1933 bool RenderWidget::SetDeviceColorProfile( 1942 bool RenderWidget::SetDeviceColorProfile(
1934 const std::vector<char>& color_profile) { 1943 const std::vector<char>& color_profile) {
1935 if (device_color_profile_ == color_profile) 1944 if (device_color_profile_ == color_profile)
1936 return false; 1945 return false;
1937 1946
1938 device_color_profile_ = color_profile; 1947 device_color_profile_ = color_profile;
1939 return true; 1948 return true;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2552 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2544 video_hole_frames_.AddObserver(frame); 2553 video_hole_frames_.AddObserver(frame);
2545 } 2554 }
2546 2555
2547 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2556 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2548 video_hole_frames_.RemoveObserver(frame); 2557 video_hole_frames_.RemoveObserver(frame);
2549 } 2558 }
2550 #endif // defined(VIDEO_HOLE) 2559 #endif // defined(VIDEO_HOLE)
2551 2560
2552 } // namespace content 2561 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698