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

Unified Diff: content/renderer/render_widget.cc

Issue 348583002: [DevTools] Take passed scale/offset into account in ScreenMetricsEmulator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index dd278d60f679d2ef3d9a7e87294bdc4729a4b99d..a3f1e59f1ead3f91aabb26956a26c7e318d14af7 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -262,14 +262,12 @@ void RenderWidget::ScreenMetricsEmulator::Apply(
applied_widget_rect_.set_height(original_size_.height());
if (params_.fitToView && !original_size_.IsEmpty()) {
- int width_with_gutter =
- std::max(original_size_.width() - 2 * params_.viewInsets.width, 1);
- int height_with_gutter =
- std::max(original_size_.height() - 2 * params_.viewInsets.height, 1);
+ int original_width = std::max(original_size_.width(), 1);
+ int original_height = std::max(original_size_.height(), 1);
float width_ratio =
- static_cast<float>(applied_widget_rect_.width()) / width_with_gutter;
+ static_cast<float>(applied_widget_rect_.width()) / original_width;
float height_ratio =
- static_cast<float>(applied_widget_rect_.height()) / height_with_gutter;
+ static_cast<float>(applied_widget_rect_.height()) / original_height;
float ratio = std::max(1.0f, std::max(width_ratio, height_ratio));
scale_ = 1.f / ratio;
@@ -279,8 +277,8 @@ void RenderWidget::ScreenMetricsEmulator::Apply(
offset_.set_y(
(original_size_.height() - scale_ * applied_widget_rect_.height()) / 2);
} else {
- scale_ = 1.f;
- offset_.SetPoint(0, 0);
+ scale_ = params_.scale;
+ offset_.SetPoint(params_.offset.x, params_.offset.y);
}
if (params_.screenPosition == WebDeviceEmulationParams::Desktop) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698