Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js |
| index acea052bce094791db15928820f94b6d61d17ff1..2600432b6baa9e24fac46cdeb186cae95eecff0e 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js |
| @@ -273,6 +273,23 @@ Emulation.DeviceModeModel = class { |
| } |
| /** |
| + * @return {boolean} |
| + */ |
| + isMobile() { |
|
dgozman
2017/01/13 23:38:48
_isMobile
ahmetemirercin
2017/01/16 17:52:01
Done.
|
| + switch (this._type) { |
| + case Emulation.DeviceModeModel.Type.Device: |
| + return this._device.mobile(); |
| + |
| + case Emulation.DeviceModeModel.Type.None: |
| + return false; |
| + |
| + case Emulation.DeviceModeModel.Type.Responsive: |
| + return this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile || |
| + this._uaSetting.get() === Emulation.DeviceModeModel.UA.MobileNoTouch; |
| + } |
| + } |
| + |
| + /** |
| * @return {!Common.Setting} |
| */ |
| scaleSetting() { |
| @@ -398,13 +415,13 @@ Emulation.DeviceModeModel = class { |
| _calculateAndEmulate(resetPageScaleFactor) { |
| if (!this._target) |
| this._onTargetAvailable = this._calculateAndEmulate.bind(this, resetPageScaleFactor); |
| - |
| + var mobile = this.isMobile(); |
| if (this._type === Emulation.DeviceModeModel.Type.Device) { |
| var orientation = this._device.orientationByName(this._mode.orientation); |
| var outline = this._currentOutline(); |
| var insets = this._currentInsets(); |
| this._fitScale = this._calculateFitScale(orientation.width, orientation.height, outline, insets); |
| - if (this._device.mobile()) { |
| + if (mobile) { |
| this._appliedUserAgentType = |
| this._device.touch() ? Emulation.DeviceModeModel.UA.Mobile : Emulation.DeviceModeModel.UA.MobileNoTouch; |
| } else { |
| @@ -413,16 +430,16 @@ Emulation.DeviceModeModel = class { |
| } |
| this._applyDeviceMetrics( |
| new Size(orientation.width, orientation.height), insets, outline, this._scaleSetting.get(), |
| - this._device.deviceScaleFactor, this._device.mobile(), |
| + this._device.deviceScaleFactor, mobile, |
| this._mode.orientation === Emulation.EmulatedDevice.Horizontal ? 'landscapePrimary' : 'portraitPrimary', |
| resetPageScaleFactor); |
| this._applyUserAgent(this._device.userAgent); |
| - this._applyTouch(this._device.touch(), this._device.mobile()); |
| + this._applyTouch(this._device.touch(), mobile); |
| } else if (this._type === Emulation.DeviceModeModel.Type.None) { |
| this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height); |
| this._appliedUserAgentType = Emulation.DeviceModeModel.UA.Desktop; |
| this._applyDeviceMetrics( |
| - this._availableSize, new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0), 1, 0, false, '', resetPageScaleFactor); |
| + this._availableSize, new Insets(0, 0, 0, 0), new Insets(0, 0, 0, 0), 1, 0, mobile, '', resetPageScaleFactor); |
| this._applyUserAgent(''); |
| this._applyTouch(false, false); |
| } else if (this._type === Emulation.DeviceModeModel.Type.Responsive) { |
| @@ -432,8 +449,6 @@ Emulation.DeviceModeModel = class { |
| var screenHeight = this._heightSetting.get(); |
| if (!screenHeight || screenHeight > this._preferredScaledHeight()) |
| screenHeight = this._preferredScaledHeight(); |
| - var mobile = this._uaSetting.get() === Emulation.DeviceModeModel.UA.Mobile || |
| - this._uaSetting.get() === Emulation.DeviceModeModel.UA.MobileNoTouch; |
| var defaultDeviceScaleFactor = mobile ? Emulation.DeviceModeModel.defaultMobileScaleFactor : 0; |
| this._fitScale = this._calculateFitScale(this._widthSetting.get(), this._heightSetting.get()); |
| this._appliedUserAgentType = this._uaSetting.get(); |
| @@ -523,6 +538,7 @@ Emulation.DeviceModeModel = class { |
| var pageWidth = screenSize.width - insets.left - insets.right; |
| var pageHeight = screenSize.height - insets.top - insets.bottom; |
| + this._emulatedPageSize = new Size(Math.floor(pageWidth * scale), Math.floor(pageHeight * scale)); |
| var positionX = insets.left; |
| var positionY = insets.top; |
| @@ -596,6 +612,26 @@ Emulation.DeviceModeModel = class { |
| } |
| } |
| + prepareForFullHeightScreenshot() { |
| + return this._target.pageAgent().getLayoutMetrics((err, layoutViewport, visualViewport, contentSize) => { |
| + var promises = []; |
| + var scaledScrollHeight = Math.floor(contentSize.height * visualViewport.scale * this._scale); |
| + promises.push(this._target.emulationAgent().forceViewport(0, 0, visualViewport.scale)); |
| + promises.push(this._target.emulationAgent().setDeviceMetricsOverride( |
|
dgozman
2017/01/13 23:38:48
nit: let's use params and invoke_setDeviceMetrrics
ahmetemirercin
2017/01/16 17:52:01
Done.
|
| + 0, 0, this._appliedDeviceScaleFactor, this.isMobile(), false, this._scale)); |
| + promises.push(this._target.emulationAgent().setVisibleSize(this._emulatedPageSize.width, scaledScrollHeight)); |
| + return Promise.all(promises); |
| + }); |
| + } |
| + |
| + resetVisibleSize() { |
| + this._target.emulationAgent().setVisibleSize(this._emulatedPageSize.width, this._emulatedPageSize.height); |
| + } |
| + |
| + resetViewport() { |
| + this._target.emulationAgent().resetViewport(); |
| + } |
| + |
| _deviceMetricsOverrideAppliedForTest() { |
| // Used for sniffing in tests. |
| } |