| 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 = new Insets(0, 0, 0, 0); | 437 var outline = new Insets(0, 20, 0, 0); |
| 438 if (Runtime.experiments.isEnabled("deviceFrames") && this._deviceOut
lineSetting.get()) | 438 if (Runtime.experiments.isEnabled("deviceFrames") && this._deviceOut
lineSetting.get()) |
| 439 outline = orientation.outlineInsets || outline; | 439 outline = orientation.outlineInsets || outline; |
| 440 this._fitScale = this._calculateFitScale(orientation.width, orientat
ion.height); | 440 this._fitScale = this._calculateFitScale(orientation.width, orientat
ion.height); |
| 441 if (this._device.mobile()) | 441 if (this._device.mobile()) |
| 442 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; |
| 443 else | 443 else |
| 444 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; |
| 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); | 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); |
| 446 this._applyUserAgent(this._device.userAgent); | 446 this._applyUserAgent(this._device.userAgent); |
| 447 this._applyTouch(this._device.touch(), this._device.mobile()); | 447 this._applyTouch(this._device.touch(), this._device.mobile()); |
| 448 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { | 448 } else if (this._type === WebInspector.DeviceModeModel.Type.None) { |
| 449 this._fitScale = this._calculateFitScale(this._availableSize.width,
this._availableSize.height); | 449 this._fitScale = this._calculateFitScale(this._availableSize.width,
this._availableSize.height); |
| 450 this._appliedUserAgentType = WebInspector.DeviceModeModel.UA.Desktop
; | 450 this._appliedUserAgentType = WebInspector.DeviceModeModel.UA.Desktop
; |
| 451 this._applyDeviceMetrics(this._availableSize, new Insets(0, 0, 0, 0)
, new Insets(0, 0, 0, 0), 1, 0, false, "", resetPageScaleFactor); | 451 this._applyDeviceMetrics(this._availableSize, new Insets(0, 0, 0, 0)
, new Insets(0, 20, 0, 0), 1, 0, false, "", resetPageScaleFactor); |
| 452 this._applyUserAgent(""); | 452 this._applyUserAgent(""); |
| 453 this._applyTouch(false, false); | 453 this._applyTouch(false, false); |
| 454 } else if (this._type === WebInspector.DeviceModeModel.Type.Responsive)
{ | 454 } else if (this._type === WebInspector.DeviceModeModel.Type.Responsive)
{ |
| 455 var screenWidth = this._widthSetting.get(); | 455 var screenWidth = this._widthSetting.get(); |
| 456 if (!screenWidth || screenWidth > this._preferredScaledWidth()) | 456 if (!screenWidth || screenWidth > this._preferredScaledWidth()) |
| 457 screenWidth = this._preferredScaledWidth(); | 457 screenWidth = this._preferredScaledWidth(); |
| 458 var screenHeight = this._heightSetting.get(); | 458 var screenHeight = this._heightSetting.get(); |
| 459 if (!screenHeight || screenHeight > this._preferredScaledHeight()) | 459 if (!screenHeight || screenHeight > this._preferredScaledHeight()) |
| 460 screenHeight = this._preferredScaledHeight(); | 460 screenHeight = this._preferredScaledHeight(); |
| 461 var mobile = this._uaSetting.get() === WebInspector.DeviceModeModel.
UA.Mobile || this._uaSetting.get() === WebInspector.DeviceModeModel.UA.MobileNoT
ouch; | 461 var mobile = this._uaSetting.get() === WebInspector.DeviceModeModel.
UA.Mobile || this._uaSetting.get() === WebInspector.DeviceModeModel.UA.MobileNoT
ouch; |
| 462 var defaultDeviceScaleFactor = mobile ? WebInspector.DeviceModeModel
.defaultMobileScaleFactor : 0; | 462 var defaultDeviceScaleFactor = mobile ? WebInspector.DeviceModeModel
.defaultMobileScaleFactor : 0; |
| 463 this._fitScale = this._calculateFitScale(this._widthSetting.get(), t
his._heightSetting.get()); | 463 this._fitScale = this._calculateFitScale(this._widthSetting.get(), t
his._heightSetting.get()); |
| 464 this._appliedUserAgentType = this._uaSetting.get(); | 464 this._appliedUserAgentType = this._uaSetting.get(); |
| 465 this._applyDeviceMetrics(new Size(screenWidth, screenHeight), new In
sets(0, 0, 0, 0), new Insets(0, 0, 0, 0), this._scaleSetting.get(), this._device
ScaleFactorSetting.get() || defaultDeviceScaleFactor, mobile, screenHeight >= sc
reenWidth ? "portraitPrimary" : "landscapePrimary", resetPageScaleFactor); | 465 this._applyDeviceMetrics(new Size(screenWidth, screenHeight), new In
sets(0, 0, 0, 0), new Insets(0, 20, 0, 0), this._scaleSetting.get(), this._devic
eScaleFactorSetting.get() || defaultDeviceScaleFactor, mobile, screenHeight >= s
creenWidth ? "portraitPrimary" : "landscapePrimary", resetPageScaleFactor); |
| 466 this._applyUserAgent(mobile ? WebInspector.DeviceModeModel._defaultM
obileUserAgent : ""); | 466 this._applyUserAgent(mobile ? WebInspector.DeviceModeModel._defaultM
obileUserAgent : ""); |
| 467 this._applyTouch(this._uaSetting.get() === WebInspector.DeviceModeMo
del.UA.DesktopTouch || this._uaSetting.get() === WebInspector.DeviceModeModel.UA
.Mobile, this._uaSetting.get() === WebInspector.DeviceModeModel.UA.Mobile); | 467 this._applyTouch(this._uaSetting.get() === WebInspector.DeviceModeMo
del.UA.DesktopTouch || this._uaSetting.get() === WebInspector.DeviceModeModel.UA
.Mobile, this._uaSetting.get() === WebInspector.DeviceModeModel.UA.Mobile); |
| 468 } | 468 } |
| 469 if (this._target) | 469 if (this._target) |
| 470 this._target.renderingAgent().setShowViewportSizeOnResize(this._type
=== WebInspector.DeviceModeModel.Type.None); | 470 this._target.renderingAgent().setShowViewportSizeOnResize(this._type
=== WebInspector.DeviceModeModel.Type.None); |
| 471 this._updateCallback.call(null); | 471 this._updateCallback.call(null); |
| 472 }, | 472 }, |
| 473 | 473 |
| 474 /** | 474 /** |
| 475 * @param {number} screenWidth | 475 * @param {number} screenWidth |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 /** | 589 /** |
| 590 * @param {boolean} touchEnabled | 590 * @param {boolean} touchEnabled |
| 591 * @param {boolean} mobile | 591 * @param {boolean} mobile |
| 592 */ | 592 */ |
| 593 _applyTouch: function(touchEnabled, mobile) | 593 _applyTouch: function(touchEnabled, mobile) |
| 594 { | 594 { |
| 595 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); | 595 WebInspector.MultitargetTouchModel.instance().setTouchEnabled(touchEnabl
ed, mobile); |
| 596 } | 596 } |
| 597 } | 597 } |
| OLD | NEW |