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

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

Issue 1727083002: Revert of [DevTools] Move screen orientation override to RenderWidgetScreenMetricsEmulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
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 2619c3d4016c6793659ff817f1d4cc5d65086b6b..14ed4df33182e0ee9fc713f9c901531cd69d62b0 100644
--- a/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js
@@ -55,6 +55,8 @@
this._touchEnabled = false;
/** @type {string} */
this._touchConfiguration = "";
+ /** @type {string} */
+ this._screenOrientation = "";
/** @type {number} */
this._fitScale = 1;
@@ -420,13 +422,15 @@
this._appliedUserAgentType = this._device.touch() ? WebInspector.DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch;
else
this._appliedUserAgentType = this._device.touch() ? WebInspector.DeviceModeModel.UA.DesktopTouch : WebInspector.DeviceModeModel.UA.Desktop;
- this._applyDeviceMetrics(new Size(orientation.width, orientation.height), this._mode.insets, this._scaleSetting.get(), this._device.deviceScaleFactor, this._device.mobile(), this._mode.orientation == WebInspector.EmulatedDevice.Horizontal ? "landscapePrimary" : "portraitPrimary", resetPageScaleFactor);
+ this._applyDeviceMetrics(new Size(orientation.width, orientation.height), this._mode.insets, this._scaleSetting.get(), this._device.deviceScaleFactor, this._device.mobile(), resetPageScaleFactor);
this._applyUserAgent(this._device.userAgent);
+ this._applyScreenOrientation(this._mode.orientation == WebInspector.EmulatedDevice.Horizontal ? "landscapePrimary" : "portraitPrimary");
} else if (this._type === WebInspector.DeviceModeModel.Type.None) {
this._fitScale = this._calculateFitScale(this._availableSize.width, this._availableSize.height);
this._appliedUserAgentType = WebInspector.DeviceModeModel.UA.Desktop;
- this._applyDeviceMetrics(this._availableSize, new Insets(0, 0, 0, 0), 1, 0, false, "", resetPageScaleFactor);
+ this._applyDeviceMetrics(this._availableSize, new Insets(0, 0, 0, 0), 1, 0, false, resetPageScaleFactor);
this._applyUserAgent("");
+ this._applyScreenOrientation("");
} else if (this._type === WebInspector.DeviceModeModel.Type.Responsive) {
var screenWidth = this._widthSetting.get();
if (!screenWidth || screenWidth > this._preferredScaledWidth())
@@ -438,8 +442,9 @@
var defaultDeviceScaleFactor = mobile ? WebInspector.DeviceModeModel.defaultMobileScaleFactor : 0;
this._fitScale = this._calculateFitScale(this._widthSetting.get(), this._heightSetting.get());
this._appliedUserAgentType = this._uaSetting.get();
- this._applyDeviceMetrics(new Size(screenWidth, screenHeight), new Insets(0, 0, 0, 0), this._scaleSetting.get(), this._deviceScaleFactorSetting.get() || defaultDeviceScaleFactor, mobile, screenHeight >= screenWidth ? "portraitPrimary" : "landscapePrimary", resetPageScaleFactor);
+ this._applyDeviceMetrics(new Size(screenWidth, screenHeight), new Insets(0, 0, 0, 0), this._scaleSetting.get(), this._deviceScaleFactorSetting.get() || defaultDeviceScaleFactor, mobile, resetPageScaleFactor);
this._applyUserAgent(mobile ? WebInspector.DeviceModeModel._defaultMobileUserAgent : "");
+ this._applyScreenOrientation(screenHeight >= screenWidth ? "portraitPrimary" : "landscapePrimary");
}
this._reapplyTouch();
this._updateCallback.call(null);
@@ -497,10 +502,9 @@
* @param {number} scale
* @param {number} deviceScaleFactor
* @param {boolean} mobile
- * @param {string} screenOrientation
* @param {boolean} resetPageScaleFactor
*/
- _applyDeviceMetrics: function(screenSize, insets, scale, deviceScaleFactor, mobile, screenOrientation, resetPageScaleFactor)
+ _applyDeviceMetrics: function(screenSize, insets, scale, deviceScaleFactor, mobile, resetPageScaleFactor)
{
screenSize.width = Math.max(1, Math.floor(screenSize.width));
screenSize.height = Math.max(1, Math.floor(screenSize.height));
@@ -509,7 +513,6 @@
var pageHeight = screenSize.height - insets.top - insets.bottom;
var positionX = insets.left;
var positionY = insets.top;
- var screenOrientationAngle = screenOrientation === "landscapePrimary" ? 90 : 0;
this._appliedDeviceSize = screenSize;
this._appliedDeviceScaleFactor = deviceScaleFactor || window.devicePixelRatio;
@@ -547,19 +550,13 @@
if (!this._target)
return Promise.resolve();
- var clear = !pageWidth && !pageHeight && !mobile && !deviceScaleFactor && scale === 1 && !screenOrientation;
+ var clear = !pageWidth && !pageHeight && !mobile && !deviceScaleFactor && scale === 1;
var allPromises = [];
if (resetPageScaleFactor)
allPromises.push(this._target.emulationAgent().resetPageScaleFactor());
- var setDevicePromise;
- if (clear) {
- setDevicePromise = this._target.emulationAgent().clearDeviceMetricsOverride(this._deviceMetricsOverrideAppliedForTest.bind(this));
- } else {
- var params = {width: pageWidth, height: pageHeight, deviceScaleFactor: deviceScaleFactor, mobile: mobile, fitWindow: false, scale: scale, screenWidth: screenSize.width, screenHeight: screenSize.height, positionX: positionX, positionY: positionY};
- if (screenOrientation)
- params.screenOrientation = {type: screenOrientation, angle: screenOrientationAngle};
- setDevicePromise = this._target.emulationAgent().invoke_setDeviceMetricsOverride(params, this._deviceMetricsOverrideAppliedForTest.bind(this));
- }
+ var setDevicePromise = clear ?
+ this._target.emulationAgent().clearDeviceMetricsOverride(this._deviceMetricsOverrideAppliedForTest.bind(this)) :
+ this._target.emulationAgent().setDeviceMetricsOverride(pageWidth, pageHeight, deviceScaleFactor, mobile, false, scale, 0, 0, screenSize.width, screenSize.height, positionX, positionY, this._deviceMetricsOverrideAppliedForTest.bind(this));
allPromises.push(setDevicePromise);
return Promise.all(allPromises);
}
@@ -617,5 +614,20 @@
target.emulationAgent().setTouchEmulationEnabled(touchEnabled, configuration);
this._touchEnabled = touchEnabled;
this._touchConfiguration = configuration;
+ },
+
+ /**
+ * @param {string} orientation
+ */
+ _applyScreenOrientation: function(orientation)
+ {
+ if (!this._target || orientation === this._screenOrientation)
+ return;
+
+ this._screenOrientation = orientation;
+ if (!this._screenOrientation)
+ this._target.screenOrientationAgent().clearScreenOrientationOverride();
+ else
+ this._target.screenOrientationAgent().setScreenOrientationOverride(this._screenOrientation === "landscapePrimary" ? 90 : 0, /** @type {!ScreenOrientationAgent.OrientationType} */ (this._screenOrientation));
}
}

Powered by Google App Engine
This is Rietveld 408576698