Index: third_party/WebKit/Source/devtools/front_end/emulation/DevicesSettingsTab.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/emulation/DevicesSettingsTab.js b/third_party/WebKit/Source/devtools/front_end/emulation/DevicesSettingsTab.js |
index 500fc75ebf9d6158b3d71390c209b544efc93499..bee660b0b731d7ca5ffac024951f1a8644ac97a1 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/emulation/DevicesSettingsTab.js |
+++ b/third_party/WebKit/Source/devtools/front_end/emulation/DevicesSettingsTab.js |
@@ -18,6 +18,9 @@ WebInspector.DevicesSettingsTab = function() |
header.createChild("h3").createTextChild(WebInspector.UIString("Emulated Devices")); |
this.containerElement = this.element.createChild("div", "help-container-wrapper").createChild("div", "settings-tab help-content help-container"); |
+ if (Runtime.experiments.isEnabled("cpuThrottling")) |
+ this._createOctaneScoreInput(); |
pfeldman
2016/05/06 23:13:09
Lets do that later.
alph
2016/05/07 00:02:27
ok
|
+ |
var buttonsRow = this.containerElement.createChild("div", "devices-button-row"); |
this._addCustomButton = createTextButton(WebInspector.UIString("Add custom device..."), this._addCustomDevice.bind(this)); |
buttonsRow.appendChild(this._addCustomButton); |
@@ -35,6 +38,20 @@ WebInspector.DevicesSettingsTab = function() |
this.setDefaultFocusedElement(this._addCustomButton); |
} |
+/** |
+ * @param {number} minValue |
+ * @param {number} maxValue |
+ * @param {string} text |
+ * @return {boolean} |
+ */ |
+WebInspector.DevicesSettingsTab.numberValidator = function(minValue, maxValue, text) |
+{ |
+ if (text === "") |
+ return true; |
+ var value = Number.parseInt(text, 10); |
+ return String(value) === text && minValue <= value && value <= maxValue; |
+} |
+ |
WebInspector.DevicesSettingsTab.prototype = { |
wasShown: function() |
{ |
@@ -74,6 +91,20 @@ WebInspector.DevicesSettingsTab.prototype = { |
this._muteUpdate = false; |
}, |
+ _createOctaneScoreInput: function() |
+ { |
+ var octaneRow = this.containerElement.createChild("div", "octane-score-row"); |
+ var labelElement = octaneRow.createChild("label"); |
+ labelElement.textContent = WebInspector.UIString("Host Octane 2.0 score"); |
+ var inputElement = octaneRow.createChild("input"); |
+ inputElement.type = "text"; |
+ inputElement.style.width = "100px"; |
+ octaneRow.appendChild(WebInspector.linkifyURLAsNode("http://chromium.github.io/octane/", WebInspector.UIString("Obtain score"), undefined, true)); |
+ var hostOctaneScore = WebInspector.settings.createSetting("hostOctaneScore", 0); |
+ WebInspector.bindInput(inputElement, hostOctaneScore.set.bind(hostOctaneScore), WebInspector.DevicesSettingsTab.numberValidator.bind(null, 1, 1e6), false); |
+ inputElement.value = hostOctaneScore.get() ? hostOctaneScore.get() : ""; |
+ }, |
+ |
_addCustomDevice: function() |
{ |
var device = new WebInspector.EmulatedDevice(); |
@@ -82,6 +113,7 @@ WebInspector.DevicesSettingsTab.prototype = { |
device.horizontal.height = 400; |
device.vertical.width = 400; |
device.vertical.height = 700; |
+ device.octaneScore = 0; |
this._list.addNewItem(this._emulatedDevicesList.custom().length, device); |
}, |
@@ -150,6 +182,7 @@ WebInspector.DevicesSettingsTab.prototype = { |
device.horizontal.width = device.vertical.height; |
device.horizontal.height = device.vertical.width; |
device.deviceScaleFactor = editor.control("scale").value ? parseFloat(editor.control("scale").value) : 0; |
+ device.octaneScore = editor.control("octane").value ? parseInt(editor.control("octane").value, 10) : 0; |
device.userAgent = editor.control("user-agent").value; |
device.modes = []; |
device.modes.push({title: "", orientation: WebInspector.EmulatedDevice.Vertical, insets: new Insets(0, 0, 0, 0), image: null}); |
@@ -182,6 +215,7 @@ WebInspector.DevicesSettingsTab.prototype = { |
editor.control("height").value = this._toNumericInputValue(device.vertical.height); |
editor.control("scale").value = this._toNumericInputValue(device.deviceScaleFactor); |
editor.control("user-agent").value = device.userAgent; |
+ editor.control("octane").value = this._toNumericInputValue(device.octaneScore); |
var uaType; |
if (device.mobile()) |
uaType = device.touch() ? WebInspector.DeviceModeModel.UA.Mobile : WebInspector.DeviceModeModel.UA.MobileNoTouch; |
@@ -216,6 +250,7 @@ WebInspector.DevicesSettingsTab.prototype = { |
var uaType = editor.createSelect("ua-type", [WebInspector.DeviceModeModel.UA.Mobile, WebInspector.DeviceModeModel.UA.MobileNoTouch, WebInspector.DeviceModeModel.UA.Desktop, WebInspector.DeviceModeModel.UA.DesktopTouch], () => true); |
uaType.classList.add("device-edit-fixed"); |
ua.appendChild(uaType); |
+ fields.createChild("div", "hbox").appendChild(editor.createInput("octane", "text", WebInspector.UIString("Octane 2.0 score"), numberValidator.bind(null, 1, 1e6))); |
return editor; |
@@ -252,6 +287,20 @@ WebInspector.DevicesSettingsTab.prototype = { |
{ |
return WebInspector.DeviceModeModel.deviceScaleFactorValidator(input.value); |
} |
+ |
+ /** |
+ * @param {number} minValue |
+ * @param {number} maxValue |
+ * @param {*} item |
+ * @param {number} index |
+ * @param {!HTMLInputElement|!HTMLSelectElement} input |
+ * @return {boolean} |
+ */ |
+ function numberValidator(minValue, maxValue, item, index, input) |
+ { |
+ return WebInspector.DevicesSettingsTab.numberValidator(minValue, maxValue, input.value.trim()); |
+ } |
+ |
}, |
__proto__: WebInspector.VBox.prototype |