| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 { | 36 { |
| 37 WebInspector.VBox.call(this); | 37 WebInspector.VBox.call(this); |
| 38 this.registerRequiredCSS("overrides.css"); | 38 this.registerRequiredCSS("overrides.css"); |
| 39 this.registerRequiredCSS("helpScreen.css"); | 39 this.registerRequiredCSS("helpScreen.css"); |
| 40 this.element.classList.add("overrides-view"); | 40 this.element.classList.add("overrides-view"); |
| 41 | 41 |
| 42 this._tabbedPane = new WebInspector.TabbedPane(); | 42 this._tabbedPane = new WebInspector.TabbedPane(); |
| 43 this._tabbedPane.shrinkableTabs = false; | 43 this._tabbedPane.shrinkableTabs = false; |
| 44 this._tabbedPane.verticalTabLayout = true; | 44 this._tabbedPane.verticalTabLayout = true; |
| 45 | 45 |
| 46 if (!WebInspector.overridesSupport.isInspectingDevice()) { | 46 if (!WebInspector.overridesSupport.isInspectingDevice()) |
| 47 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) | 47 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane)
; |
| 48 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedP
ane); | 48 new WebInspector.OverridesView.MediaTab().appendAsTab(this._tabbedPane); |
| 49 } | |
| 50 new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPane); | |
| 51 new WebInspector.OverridesView.NetworkTab().appendAsTab(this._tabbedPane); | 49 new WebInspector.OverridesView.NetworkTab().appendAsTab(this._tabbedPane); |
| 52 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); | 50 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); |
| 53 | 51 |
| 54 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele
ctedEmulateTab", "device"); | 52 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele
ctedEmulateTab", "device"); |
| 55 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); | 53 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); |
| 56 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); | 54 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele
cted, this._tabSelected, this); |
| 57 this._tabbedPane.show(this.element); | 55 this._tabbedPane.show(this.element); |
| 58 | 56 |
| 59 this._warningFooter = this.element.createChild("div", "overrides-footer"); | 57 this._warningFooter = this.element.createChild("div", "overrides-footer"); |
| 60 this._overridesWarningUpdated(); | 58 this._overridesWarningUpdated(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 updateActiveState: function() | 111 updateActiveState: function() |
| 114 { | 112 { |
| 115 if (!this._tabbedPane) | 113 if (!this._tabbedPane) |
| 116 return; | 114 return; |
| 117 var active = false; | 115 var active = false; |
| 118 for (var i = 0; !active && i < this._settings.length; ++i) | 116 for (var i = 0; !active && i < this._settings.length; ++i) |
| 119 active = this._settings[i].get(); | 117 active = this._settings[i].get(); |
| 120 for (var i = 0; !active && i < this._predicates.length; ++i) | 118 for (var i = 0; !active && i < this._predicates.length; ++i) |
| 121 active = this._predicates[i](); | 119 active = this._predicates[i](); |
| 122 this._tabbedPane.element.classList.toggle("overrides-activate-" + this._
id, active); | 120 this._tabbedPane.element.classList.toggle("overrides-activate-" + this._
id, active); |
| 123 this._tabbedPane.changeTabTitle(this._id, active ? this._name + " \u2713
" : this._name); | |
| 124 }, | 121 }, |
| 125 | 122 |
| 126 /** | 123 /** |
| 127 * @param {string} name | 124 * @param {string} name |
| 128 * @param {!WebInspector.Setting} setting | 125 * @param {!WebInspector.Setting} setting |
| 129 * @param {function(boolean)=} callback | 126 * @param {function(boolean)=} callback |
| 130 */ | 127 */ |
| 131 _createSettingCheckbox: function(name, setting, callback) | 128 _createSettingCheckbox: function(name, setting, callback) |
| 132 { | 129 { |
| 133 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(name, setti
ng, true); | 130 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(name, setti
ng, true); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio
ns"); | 184 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio
ns"); |
| 188 this._swapDimensionsElement.addEventListener("click", WebInspector.overr
idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); | 185 this._swapDimensionsElement.addEventListener("click", WebInspector.overr
idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); |
| 189 this._swapDimensionsElement.tabIndex = -1; | 186 this._swapDimensionsElement.tabIndex = -1; |
| 190 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel
d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI
nspector.OverridesSupport.integerInputValidator, true); | 187 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel
d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI
nspector.OverridesSupport.integerInputValidator, true); |
| 191 cellElement.appendChild(heightOverrideInput); | 188 cellElement.appendChild(heightOverrideInput); |
| 192 | 189 |
| 193 rowElement = tableElement.createChild("tr"); | 190 rowElement = tableElement.createChild("tr"); |
| 194 cellElement = rowElement.createChild("td"); | 191 cellElement = rowElement.createChild("td"); |
| 195 cellElement.colSpan = 4; | 192 cellElement.colSpan = 4; |
| 196 | 193 |
| 197 var widthRangeInput = WebInspector.SettingsUI.createSettingInputField(""
, WebInspector.overridesSupport.settings.deviceWidth, true, 4, "200px", undefine
d, true).lastChild; | |
| 198 widthRangeInput.type = "range"; | |
| 199 widthRangeInput.min = 100; | |
| 200 widthRangeInput.max = 2000; | |
| 201 cellElement.appendChild(widthRangeInput); | |
| 202 | |
| 203 rowElement = tableElement.createChild("tr"); | 194 rowElement = tableElement.createChild("tr"); |
| 204 rowElement.title = WebInspector.UIString("Ratio between a device's physi
cal pixels and device-independent pixels."); | 195 rowElement.title = WebInspector.UIString("Ratio between a device's physi
cal pixels and device-independent pixels."); |
| 205 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp
ector.UIString("Device pixel ratio:"))); | 196 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp
ector.UIString("Device pixel ratio:"))); |
| 206 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS
ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t
rue, 4, "80px", WebInspector.OverridesSupport.doubleInputValidator, true)); | 197 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS
ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t
rue, 4, "80px", WebInspector.OverridesSupport.doubleInputValidator, true)); |
| 207 | 198 |
| 208 var viewportCheckbox = this._createSettingCheckbox(WebInspector.UIString
("Emulate mobile"), WebInspector.overridesSupport.settings.emulateViewport); | 199 var viewportCheckbox = this._createSettingCheckbox(WebInspector.UIString
("Emulate mobile"), WebInspector.overridesSupport.settings.emulateViewport); |
| 209 viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, ov
erlay scrollbars and default 980px body width"); | 200 viewportCheckbox.title = WebInspector.UIString("Enable meta viewport, ov
erlay scrollbars and default 980px body width"); |
| 210 fieldsetElement.appendChild(viewportCheckbox); | 201 fieldsetElement.appendChild(viewportCheckbox); |
| 211 | 202 |
| 212 // FIXME: move text autosizing to the "misc" tab together with css media
, and separate it from device emulation. | 203 // FIXME: move text autosizing to the "misc" tab together with css media
, and separate it from device emulation. |
| 213 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe
ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings
.deviceTextAutosizing); | 204 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe
ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings
.deviceTextAutosizing); |
| 214 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi
zing is the feature that boosts font sizes on mobile devices."); | 205 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi
zing is the feature that boosts font sizes on mobile devices."); |
| 215 fieldsetElement.appendChild(textAutosizingOverrideElement); | 206 fieldsetElement.appendChild(textAutosizingOverrideElement); |
| 216 | 207 |
| 217 fieldsetElement.appendChild(this._createSettingCheckbox(WebInspector.UIS
tring("Shrink to fit"), WebInspector.overridesSupport.settings.deviceFitWindow))
; | 208 fieldsetElement.appendChild(this._createSettingCheckbox(WebInspector.UIS
tring("Shrink to fit"), WebInspector.overridesSupport.settings.deviceFitWindow))
; |
| 218 | 209 |
| 219 return fieldsetElement; | 210 return fieldsetElement; |
| 220 }, | 211 }, |
| 221 | 212 |
| 222 __proto__: WebInspector.OverridesView.Tab.prototype | 213 __proto__: WebInspector.OverridesView.Tab.prototype |
| 223 } | 214 } |
| 224 | 215 |
| 225 | |
| 226 /** | 216 /** |
| 227 * @constructor | 217 * @constructor |
| 228 * @extends {WebInspector.OverridesView.Tab} | 218 * @extends {WebInspector.OverridesView.Tab} |
| 229 */ | 219 */ |
| 230 WebInspector.OverridesView.ViewportTab = function() | 220 WebInspector.OverridesView.MediaTab = function() |
| 231 { | 221 { |
| 232 var settings = [WebInspector.overridesSupport.settings.overrideCSSMedia]; | 222 var settings = [WebInspector.overridesSupport.settings.overrideCSSMedia]; |
| 233 WebInspector.OverridesView.Tab.call(this, "viewport", WebInspector.UIString(
"Screen"), settings); | 223 WebInspector.OverridesView.Tab.call(this, "media", WebInspector.UIString("Me
dia"), settings); |
| 234 this.element.classList.add("overrides-viewport"); | 224 this.element.classList.add("overrides-media"); |
| 235 | 225 |
| 236 this._createMediaEmulationFragment(); | 226 this._createMediaEmulationFragment(); |
| 237 } | 227 } |
| 238 | 228 |
| 239 WebInspector.OverridesView.ViewportTab.prototype = { | 229 WebInspector.OverridesView.MediaTab.prototype = { |
| 240 _createMediaEmulationFragment: function() | 230 _createMediaEmulationFragment: function() |
| 241 { | 231 { |
| 242 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspecto
r.UIString("CSS media"), WebInspector.overridesSupport.settings.overrideCSSMedia
, true); | 232 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspecto
r.UIString("CSS media"), WebInspector.overridesSupport.settings.overrideCSSMedia
, true); |
| 243 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.overrideCSSMedia); | 233 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.overrideCSSMedia); |
| 244 if (WebInspector.overridesSupport.isInspectingDevice()) | 234 if (WebInspector.overridesSupport.isInspectingDevice()) |
| 245 fieldsetElement.disabled = true; | 235 fieldsetElement.disabled = true; |
| 246 | 236 |
| 247 var mediaSelectElement = fieldsetElement.createChild("select"); | 237 var mediaSelectElement = fieldsetElement.createChild("select"); |
| 248 var mediaTypes = WebInspector.CSSStyleModel.MediaTypes; | 238 var mediaTypes = WebInspector.CSSStyleModel.MediaTypes; |
| 249 var defaultMedia = WebInspector.overridesSupport.settings.emulatedCSSMed
ia.get(); | 239 var defaultMedia = WebInspector.overridesSupport.settings.emulatedCSSMed
ia.get(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 277 __proto__: WebInspector.OverridesView.Tab.prototype | 267 __proto__: WebInspector.OverridesView.Tab.prototype |
| 278 } | 268 } |
| 279 | 269 |
| 280 | 270 |
| 281 /** | 271 /** |
| 282 * @constructor | 272 * @constructor |
| 283 * @extends {WebInspector.OverridesView.Tab} | 273 * @extends {WebInspector.OverridesView.Tab} |
| 284 */ | 274 */ |
| 285 WebInspector.OverridesView.NetworkTab = function() | 275 WebInspector.OverridesView.NetworkTab = function() |
| 286 { | 276 { |
| 287 WebInspector.OverridesView.Tab.call(this, "network", WebInspector.UIString("
Network"), [WebInspector.overridesSupport.settings.emulateNetworkConditions], [t
his._isUserAgentOverrideEnabled.bind(this)]); | 277 var flags = []; |
| 278 if (WebInspector.experimentsSettings.networkConditions.isEnabled()) |
| 279 flags.push(WebInspector.overridesSupport.settings.emulateNetworkCondition
s); |
| 280 WebInspector.OverridesView.Tab.call(this, "network", WebInspector.UIString("
Network"), flags, [this._isUserAgentOverrideEnabled.bind(this)]); |
| 288 this.element.classList.add("overrides-network"); | 281 this.element.classList.add("overrides-network"); |
| 289 this.element.appendChild(this._createSettingCheckbox(WebInspector.UIString("
Limit network throughput"), WebInspector.overridesSupport.settings.emulateNetwor
kConditions)); | 282 if (WebInspector.experimentsSettings.networkConditions.isEnabled()) { |
| 290 this.element.appendChild(this._createNetworkConditionsElement()); | 283 this.element.appendChild(this._createSettingCheckbox(WebInspector.UIStri
ng("Limit network throughput"), WebInspector.overridesSupport.settings.emulateNe
tworkConditions)); |
| 284 this.element.appendChild(this._createNetworkConditionsElement()); |
| 285 } |
| 291 this._createUserAgentSection(); | 286 this._createUserAgentSection(); |
| 292 } | 287 } |
| 293 | 288 |
| 294 WebInspector.OverridesView.NetworkTab.prototype = { | 289 WebInspector.OverridesView.NetworkTab.prototype = { |
| 295 /** | 290 /** |
| 296 * @return {!Element} | 291 * @return {!Element} |
| 297 */ | 292 */ |
| 298 _createNetworkConditionsElement: function() | 293 _createNetworkConditionsElement: function() |
| 299 { | 294 { |
| 300 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.emulateNetworkConditions); | 295 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI
nspector.overridesSupport.settings.emulateNetworkConditions); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 322 { | 317 { |
| 323 this.updateActiveState(); | 318 this.updateActiveState(); |
| 324 var enabled = !!WebInspector.overridesSupport.userAgentOverride(); | 319 var enabled = !!WebInspector.overridesSupport.userAgentOverride(); |
| 325 if (this._userAgentCheckbox.checked !== enabled) | 320 if (this._userAgentCheckbox.checked !== enabled) |
| 326 this._userAgentCheckbox.checked = enabled; | 321 this._userAgentCheckbox.checked = enabled; |
| 327 this._userAgentFieldset.disabled = !enabled; | 322 this._userAgentFieldset.disabled = !enabled; |
| 328 }, | 323 }, |
| 329 | 324 |
| 330 _createUserAgentSection: function() | 325 _createUserAgentSection: function() |
| 331 { | 326 { |
| 332 var settings = [WebInspector.overridesSupport.settings.emulateDevice, We
bInspector.settings.responsiveDesign.enabled, WebInspector.overridesSupport.sett
ings.deviceUserAgent]; | 327 var settings = [WebInspector.overridesSupport.settings.emulateDevice, We
bInspector.settings.responsiveDesignEnabled, WebInspector.overridesSupport.setti
ngs.deviceUserAgent]; |
| 333 for (var i = 0; i < settings.length; i++) { | 328 for (var i = 0; i < settings.length; i++) { |
| 334 settings[i].addChangeListener(this._onUserAgentOverrideEnabledChange
d.bind(this)); | 329 settings[i].addChangeListener(this._onUserAgentOverrideEnabledChange
d.bind(this)); |
| 335 settings[i].addChangeListener(WebInspector.overridesSupport.updateUs
erAgentToMatchDeviceUserAgent.bind(WebInspector.overridesSupport)); | 330 settings[i].addChangeListener(WebInspector.overridesSupport.updateUs
erAgentToMatchDeviceUserAgent.bind(WebInspector.overridesSupport)); |
| 336 } | 331 } |
| 337 WebInspector.overridesSupport.settings.overrideUserAgent.addChangeListen
er(this._onUserAgentOverrideEnabledChanged.bind(this)); | 332 WebInspector.overridesSupport.settings.overrideUserAgent.addChangeListen
er(this._onUserAgentOverrideEnabledChanged.bind(this)); |
| 338 WebInspector.overridesSupport.settings.userAgent.addChangeListener(this.
_onUserAgentOverrideEnabledChanged.bind(this)); | 333 WebInspector.overridesSupport.settings.userAgent.addChangeListener(this.
_onUserAgentOverrideEnabledChanged.bind(this)); |
| 339 | 334 |
| 340 var label = this.element.createChild("label"); | 335 var label = this.element.createChild("label"); |
| 341 var checkbox = label.createChild("input"); | 336 var checkbox = label.createChild("input"); |
| 342 checkbox.type = "checkbox"; | 337 checkbox.type = "checkbox"; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 var enabled = WebInspector.overridesSupport.isTouchEmulationEnabled(); | 486 var enabled = WebInspector.overridesSupport.isTouchEmulationEnabled(); |
| 492 if (this._touchCheckbox.checked !== enabled) | 487 if (this._touchCheckbox.checked !== enabled) |
| 493 this._touchCheckbox.checked = enabled; | 488 this._touchCheckbox.checked = enabled; |
| 494 }, | 489 }, |
| 495 | 490 |
| 496 /** | 491 /** |
| 497 * @return {!Element} | 492 * @return {!Element} |
| 498 */ | 493 */ |
| 499 _createTouchCheckbox: function() | 494 _createTouchCheckbox: function() |
| 500 { | 495 { |
| 501 var settings = [WebInspector.overridesSupport.settings.emulateDevice, We
bInspector.settings.responsiveDesign.enabled, WebInspector.overridesSupport.sett
ings.deviceTouch]; | 496 var settings = [WebInspector.overridesSupport.settings.emulateDevice, We
bInspector.settings.responsiveDesignEnabled, WebInspector.overridesSupport.setti
ngs.deviceTouch]; |
| 502 for (var i = 0; i < settings.length; i++) { | 497 for (var i = 0; i < settings.length; i++) { |
| 503 settings[i].addChangeListener(this._onTouchEmulationChanged.bind(thi
s)); | 498 settings[i].addChangeListener(this._onTouchEmulationChanged.bind(thi
s)); |
| 504 settings[i].addChangeListener(WebInspector.overridesSupport.updateSe
nsorsTouchToMatchDeviceTouch.bind(WebInspector.overridesSupport)); | 499 settings[i].addChangeListener(WebInspector.overridesSupport.updateSe
nsorsTouchToMatchDeviceTouch.bind(WebInspector.overridesSupport)); |
| 505 } | 500 } |
| 506 WebInspector.overridesSupport.settings.sensorsTouch.addChangeListener(th
is._onTouchEmulationChanged.bind(this)); | 501 WebInspector.overridesSupport.settings.sensorsTouch.addChangeListener(th
is._onTouchEmulationChanged.bind(this)); |
| 507 | 502 |
| 508 var input = document.createElement("input"); | 503 var input = document.createElement("input"); |
| 509 input.type = "checkbox"; | 504 input.type = "checkbox"; |
| 510 input.name = WebInspector.UIString("Emulate touch screen"); | 505 input.name = WebInspector.UIString("Emulate touch screen"); |
| 511 this._touchCheckbox = input; | 506 this._touchCheckbox = input; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 773 |
| 779 __proto__ : WebInspector.OverridesView.Tab.prototype | 774 __proto__ : WebInspector.OverridesView.Tab.prototype |
| 780 } | 775 } |
| 781 | 776 |
| 782 /** @enum {string} */ | 777 /** @enum {string} */ |
| 783 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { | 778 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { |
| 784 UserInput: "userInput", | 779 UserInput: "userInput", |
| 785 UserDrag: "userDrag", | 780 UserDrag: "userDrag", |
| 786 ResetButton: "resetButton" | 781 ResetButton: "resetButton" |
| 787 } | 782 } |
| OLD | NEW |