OLD | NEW |
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 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 scale_ = 1.f / ratio; | 61 scale_ = 1.f / ratio; |
62 | 62 |
63 // Center emulated view inside available view space. | 63 // Center emulated view inside available view space. |
64 offset_.set_x( | 64 offset_.set_x( |
65 (original_size().width() - scale_ * applied_widget_rect_.width()) / 2); | 65 (original_size().width() - scale_ * applied_widget_rect_.width()) / 2); |
66 offset_.set_y( | 66 offset_.set_y( |
67 (original_size().height() - scale_ * applied_widget_rect_.height()) / | 67 (original_size().height() - scale_ * applied_widget_rect_.height()) / |
68 2); | 68 2); |
69 } else { | 69 } else { |
70 scale_ = emulation_params_.scale; | 70 scale_ = emulation_params_.scale; |
71 offset_.SetPoint(emulation_params_.offset.x, emulation_params_.offset.y); | 71 offset_.SetPoint(0, 0); |
72 if (!emulation_params_.viewSize.width && | 72 if (!emulation_params_.viewSize.width && |
73 !emulation_params_.viewSize.height && scale_) { | 73 !emulation_params_.viewSize.height && scale_) { |
74 applied_widget_rect_.set_size( | 74 applied_widget_rect_.set_size( |
75 gfx::ScaleToRoundedSize(original_size(), 1.f / scale_)); | 75 gfx::ScaleToRoundedSize(original_size(), 1.f / scale_)); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 gfx::Rect window_screen_rect; | 79 gfx::Rect window_screen_rect; |
80 if (emulation_params_.screenPosition == | 80 if (emulation_params_.screenPosition == |
81 blink::WebDeviceEmulationParams::Desktop) { | 81 blink::WebDeviceEmulationParams::Desktop) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( | 192 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( |
193 const gfx::Rect& anchor) { | 193 const gfx::Rect& anchor) { |
194 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); | 194 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); |
195 scaled.set_x(scaled.x() + offset_.x()); | 195 scaled.set_x(scaled.x() + offset_.x()); |
196 scaled.set_y(scaled.y() + offset_.y()); | 196 scaled.set_y(scaled.y() + offset_.y()); |
197 return scaled; | 197 return scaled; |
198 } | 198 } |
199 | 199 |
200 } // namespace content | 200 } // namespace content |
OLD | NEW |