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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 static_cast<float>(applied_widget_rect_.height()) / original_height; | 59 static_cast<float>(applied_widget_rect_.height()) / original_height; |
60 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); | 60 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); |
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 { | |
70 scale_ = emulation_params_.scale; | |
71 offset_.SetPoint(emulation_params_.offset.x, emulation_params_.offset.y); | |
72 if (!emulation_params_.viewSize.width && | |
73 !emulation_params_.viewSize.height && scale_) { | |
74 applied_widget_rect_.set_size( | |
75 gfx::ScaleToRoundedSize(original_size(), 1.f / scale_)); | |
76 } | |
77 } | 69 } |
78 | 70 |
79 gfx::Rect window_screen_rect; | 71 gfx::Rect window_screen_rect; |
80 if (emulation_params_.screenPosition == | 72 if (emulation_params_.screenPosition == |
81 blink::WebDeviceEmulationParams::Desktop) { | 73 blink::WebDeviceEmulationParams::Desktop) { |
82 applied_widget_rect_.set_origin(original_view_screen_rect_.origin()); | 74 applied_widget_rect_.set_origin(original_view_screen_rect_.origin()); |
83 modified_resize_params.screen_info.rect = original_screen_info().rect; | 75 modified_resize_params.screen_info.rect = original_screen_info().rect; |
84 modified_resize_params.screen_info.availableRect = | 76 modified_resize_params.screen_info.availableRect = |
85 original_screen_info().availableRect; | 77 original_screen_info().availableRect; |
86 window_screen_rect = original_window_screen_rect_; | 78 window_screen_rect = original_window_screen_rect_; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 163 |
172 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( | 164 gfx::Rect RenderWidgetScreenMetricsEmulator::AdjustValidationMessageAnchor( |
173 const gfx::Rect& anchor) { | 165 const gfx::Rect& anchor) { |
174 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); | 166 gfx::Rect scaled = gfx::ScaleToEnclosedRect(anchor, scale_); |
175 scaled.set_x(scaled.x() + offset_.x()); | 167 scaled.set_x(scaled.x() + offset_.x()); |
176 scaled.set_y(scaled.y() + offset_.y()); | 168 scaled.set_y(scaled.y() + offset_.y()); |
177 return scaled; | 169 return scaled; |
178 } | 170 } |
179 | 171 |
180 } // namespace content | 172 } // namespace content |
OLD | NEW |