| 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 = new Insets(0, 0, 0, 0); |
| 438 if (Runtime.experiments.isEnabled("deviceFrames") && this._deviceOut
lineSetting.get()) |
| 439 outline = orientation.outlineInsets || outline; |
| 438 this._fitScale = this._calculateFitScale(orientation.width, orientat
ion.height); | 440 this._fitScale = this._calculateFitScale(orientation.width, orientat
ion.height); |
| 439 if (this._device.mobile()) | 441 if (this._device.mobile()) |
| 440 this._appliedUserAgentType = this._device.touch() ? WebInspector
.DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; | 442 this._appliedUserAgentType = this._device.touch() ? WebInspector
.DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; |
| 441 else | 443 else |
| 442 this._appliedUserAgentType = this._device.touch() ? WebInspector
.DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop; | 444 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); | 445 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); | 446 this._applyUserAgent(this._device.userAgent); |
| 445 this._applyTouch(this._device.touch(), this._device.mobile()); | 447 this._applyTouch(this._device.touch(), this._device.mobile()); |
| 446 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { | 448 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { |
| 447 this._fitScale = this._calculateFitScale(this._availableSize.width,
this._availableSize.height); | 449 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 | 496 * @param {string} userAgent |
| 495 */ | 497 */ |
| 496 _applyUserAgent: function(userAgent) | 498 _applyUserAgent: function(userAgent) |
| 497 { | 499 { |
| 498 WebInspector.multitargetNetworkManager.setUserAgentOverride(userAgent); | 500 WebInspector.multitargetNetworkManager.setUserAgentOverride(userAgent); |
| 499 }, | 501 }, |
| 500 | 502 |
| 501 /** | 503 /** |
| 502 * @param {!Size} screenSize | 504 * @param {!Size} screenSize |
| 503 * @param {!Insets} insets | 505 * @param {!Insets} insets |
| 504 * @param {!Insets|null} outline | 506 * @param {!Insets} outline |
| 505 * @param {number} scale | 507 * @param {number} scale |
| 506 * @param {number} deviceScaleFactor | 508 * @param {number} deviceScaleFactor |
| 507 * @param {boolean} mobile | 509 * @param {boolean} mobile |
| 508 * @param {string} screenOrientation | 510 * @param {string} screenOrientation |
| 509 * @param {boolean} resetPageScaleFactor | 511 * @param {boolean} resetPageScaleFactor |
| 510 */ | 512 */ |
| 511 _applyDeviceMetrics: function(screenSize, insets, outline, scale, deviceScal
eFactor, mobile, screenOrientation, resetPageScaleFactor) | 513 _applyDeviceMetrics: function(screenSize, insets, outline, scale, deviceScal
eFactor, mobile, screenOrientation, resetPageScaleFactor) |
| 512 { | 514 { |
| 513 screenSize.width = Math.max(1, Math.floor(screenSize.width)); | 515 screenSize.width = Math.max(1, Math.floor(screenSize.width)); |
| 514 screenSize.height = Math.max(1, Math.floor(screenSize.height)); | 516 screenSize.height = Math.max(1, Math.floor(screenSize.height)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 588 |
| 587 /** | 589 /** |
| 588 * @param {boolean} touchEnabled | 590 * @param {boolean} touchEnabled |
| 589 * @param {boolean} mobile | 591 * @param {boolean} mobile |
| 590 */ | 592 */ |
| 591 _applyTouch: function(touchEnabled, mobile) | 593 _applyTouch: function(touchEnabled, mobile) |
| 592 { | 594 { |
| 593 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); | 595 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); |
| 594 } | 596 } |
| 595 } | 597 } |
| OLD | NEW |