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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js

Issue 2457883004: DevTools: fix rounding of scale in device mode (Closed)
Patch Set: Created 4 years, 1 month 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 | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @param {function()} updateCallback 7 * @param {function()} updateCallback
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.DeviceModeModel = function(updateCallback) 10 WebInspector.DeviceModeModel = function(updateCallback)
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 * @param {!Insets=} insets 501 * @param {!Insets=} insets
502 * @return {number} 502 * @return {number}
503 */ 503 */
504 _calculateFitScale: function(screenWidth, screenHeight, outline, insets) 504 _calculateFitScale: function(screenWidth, screenHeight, outline, insets)
505 { 505 {
506 var outlineWidth = outline ? outline.left + outline.right : 0; 506 var outlineWidth = outline ? outline.left + outline.right : 0;
507 var outlineHeight = outline ? outline.top + outline.bottom : 0; 507 var outlineHeight = outline ? outline.top + outline.bottom : 0;
508 var insetsWidth = insets ? insets.left + insets.right : 0; 508 var insetsWidth = insets ? insets.left + insets.right : 0;
509 var insetsHeight = insets ? insets.top + insets.bottom : 0; 509 var insetsHeight = insets ? insets.top + insets.bottom : 0;
510 var scale = Math.min(screenWidth ? this._preferredSize.width / (screenWi dth + outlineWidth) : 1, screenHeight ? this._preferredSize.height / (screenHeig ht + outlineHeight) : 1); 510 var scale = Math.min(screenWidth ? this._preferredSize.width / (screenWi dth + outlineWidth) : 1, screenHeight ? this._preferredSize.height / (screenHeig ht + outlineHeight) : 1);
511 scale = Math.min(Math.ceil(scale * 100), 100); 511 scale = Math.min(Math.floor(scale * 100), 100);
512 512
513 var sharpScale = scale; 513 var sharpScale = scale;
514 while (sharpScale > scale * 0.7) { 514 while (sharpScale > scale * 0.7) {
515 var sharp = true; 515 var sharp = true;
516 if (screenWidth) 516 if (screenWidth)
517 sharp = sharp && Number.isInteger((screenWidth - insetsWidth) * sharpScale / 100); 517 sharp = sharp && Number.isInteger((screenWidth - insetsWidth) * sharpScale / 100);
518 if (screenHeight) 518 if (screenHeight)
519 sharp = sharp && Number.isInteger((screenHeight - insetsHeight) * sharpScale / 100); 519 sharp = sharp && Number.isInteger((screenHeight - insetsHeight) * sharpScale / 100);
520 if (sharp) 520 if (sharp)
521 return sharpScale / 100; 521 return sharpScale / 100;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 630
631 /** 631 /**
632 * @param {boolean} touchEnabled 632 * @param {boolean} touchEnabled
633 * @param {boolean} mobile 633 * @param {boolean} mobile
634 */ 634 */
635 _applyTouch: function(touchEnabled, mobile) 635 _applyTouch: function(touchEnabled, mobile)
636 { 636 {
637 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); 637 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile);
638 } 638 }
639 } 639 }
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