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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 float overdraw_bottom_height, 255 float overdraw_bottom_height,
256 gfx::Rect resizer_rect, 256 gfx::Rect resizer_rect,
257 bool is_fullscreen) { 257 bool is_fullscreen) {
258 applied_widget_rect_.set_size(gfx::Size(params_.viewSize)); 258 applied_widget_rect_.set_size(gfx::Size(params_.viewSize));
259 if (!applied_widget_rect_.width()) 259 if (!applied_widget_rect_.width())
260 applied_widget_rect_.set_width(original_size_.width()); 260 applied_widget_rect_.set_width(original_size_.width());
261 if (!applied_widget_rect_.height()) 261 if (!applied_widget_rect_.height())
262 applied_widget_rect_.set_height(original_size_.height()); 262 applied_widget_rect_.set_height(original_size_.height());
263 263
264 if (params_.fitToView && !original_size_.IsEmpty()) { 264 if (params_.fitToView && !original_size_.IsEmpty()) {
265 int width_with_gutter = 265 int original_width = std::max(original_size_.width(), 1);
266 std::max(original_size_.width() - 2 * params_.viewInsets.width, 1); 266 int original_height = std::max(original_size_.height(), 1);
267 int height_with_gutter =
268 std::max(original_size_.height() - 2 * params_.viewInsets.height, 1);
269 float width_ratio = 267 float width_ratio =
270 static_cast<float>(applied_widget_rect_.width()) / width_with_gutter; 268 static_cast<float>(applied_widget_rect_.width()) / original_width;
271 float height_ratio = 269 float height_ratio =
272 static_cast<float>(applied_widget_rect_.height()) / height_with_gutter; 270 static_cast<float>(applied_widget_rect_.height()) / original_height;
273 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio)); 271 float ratio = std::max(1.0f, std::max(width_ratio, height_ratio));
274 scale_ = 1.f / ratio; 272 scale_ = 1.f / ratio;
275 273
276 // Center emulated view inside available view space. 274 // Center emulated view inside available view space.
277 offset_.set_x( 275 offset_.set_x(
278 (original_size_.width() - scale_ * applied_widget_rect_.width()) / 2); 276 (original_size_.width() - scale_ * applied_widget_rect_.width()) / 2);
279 offset_.set_y( 277 offset_.set_y(
280 (original_size_.height() - scale_ * applied_widget_rect_.height()) / 2); 278 (original_size_.height() - scale_ * applied_widget_rect_.height()) / 2);
281 } else { 279 } else {
282 scale_ = 1.f; 280 scale_ = params_.scale;
283 offset_.SetPoint(0, 0); 281 offset_.SetPoint(params_.offset.x, params_.offset.y);
284 } 282 }
285 283
286 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) { 284 if (params_.screenPosition == WebDeviceEmulationParams::Desktop) {
287 applied_widget_rect_.set_origin(original_view_screen_rect_.origin()); 285 applied_widget_rect_.set_origin(original_view_screen_rect_.origin());
288 widget_->screen_info_.rect = original_screen_info_.rect; 286 widget_->screen_info_.rect = original_screen_info_.rect;
289 widget_->screen_info_.availableRect = original_screen_info_.availableRect; 287 widget_->screen_info_.availableRect = original_screen_info_.availableRect;
290 widget_->window_screen_rect_ = original_window_screen_rect_; 288 widget_->window_screen_rect_ = original_window_screen_rect_;
291 } else { 289 } else {
292 applied_widget_rect_.set_origin(gfx::Point(0, 0)); 290 applied_widget_rect_.set_origin(gfx::Point(0, 0));
293 widget_->screen_info_.rect = applied_widget_rect_; 291 widget_->screen_info_.rect = applied_widget_rect_;
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2068 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2071 video_hole_frames_.AddObserver(frame); 2069 video_hole_frames_.AddObserver(frame);
2072 } 2070 }
2073 2071
2074 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2072 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2075 video_hole_frames_.RemoveObserver(frame); 2073 video_hole_frames_.RemoveObserver(frame);
2076 } 2074 }
2077 #endif // defined(VIDEO_HOLE) 2075 #endif // defined(VIDEO_HOLE)
2078 2076
2079 } // namespace content 2077 } // namespace content
OLDNEW
« 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