| Index: Source/devtools/front_end/OverridesSupport.js
|
| diff --git a/Source/devtools/front_end/OverridesSupport.js b/Source/devtools/front_end/OverridesSupport.js
|
| index 046d2a5d014e61855944c5432dedd12b5cc880d3..5ad421eb6c8c2d1df7f291e997a7ee8b4068b702 100644
|
| --- a/Source/devtools/front_end/OverridesSupport.js
|
| +++ b/Source/devtools/front_end/OverridesSupport.js
|
| @@ -61,31 +61,43 @@ WebInspector.OverridesSupport = function()
|
| * @param {number} width
|
| * @param {number} height
|
| * @param {number} deviceScaleFactor
|
| + * @param {number} textAutosizing (index into WebInspector.OverridesSupport.DeviceMetrics.TextAutosizingTypes).
|
| */
|
| -WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScaleFactor)
|
| +WebInspector.OverridesSupport.DeviceMetrics = function(width, height, deviceScaleFactor, textAutosizingOverride)
|
| {
|
| this.width = width;
|
| this.height = height;
|
| this.deviceScaleFactor = deviceScaleFactor;
|
| + this.textAutosizingOverride = textAutosizingOverride;
|
| }
|
|
|
| +WebInspector.OverridesSupport.DeviceMetrics.TextAutosizingTypes = ["Default", "Enabled", "Disabled"];
|
| +
|
| /**
|
| * @return {WebInspector.OverridesSupport.DeviceMetrics}
|
| */
|
| WebInspector.OverridesSupport.DeviceMetrics.parseSetting = function(value)
|
| {
|
| + var width = 0;
|
| + var height = 0;
|
| + var deviceScaleFactor = 1;
|
| + var textAutosizingOverride = 0;
|
| if (value) {
|
| var splitMetrics = value.split("x");
|
| - if (splitMetrics.length === 3)
|
| - return new WebInspector.OverridesSupport.DeviceMetrics(parseInt(splitMetrics[0], 10), parseInt(splitMetrics[1], 10), parseFloat(splitMetrics[2]));
|
| + if (splitMetrics.length === 4) {
|
| + width = parseInt(splitMetrics[0], 10);
|
| + height = parseInt(splitMetrics[1], 10);
|
| + deviceScaleFactor = parseFloat(splitMetrics[2]);
|
| + textAutosizingOverride = parseInt(splitMetrics[3], 10);
|
| + }
|
| }
|
| - return new WebInspector.OverridesSupport.DeviceMetrics(0, 0, 1);
|
| + return new WebInspector.OverridesSupport.DeviceMetrics(width, height, deviceScaleFactor, textAutosizingOverride);
|
| }
|
|
|
| /**
|
| * @return {?WebInspector.OverridesSupport.DeviceMetrics}
|
| */
|
| -WebInspector.OverridesSupport.DeviceMetrics.parseUserInput = function(widthString, heightString, deviceScaleFactorString)
|
| +WebInspector.OverridesSupport.DeviceMetrics.parseUserInput = function(widthString, heightString, deviceScaleFactorString, textAutosizingOverrideIndex)
|
| {
|
| function isUserInputValid(value, isInteger)
|
| {
|
| @@ -100,15 +112,17 @@ WebInspector.OverridesSupport.DeviceMetrics.parseUserInput = function(widthStrin
|
| var isWidthValid = isUserInputValid(widthString, true);
|
| var isHeightValid = isUserInputValid(heightString, true);
|
| var isDeviceScaleFactorValid = isUserInputValid(deviceScaleFactorString, false);
|
| + var isTextAutosizingOverrideValid = WebInspector.OverridesSupport.DeviceMetrics.TextAutosizingTypes[textAutosizingOverrideIndex] !== undefined;
|
|
|
| - if (!isWidthValid && !isHeightValid && !isDeviceScaleFactorValid)
|
| + if (!isWidthValid && !isHeightValid && !isDeviceScaleFactorValid && !isTextAutosizingOverrideValid)
|
| return null;
|
|
|
| var width = isWidthValid ? parseInt(widthString || "0", 10) : -1;
|
| var height = isHeightValid ? parseInt(heightString || "0", 10) : -1;
|
| var deviceScaleFactor = isDeviceScaleFactorValid ? parseFloat(deviceScaleFactorString) : -1;
|
| + var textAutosizingOverride = isTextAutosizingOverrideValid ? textAutosizingOverrideIndex : 0;
|
|
|
| - return new WebInspector.OverridesSupport.DeviceMetrics(width, height, deviceScaleFactor);
|
| + return new WebInspector.OverridesSupport.DeviceMetrics(width, height, deviceScaleFactor, textAutosizingOverride);
|
| }
|
|
|
| WebInspector.OverridesSupport.DeviceMetrics.prototype = {
|
| @@ -145,14 +159,21 @@ WebInspector.OverridesSupport.DeviceMetrics.prototype = {
|
| },
|
|
|
| /**
|
| + * @return {boolean}
|
| + */
|
| + isTextAutosizingOverrideValid: function()
|
| + {
|
| + return WebInspector.OverridesSupport.DeviceMetrics.TextAutosizingTypes[this.textAutosizingOverride] !== undefined;
|
| + },
|
| +
|
| + /**
|
| * @return {string}
|
| */
|
| toSetting: function()
|
| {
|
| if (!this.isValid())
|
| return "";
|
| -
|
| - return this.width && this.height ? this.width + "x" + this.height + "x" + this.deviceScaleFactor : "";
|
| + return this.width && this.height ? this.width + "x" + this.height + "x" + this.deviceScaleFactor + "x" + this.textAutosizingOverride : "";
|
| },
|
|
|
| /**
|
| @@ -177,6 +198,14 @@ WebInspector.OverridesSupport.DeviceMetrics.prototype = {
|
| deviceScaleFactorToInput: function()
|
| {
|
| return this.isDeviceScaleFactorValid() && this.deviceScaleFactor ? String(this.deviceScaleFactor) : "";
|
| + },
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + textAutosizingOverrideToIndex: function()
|
| + {
|
| + return this.isTextAutosizingOverrideValid() ? this.textAutosizingOverride : 0;
|
| }
|
| }
|
|
|
| @@ -351,7 +380,7 @@ WebInspector.OverridesSupport.prototype = {
|
| var active = metrics.width > 0 && metrics.height > 0;
|
| var dipWidth = Math.round(metrics.width / metrics.deviceScaleFactor);
|
| var dipHeight = Math.round(metrics.height / metrics.deviceScaleFactor);
|
| - PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metrics.deviceScaleFactor, WebInspector.settings.deviceFitWindow.get());
|
| + PageAgent.setDeviceMetricsOverride(dipWidth, dipHeight, metrics.deviceScaleFactor, WebInspector.settings.deviceFitWindow.get(), metrics.textAutosizingOverride);
|
| if (active != this._deviceMetricsOverridesActive) {
|
| PageAgent.reload(false);
|
| this._deviceMetricsOverridesActive = active;
|
|
|