Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 /** | 427 /** |
| 428 * @param {boolean} resetPageScaleFactor | 428 * @param {boolean} resetPageScaleFactor |
| 429 */ | 429 */ |
| 430 _calculateAndEmulate: function(resetPageScaleFactor) | 430 _calculateAndEmulate: function(resetPageScaleFactor) |
| 431 { | 431 { |
| 432 if (!this._target) | 432 if (!this._target) |
| 433 this._onTargetAvailable = this._calculateAndEmulate.bind(this, reset PageScaleFactor); | 433 this._onTargetAvailable = this._calculateAndEmulate.bind(this, reset PageScaleFactor); |
| 434 | 434 |
| 435 if (this._type === WebInspector.DeviceModeModel.Type.Device) { | 435 if (this._type === WebInspector.DeviceModeModel.Type.Device) { |
| 436 var orientation = this._device.orientationByName(this._mode.orientat ion); | 436 var orientation = this._device.orientationByName(this._mode.orientat ion); |
| 437 var outline = (this._deviceOutlineSetting.get() && Runtime.experimen ts.isEnabled("deviceFrames")) ? orientation.outlineInsets : new Insets(0,0,0,0); | 437 var outline = (this._deviceOutlineSetting.get() && Runtime.experimen ts.isEnabled("deviceFrames")) ? orientation.outlineInsets : new Insets(0,0,0,0); |
|
dgozman
2016/04/27 18:48:16
Let's fix here instead:
var outline = new Insets(
mmccoy1
2016/04/27 20:23:52
Right, thanks!
| |
| 438 this._fitScale = this._calculateFitScale(orientation.width, orientat ion.height); | 438 this._fitScale = this._calculateFitScale(orientation.width, orientat ion.height); |
| 439 if (this._device.mobile()) | 439 if (this._device.mobile()) |
| 440 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; | 440 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; |
| 441 else | 441 else |
| 442 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop; | 442 this._appliedUserAgentType = this._device.touch() ? WebInspector .DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop; |
| 443 this._applyDeviceMetrics(new Size(orientation.width, orientation.hei ght), this._mode.insets, outline, this._scaleSetting.get(), this._device.deviceS caleFactor, this._device.mobile(), this._mode.orientation == WebInspector.Emulat edDevice.Horizontal ? "landscapePrimary" : "portraitPrimary", resetPageScaleFact or); | 443 this._applyDeviceMetrics(new Size(orientation.width, orientation.hei ght), this._mode.insets, outline, this._scaleSetting.get(), this._device.deviceS caleFactor, this._device.mobile(), this._mode.orientation == WebInspector.Emulat edDevice.Horizontal ? "landscapePrimary" : "portraitPrimary", resetPageScaleFact or); |
| 444 this._applyUserAgent(this._device.userAgent); | 444 this._applyUserAgent(this._device.userAgent); |
| 445 this._applyTouch(this._device.touch(), this._device.mobile()); | 445 this._applyTouch(this._device.touch(), this._device.mobile()); |
| 446 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { | 446 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { |
| 447 this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height); | 447 this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 * @param {string} userAgent | 494 * @param {string} userAgent |
| 495 */ | 495 */ |
| 496 _applyUserAgent: function(userAgent) | 496 _applyUserAgent: function(userAgent) |
| 497 { | 497 { |
| 498 WebInspector.multitargetNetworkManager.setUserAgentOverride(userAgent); | 498 WebInspector.multitargetNetworkManager.setUserAgentOverride(userAgent); |
| 499 }, | 499 }, |
| 500 | 500 |
| 501 /** | 501 /** |
| 502 * @param {!Size} screenSize | 502 * @param {!Size} screenSize |
| 503 * @param {!Insets} insets | 503 * @param {!Insets} insets |
| 504 * @param {!Insets|null} outline | 504 * @param {!Insets|null} outline |
|
dgozman
2016/04/27 18:48:16
... and mark this as non-null.
mmccoy1
2016/04/27 20:23:52
Done.
| |
| 505 * @param {number} scale | 505 * @param {number} scale |
| 506 * @param {number} deviceScaleFactor | 506 * @param {number} deviceScaleFactor |
| 507 * @param {boolean} mobile | 507 * @param {boolean} mobile |
| 508 * @param {string} screenOrientation | 508 * @param {string} screenOrientation |
| 509 * @param {boolean} resetPageScaleFactor | 509 * @param {boolean} resetPageScaleFactor |
| 510 */ | 510 */ |
| 511 _applyDeviceMetrics: function(screenSize, insets, outline, scale, deviceScal eFactor, mobile, screenOrientation, resetPageScaleFactor) | 511 _applyDeviceMetrics: function(screenSize, insets, outline, scale, deviceScal eFactor, mobile, screenOrientation, resetPageScaleFactor) |
| 512 { | 512 { |
| 513 screenSize.width = Math.max(1, Math.floor(screenSize.width)); | 513 screenSize.width = Math.max(1, Math.floor(screenSize.width)); |
| 514 screenSize.height = Math.max(1, Math.floor(screenSize.height)); | 514 screenSize.height = Math.max(1, Math.floor(screenSize.height)); |
| 515 | 515 |
| 516 var pageWidth = screenSize.width - insets.left - insets.right; | 516 var pageWidth = screenSize.width - insets.left - insets.right; |
| 517 var pageHeight = screenSize.height - insets.top - insets.bottom; | 517 var pageHeight = screenSize.height - insets.top - insets.bottom; |
| 518 | 518 |
| 519 var positionX = insets.left; | 519 var positionX = insets.left; |
| 520 var positionY = insets.top; | 520 var positionY = insets.top; |
| 521 var screenOrientationAngle = screenOrientation === "landscapePrimary" ? 90 : 0; | 521 var screenOrientationAngle = screenOrientation === "landscapePrimary" ? 90 : 0; |
| 522 | 522 |
| 523 this._appliedDeviceSize = screenSize; | 523 this._appliedDeviceSize = screenSize; |
| 524 this._appliedDeviceScaleFactor = deviceScaleFactor || window.devicePixel Ratio; | 524 this._appliedDeviceScaleFactor = deviceScaleFactor || window.devicePixel Ratio; |
| 525 if (!outline) | |
| 526 outline = new Insets(0,0,0,0); | |
| 527 | |
| 525 this._screenRect = new WebInspector.Rect( | 528 this._screenRect = new WebInspector.Rect( |
| 526 Math.max(0, (this._availableSize.width - screenSize.width * scale) / 2), | 529 Math.max(0, (this._availableSize.width - screenSize.width * scale) / 2), |
| 527 outline.top * scale, | 530 outline.top * scale, |
| 528 screenSize.width * scale, | 531 screenSize.width * scale, |
| 529 screenSize.height * scale); | 532 screenSize.height * scale); |
| 530 this._outlineRect = new WebInspector.Rect( | 533 this._outlineRect = new WebInspector.Rect( |
| 531 Math.max(0, this._screenRect.left - outline.left * scale), | 534 Math.max(0, this._screenRect.left - outline.left * scale), |
| 532 0, | 535 0, |
| 533 (outline.left + screenSize.width + outline.right) * scale, | 536 (outline.left + screenSize.width + outline.right) * scale, |
| 534 (outline.top + screenSize.height + outline.bottom) * scale); | 537 (outline.top + screenSize.height + outline.bottom) * scale); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 | 589 |
| 587 /** | 590 /** |
| 588 * @param {boolean} touchEnabled | 591 * @param {boolean} touchEnabled |
| 589 * @param {boolean} mobile | 592 * @param {boolean} mobile |
| 590 */ | 593 */ |
| 591 _applyTouch: function(touchEnabled, mobile) | 594 _applyTouch: function(touchEnabled, mobile) |
| 592 { | 595 { |
| 593 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); | 596 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl ed, mobile); |
| 594 } | 597 } |
| 595 } | 598 } |
| OLD | NEW |