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

Side by Side Diff: content/renderer/devtools/render_widget_screen_metrics_emulator.cc

Issue 2183533003: Fix the mobile emulator to use the correct device scale when disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/screen-orientation-override-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/devtools/render_widget_screen_metrics_emulator.h" 5 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h"
6 6
7 #include "content/common/resize_params.h" 7 #include "content/common/resize_params.h"
8 #include "content/public/common/context_menu_params.h" 8 #include "content/public/common/context_menu_params.h"
9 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega te.h" 9 #include "content/renderer/devtools/render_widget_screen_metrics_emulator_delega te.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 RenderWidgetScreenMetricsEmulator::RenderWidgetScreenMetricsEmulator( 13 RenderWidgetScreenMetricsEmulator::RenderWidgetScreenMetricsEmulator(
14 RenderWidgetScreenMetricsEmulatorDelegate* delegate, 14 RenderWidgetScreenMetricsEmulatorDelegate* delegate,
15 const blink::WebDeviceEmulationParams& params, 15 const blink::WebDeviceEmulationParams& params,
16 const ResizeParams& resize_params, 16 const ResizeParams& resize_params,
17 const gfx::Rect& view_screen_rect, 17 const gfx::Rect& view_screen_rect,
18 const gfx::Rect& window_screen_rect) 18 const gfx::Rect& window_screen_rect)
19 : delegate_(delegate), 19 : delegate_(delegate),
20 emulation_params_(params), 20 emulation_params_(params),
21 scale_(1.f), 21 scale_(1.f),
22 original_resize_params_(resize_params), 22 original_resize_params_(resize_params),
23 original_view_screen_rect_(view_screen_rect), 23 original_view_screen_rect_(view_screen_rect),
24 original_window_screen_rect_(window_screen_rect) { 24 original_window_screen_rect_(window_screen_rect) {
25 } 25 }
26 26
27 RenderWidgetScreenMetricsEmulator::~RenderWidgetScreenMetricsEmulator() { 27 RenderWidgetScreenMetricsEmulator::~RenderWidgetScreenMetricsEmulator() {
28 delegate_->Resize(original_resize_params_);
28 delegate_->SetScreenMetricsEmulationParameters(false, emulation_params_); 29 delegate_->SetScreenMetricsEmulationParameters(false, emulation_params_);
29 delegate_->SetScreenRects(original_view_screen_rect_, 30 delegate_->SetScreenRects(original_view_screen_rect_,
30 original_window_screen_rect_); 31 original_window_screen_rect_);
31 delegate_->Resize(original_resize_params_);
32 } 32 }
33 33
34 void RenderWidgetScreenMetricsEmulator::ChangeEmulationParams( 34 void RenderWidgetScreenMetricsEmulator::ChangeEmulationParams(
35 const blink::WebDeviceEmulationParams& params) { 35 const blink::WebDeviceEmulationParams& params) {
36 emulation_params_ = params; 36 emulation_params_ = params;
37 Apply(); 37 Apply();
38 } 38 }
39 39
40 void RenderWidgetScreenMetricsEmulator::Apply() { 40 void RenderWidgetScreenMetricsEmulator::Apply() {
41 ResizeParams modified_resize_params = original_resize_params_; 41 ResizeParams modified_resize_params = original_resize_params_;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( 169 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor(
170 const gfx::Rect& anchor) { 170 const gfx::Rect& anchor) {
171 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); 171 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_);
172 scaled.set_x(scaled.x() + offset_.x()); 172 scaled.set_x(scaled.x() + offset_.x());
173 scaled.set_y(scaled.y() + offset_.y()); 173 scaled.set_y(scaled.y() + offset_.y());
174 return scaled; 174 return scaled;
175 } 175 }
176 176
177 } // namespace content 177 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/inspector/screen-orientation-override-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698