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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2122023002: Cross-process frames should be notified of device scale factor changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix RenderWidgetHostTest.ResizeScreenInfo. Created 4 years, 4 months 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/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/common/site_isolation_policy.h" 48 #include "content/common/site_isolation_policy.h"
49 #include "content/common/text_input_state.h" 49 #include "content/common/text_input_state.h"
50 #include "content/common/view_messages.h" 50 #include "content/common/view_messages.h"
51 #include "content/public/browser/content_browser_client.h" 51 #include "content/public/browser/content_browser_client.h"
52 #include "content/public/browser/overscroll_configuration.h" 52 #include "content/public/browser/overscroll_configuration.h"
53 #include "content/public/browser/render_view_host.h" 53 #include "content/public/browser/render_view_host.h"
54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
55 #include "content/public/browser/user_metrics.h" 55 #include "content/public/browser/user_metrics.h"
56 #include "content/public/common/content_switches.h" 56 #include "content/public/common/content_switches.h"
57 #include "gpu/ipc/common/gpu_messages.h" 57 #include "gpu/ipc/common/gpu_messages.h"
58 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
59 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 58 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
60 #include "third_party/WebKit/public/web/WebInputEvent.h" 59 #include "third_party/WebKit/public/web/WebInputEvent.h"
61 #include "ui/aura/client/aura_constants.h" 60 #include "ui/aura/client/aura_constants.h"
62 #include "ui/aura/client/cursor_client.h" 61 #include "ui/aura/client/cursor_client.h"
63 #include "ui/aura/client/cursor_client_observer.h" 62 #include "ui/aura/client/cursor_client_observer.h"
64 #include "ui/aura/client/focus_client.h" 63 #include "ui/aura/client/focus_client.h"
65 #include "ui/aura/client/screen_position_client.h" 64 #include "ui/aura/client/screen_position_client.h"
66 #include "ui/aura/client/window_tree_client.h" 65 #include "ui/aura/client/window_tree_client.h"
67 #include "ui/aura/env.h" 66 #include "ui/aura/env.h"
68 #include "ui/aura/window.h" 67 #include "ui/aura/window.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 107
109 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 108 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
110 #include "content/common/input_messages.h" 109 #include "content/common/input_messages.h"
111 #include "ui/base/ime/linux/text_edit_command_auralinux.h" 110 #include "ui/base/ime/linux/text_edit_command_auralinux.h"
112 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" 111 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h"
113 #endif 112 #endif
114 113
115 using gfx::RectToSkIRect; 114 using gfx::RectToSkIRect;
116 using gfx::SkIRectToRect; 115 using gfx::SkIRectToRect;
117 116
118 using blink::WebScreenInfo;
119 using blink::WebInputEvent; 117 using blink::WebInputEvent;
120 using blink::WebGestureEvent; 118 using blink::WebGestureEvent;
121 using blink::WebTouchEvent; 119 using blink::WebTouchEvent;
122 120
123 namespace content { 121 namespace content {
124 122
125 namespace { 123 namespace {
126 124
127 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting 125 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting
128 // the border of the view, in order to get valid movement information. However, 126 // the border of the view, in order to get valid movement information. However,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 #if defined(OS_WIN) 160 #if defined(OS_WIN)
163 switch (event->native_event().message) { 161 switch (event->native_event().message) {
164 case WM_XBUTTONUP: 162 case WM_XBUTTONUP:
165 case WM_NCXBUTTONUP: 163 case WM_NCXBUTTONUP:
166 return true; 164 return true;
167 } 165 }
168 #endif 166 #endif
169 return false; 167 return false;
170 } 168 }
171 169
172 void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) {
173 display::Screen* screen = display::Screen::GetScreen();
174 const display::Display display = window
175 ? screen->GetDisplayNearestWindow(window)
176 : screen->GetPrimaryDisplay();
177 results->rect = display.bounds();
178 results->availableRect = display.work_area();
179 // TODO(derat|oshima): Don't hardcode this. Get this from display object.
180 results->depth = 24;
181 results->depthPerComponent = 8;
182 results->deviceScaleFactor = display.device_scale_factor();
183
184 // The Display rotation and the WebScreenInfo orientation are not the same
185 // angle. The former is the physical display rotation while the later is the
186 // rotation required by the content to be shown properly on the screen, in
187 // other words, relative to the physical display.
188 results->orientationAngle = display.RotationAsDegree();
189 if (results->orientationAngle == 90)
190 results->orientationAngle = 270;
191 else if (results->orientationAngle == 270)
192 results->orientationAngle = 90;
193
194 results->orientationType =
195 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
196 }
197
198 bool IsFractionalScaleFactor(float scale_factor) { 170 bool IsFractionalScaleFactor(float scale_factor) {
199 return (scale_factor - static_cast<int>(scale_factor)) > 0; 171 return (scale_factor - static_cast<int>(scale_factor)) > 0;
200 } 172 }
201 173
202 // Reset unchanged touch point to StateStationary for touchmove and 174 // Reset unchanged touch point to StateStationary for touchmove and
203 // touchcancel. 175 // touchcancel.
204 void MarkUnchangedTouchPointsAsStationary( 176 void MarkUnchangedTouchPointsAsStationary(
205 blink::WebTouchEvent* event, 177 blink::WebTouchEvent* event,
206 int changed_touch_id) { 178 int changed_touch_id) {
207 if (event->type == blink::WebInputEvent::TouchMove || 179 if (event->type == blink::WebInputEvent::TouchMove ||
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 } 1081 }
1110 1082
1111 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1083 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
1112 const gfx::Size& desired_size) { 1084 const gfx::Size& desired_size) {
1113 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1085 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
1114 // matter what is returned here as GetBackingStore is the only caller of this 1086 // matter what is returned here as GetBackingStore is the only caller of this
1115 // method. TODO(jbates) implement this if other Aura code needs it. 1087 // method. TODO(jbates) implement this if other Aura code needs it.
1116 return false; 1088 return false;
1117 } 1089 }
1118 1090
1119 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
1120 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
1121 }
1122
1123 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 1091 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
1124 aura::Window* top_level = window_->GetToplevelWindow(); 1092 aura::Window* top_level = window_->GetToplevelWindow();
1125 gfx::Rect bounds(top_level->GetBoundsInScreen()); 1093 gfx::Rect bounds(top_level->GetBoundsInScreen());
1126 1094
1127 #if defined(OS_WIN) 1095 #if defined(OS_WIN)
1128 // TODO(zturner,iyengar): This will break when we remove support for NPAPI and 1096 // TODO(zturner,iyengar): This will break when we remove support for NPAPI and
1129 // remove the legacy hwnd, so a better fix will need to be decided when that 1097 // remove the legacy hwnd, so a better fix will need to be decided when that
1130 // happens. 1098 // happens.
1131 if (UsesNativeWindowFrame()) { 1099 if (UsesNativeWindowFrame()) {
1132 // aura::Window doesn't take into account non-client area of native windows 1100 // aura::Window doesn't take into account non-client area of native windows
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 void RenderWidgetHostViewAura::OnCaptureLost() { 1692 void RenderWidgetHostViewAura::OnCaptureLost() {
1725 host_->LostCapture(); 1693 host_->LostCapture();
1726 } 1694 }
1727 1695
1728 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { 1696 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {
1729 NOTREACHED(); 1697 NOTREACHED();
1730 } 1698 }
1731 1699
1732 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1700 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1733 float device_scale_factor) { 1701 float device_scale_factor) {
1734 // TODO(wjmaclean): can host_ ever be null? 1702 // TODO(wjmaclean): can host_ ever be null?
oshima 2016/07/29 18:11:46 This is called only when the window is attached to
wjmaclean 2016/07/29 18:40:04 Acknowledged.
1735 if (!host_ || !window_->GetRootWindow()) 1703 if (!host_ || !window_->GetRootWindow())
1736 return; 1704 return;
1737 1705
1738 UpdateScreenInfo(window_); 1706 RenderWidgetHostImpl* host =
1707 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1708 if (host && host->delegate())
1709 host->delegate()->UpdateDeviceScaleFactor(device_scale_factor);
1739 1710
1740 device_scale_factor_ = device_scale_factor; 1711 device_scale_factor_ = device_scale_factor;
1741 const display::Display display = 1712 const display::Display display =
1742 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); 1713 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
1743 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); 1714 DCHECK_EQ(device_scale_factor, display.device_scale_factor());
1744 current_cursor_.SetDisplayInfo(display); 1715 current_cursor_.SetDisplayInfo(display);
1745 SnapToPhysicalPixelBoundary(); 1716 SnapToPhysicalPixelBoundary();
1746 } 1717 }
1747 1718
1748 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { 1719 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) {
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 NOTREACHED() << "The text can not cover range."; 3002 NOTREACHED() << "The text can not cover range.";
3032 return; 3003 return;
3033 } 3004 }
3034 3005
3035 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3006 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3036 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3007 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3037 clipboard_writer.WriteText(text_selection->text.substr(pos, n)); 3008 clipboard_writer.WriteText(text_selection->text.substr(pos, n));
3038 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3009 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3039 } 3010 }
3040 3011
3041 ////////////////////////////////////////////////////////////////////////////////
3042 // RenderWidgetHostViewBase, public:
3043
3044 // static
3045 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3046 GetScreenInfoForWindow(results, NULL);
3047 }
3048
3049 } // namespace content 3012 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698