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

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: Version of patch without second test. 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "content/common/text_input_state.h" 50 #include "content/common/text_input_state.h"
51 #include "content/common/view_messages.h" 51 #include "content/common/view_messages.h"
52 #include "content/public/browser/content_browser_client.h" 52 #include "content/public/browser/content_browser_client.h"
53 #include "content/public/browser/overscroll_configuration.h" 53 #include "content/public/browser/overscroll_configuration.h"
54 #include "content/public/browser/render_view_host.h" 54 #include "content/public/browser/render_view_host.h"
55 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 55 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
56 #include "content/public/browser/user_metrics.h" 56 #include "content/public/browser/user_metrics.h"
57 #include "content/public/common/child_process_host.h" 57 #include "content/public/common/child_process_host.h"
58 #include "content/public/common/content_switches.h" 58 #include "content/public/common/content_switches.h"
59 #include "gpu/ipc/common/gpu_messages.h" 59 #include "gpu/ipc/common/gpu_messages.h"
60 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
61 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 60 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
62 #include "third_party/WebKit/public/web/WebInputEvent.h" 61 #include "third_party/WebKit/public/web/WebInputEvent.h"
63 #include "ui/aura/client/aura_constants.h" 62 #include "ui/aura/client/aura_constants.h"
64 #include "ui/aura/client/cursor_client.h" 63 #include "ui/aura/client/cursor_client.h"
65 #include "ui/aura/client/cursor_client_observer.h" 64 #include "ui/aura/client/cursor_client_observer.h"
66 #include "ui/aura/client/focus_client.h" 65 #include "ui/aura/client/focus_client.h"
67 #include "ui/aura/client/screen_position_client.h" 66 #include "ui/aura/client/screen_position_client.h"
68 #include "ui/aura/client/window_tree_client.h" 67 #include "ui/aura/client/window_tree_client.h"
69 #include "ui/aura/env.h" 68 #include "ui/aura/env.h"
70 #include "ui/aura/window.h" 69 #include "ui/aura/window.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 #endif 108 #endif
110 109
111 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 110 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
112 #include "ui/base/ime/linux/text_edit_command_auralinux.h" 111 #include "ui/base/ime/linux/text_edit_command_auralinux.h"
113 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" 112 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h"
114 #endif 113 #endif
115 114
116 using gfx::RectToSkIRect; 115 using gfx::RectToSkIRect;
117 using gfx::SkIRectToRect; 116 using gfx::SkIRectToRect;
118 117
119 using blink::WebScreenInfo;
120 using blink::WebInputEvent; 118 using blink::WebInputEvent;
121 using blink::WebGestureEvent; 119 using blink::WebGestureEvent;
122 using blink::WebTouchEvent; 120 using blink::WebTouchEvent;
123 121
124 namespace content { 122 namespace content {
125 123
126 namespace { 124 namespace {
127 125
128 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting 126 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting
129 // the border of the view, in order to get valid movement information. However, 127 // 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
163 #if defined(OS_WIN) 161 #if defined(OS_WIN)
164 switch (event->native_event().message) { 162 switch (event->native_event().message) {
165 case WM_XBUTTONUP: 163 case WM_XBUTTONUP:
166 case WM_NCXBUTTONUP: 164 case WM_NCXBUTTONUP:
167 return true; 165 return true;
168 } 166 }
169 #endif 167 #endif
170 return false; 168 return false;
171 } 169 }
172 170
173 void GetScreenInfoForWindow(WebScreenInfo* results, aura::Window* window) {
174 display::Screen* screen = display::Screen::GetScreen();
175 const display::Display display = window
176 ? screen->GetDisplayNearestWindow(window)
177 : screen->GetPrimaryDisplay();
178 results->rect = display.bounds();
179 results->availableRect = display.work_area();
180 // TODO(derat|oshima): Don't hardcode this. Get this from display object.
181 results->depth = 24;
182 results->depthPerComponent = 8;
183 results->deviceScaleFactor = display.device_scale_factor();
184
185 // The Display rotation and the WebScreenInfo orientation are not the same
186 // angle. The former is the physical display rotation while the later is the
187 // rotation required by the content to be shown properly on the screen, in
188 // other words, relative to the physical display.
189 results->orientationAngle = display.RotationAsDegree();
190 if (results->orientationAngle == 90)
191 results->orientationAngle = 270;
192 else if (results->orientationAngle == 270)
193 results->orientationAngle = 90;
194
195 results->orientationType =
196 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
197 }
198
199 bool IsFractionalScaleFactor(float scale_factor) { 171 bool IsFractionalScaleFactor(float scale_factor) {
200 return (scale_factor - static_cast<int>(scale_factor)) > 0; 172 return (scale_factor - static_cast<int>(scale_factor)) > 0;
201 } 173 }
202 174
203 // Reset unchanged touch point to StateStationary for touchmove and 175 // Reset unchanged touch point to StateStationary for touchmove and
204 // touchcancel. 176 // touchcancel.
205 void MarkUnchangedTouchPointsAsStationary( 177 void MarkUnchangedTouchPointsAsStationary(
206 blink::WebTouchEvent* event, 178 blink::WebTouchEvent* event,
207 int changed_touch_id) { 179 int changed_touch_id) {
208 if (event->type == blink::WebInputEvent::TouchMove || 180 if (event->type == blink::WebInputEvent::TouchMove ||
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1084 }
1113 1085
1114 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1086 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
1115 const gfx::Size& desired_size) { 1087 const gfx::Size& desired_size) {
1116 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1088 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't
1117 // matter what is returned here as GetBackingStore is the only caller of this 1089 // matter what is returned here as GetBackingStore is the only caller of this
1118 // method. TODO(jbates) implement this if other Aura code needs it. 1090 // method. TODO(jbates) implement this if other Aura code needs it.
1119 return false; 1091 return false;
1120 } 1092 }
1121 1093
1122 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
1123 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
1124 }
1125
1126 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 1094 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
1127 aura::Window* top_level = window_->GetToplevelWindow(); 1095 aura::Window* top_level = window_->GetToplevelWindow();
1128 gfx::Rect bounds(top_level->GetBoundsInScreen()); 1096 gfx::Rect bounds(top_level->GetBoundsInScreen());
1129 1097
1130 #if defined(OS_WIN) 1098 #if defined(OS_WIN)
1131 // TODO(zturner,iyengar): This will break when we remove support for NPAPI and 1099 // TODO(zturner,iyengar): This will break when we remove support for NPAPI and
1132 // remove the legacy hwnd, so a better fix will need to be decided when that 1100 // remove the legacy hwnd, so a better fix will need to be decided when that
1133 // happens. 1101 // happens.
1134 if (UsesNativeWindowFrame()) { 1102 if (UsesNativeWindowFrame()) {
1135 // aura::Window doesn't take into account non-client area of native windows 1103 // 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
1727 void RenderWidgetHostViewAura::OnCaptureLost() { 1695 void RenderWidgetHostViewAura::OnCaptureLost() {
1728 host_->LostCapture(); 1696 host_->LostCapture();
1729 } 1697 }
1730 1698
1731 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { 1699 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {
1732 NOTREACHED(); 1700 NOTREACHED();
1733 } 1701 }
1734 1702
1735 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1703 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1736 float device_scale_factor) { 1704 float device_scale_factor) {
1737 // TODO(wjmaclean): can host_ ever be null? 1705 if (!window_->GetRootWindow())
1738 if (!host_ || !window_->GetRootWindow())
1739 return; 1706 return;
1740 1707
1741 UpdateScreenInfo(window_); 1708 RenderWidgetHostImpl* host =
1709 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1710 if (host && host->delegate())
1711 host->delegate()->UpdateDeviceScaleFactor(device_scale_factor);
1742 1712
1743 device_scale_factor_ = device_scale_factor; 1713 device_scale_factor_ = device_scale_factor;
1744 const display::Display display = 1714 const display::Display display =
1745 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); 1715 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
1746 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); 1716 DCHECK_EQ(device_scale_factor, display.device_scale_factor());
1747 current_cursor_.SetDisplayInfo(display); 1717 current_cursor_.SetDisplayInfo(display);
1748 SnapToPhysicalPixelBoundary(); 1718 SnapToPhysicalPixelBoundary();
1749 } 1719 }
1750 1720
1751 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { 1721 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) {
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 NOTREACHED() << "The text can not cover range."; 3051 NOTREACHED() << "The text can not cover range.";
3082 return; 3052 return;
3083 } 3053 }
3084 3054
3085 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3055 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3086 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3056 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3087 clipboard_writer.WriteText(text_selection->text.substr(pos, n)); 3057 clipboard_writer.WriteText(text_selection->text.substr(pos, n));
3088 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3058 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3089 } 3059 }
3090 3060
3091 ////////////////////////////////////////////////////////////////////////////////
3092 // RenderWidgetHostViewBase, public:
3093
3094 // static
3095 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3096 GetScreenInfoForWindow(results, NULL);
3097 }
3098
3099 } // namespace content 3061 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698