Commit 90c3f00b authored by apavlov@chromium.org's avatar apavlov@chromium.org

DevTools: Migrate General tab settings to extensions

R=aandrey, pfeldman

Review URL: https://codereview.chromium.org/213423010

git-svn-id: svn://svn.chromium.org/blink/trunk@170585 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d85f37d8
...@@ -56,7 +56,9 @@ WebInspector.DebuggerModel = function(target) ...@@ -56,7 +56,9 @@ WebInspector.DebuggerModel = function(target)
this.enableDebugger(); this.enableDebugger();
this.applySkipStackFrameSettings(); WebInspector.settings.skipStackFramesSwitch.addChangeListener(this._applySkipStackFrameSettings, this);
WebInspector.settings.skipStackFramesPattern.addChangeListener(this._applySkipStackFrameSettings, this);
this._applySkipStackFrameSettings();
} }
/** /**
...@@ -671,7 +673,7 @@ WebInspector.DebuggerModel.prototype = { ...@@ -671,7 +673,7 @@ WebInspector.DebuggerModel.prototype = {
this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace); this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
}, },
applySkipStackFrameSettings: function() _applySkipStackFrameSettings: function()
{ {
if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabled()) if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabled())
return; return;
......
...@@ -277,6 +277,32 @@ WebInspector.HandlerRegistry.LinkHandler.prototype = { ...@@ -277,6 +277,32 @@ WebInspector.HandlerRegistry.LinkHandler.prototype = {
} }
} }
/**
* @constructor
* @extends {WebInspector.UISettingDelegate}
*/
WebInspector.HandlerRegistry.OpenAnchorLocationSettingDelegate = function()
{
WebInspector.UISettingDelegate.call(this);
}
WebInspector.HandlerRegistry.OpenAnchorLocationSettingDelegate.prototype = {
/**
* @override
* @return {?Element}
*/
settingElement: function()
{
if (!WebInspector.openAnchorLocationRegistry.handlerNames.length)
return null;
var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
return WebInspector.SettingsUI.createCustomSetting(WebInspector.UIString("Open links in"), handlerSelector.element);
},
__proto__: WebInspector.UISettingDelegate.prototype
}
/** /**
* @type {!WebInspector.HandlerRegistry} * @type {!WebInspector.HandlerRegistry}
*/ */
......
...@@ -735,6 +735,29 @@ WebInspector.Main.DebugReloadActionDelegate.prototype = { ...@@ -735,6 +735,29 @@ WebInspector.Main.DebugReloadActionDelegate.prototype = {
} }
} }
/**
* @constructor
* @extends {WebInspector.UISettingDelegate}
*/
WebInspector.Main.ShortcutPanelSwitchSettingDelegate = function()
{
WebInspector.UISettingDelegate.call(this);
}
WebInspector.Main.ShortcutPanelSwitchSettingDelegate.prototype = {
/**
* @override
* @return {!Element}
*/
settingElement: function()
{
var modifier = WebInspector.platform() === "mac" ? "Cmd" : "Ctrl";
return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable %s + 1-9 shortcut to switch panels", modifier), WebInspector.settings.shortcutPanelSwitch);
},
__proto__: WebInspector.UISettingDelegate.prototype
}
new WebInspector.Main(); new WebInspector.Main();
window.DEBUG = true; window.DEBUG = true;
......
...@@ -61,20 +61,6 @@ WebInspector.SettingsScreen = function(onHide) ...@@ -61,20 +61,6 @@ WebInspector.SettingsScreen = function(onHide)
this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this); this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSelected, this._tabSelected, this);
} }
/**
* @param {string} text
* @return {?string}
*/
WebInspector.SettingsScreen.regexValidator = function(text)
{
var regex;
try {
regex = new RegExp(text);
} catch (e) {
}
return regex ? null : WebInspector.UIString("Invalid pattern");
}
/** /**
* @param {number} min * @param {number} min
* @param {number} max * @param {number} max
...@@ -205,60 +191,6 @@ WebInspector.SettingsTab.prototype = { ...@@ -205,60 +191,6 @@ WebInspector.SettingsTab.prototype = {
return p; return p;
}, },
/**
* @param {string} label
* @param {!WebInspector.Setting} setting
* @param {boolean} numeric
* @param {number=} maxLength
* @param {string=} width
* @param {function(string):?string=} validatorCallback
*/
_createInputSetting: function(label, setting, numeric, maxLength, width, validatorCallback)
{
var p = document.createElement("p");
var labelElement = p.createChild("label");
labelElement.textContent = label;
var inputElement = p.createChild("input");
inputElement.value = setting.get();
inputElement.type = "text";
if (numeric)
inputElement.className = "numeric";
if (maxLength)
inputElement.maxLength = maxLength;
if (width)
inputElement.style.width = width;
if (validatorCallback) {
var errorMessageLabel = p.createChild("div");
errorMessageLabel.classList.add("field-error-message");
errorMessageLabel.style.color = "DarkRed";
inputElement.oninput = function()
{
var error = validatorCallback(inputElement.value);
if (!error)
error = "";
errorMessageLabel.textContent = error;
};
}
function onBlur()
{
setting.set(numeric ? Number(inputElement.value) : inputElement.value);
}
inputElement.addEventListener("blur", onBlur, false);
return p;
},
_createCustomSetting: function(name, element)
{
var p = document.createElement("p");
var fieldsetElement = document.createElement("fieldset");
fieldsetElement.createChild("label").textContent = name;
fieldsetElement.appendChild(element);
p.appendChild(fieldsetElement);
return p;
},
__proto__: WebInspector.VBox.prototype __proto__: WebInspector.VBox.prototype
} }
...@@ -270,88 +202,9 @@ WebInspector.GenericSettingsTab = function() ...@@ -270,88 +202,9 @@ WebInspector.GenericSettingsTab = function()
{ {
WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "general-tab-content"); WebInspector.SettingsTab.call(this, WebInspector.UIString("General"), "general-tab-content");
var p = this._appendSection(); this._populateSectionsFromExtensions();
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Disable cache (while DevTools is open)"), WebInspector.settings.cacheDisabled));
var disableJSElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Disable JavaScript"), WebInspector.settings.javaScriptDisabled);
p.appendChild(disableJSElement);
WebInspector.settings.javaScriptDisabled.addChangeListener(this._javaScriptDisabledChanged, this);
this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
var disableJSInfoParent = this._disableJSCheckbox.parentElement.createChild("span", "monospace");
this._disableJSInfo = disableJSInfoParent.createChild("span", "object-info-state-note hidden");
this._disableJSInfo.title = WebInspector.UIString("JavaScript is blocked on the inspected page (may be disabled in browser settings).");
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._updateScriptDisabledCheckbox, this);
this._updateScriptDisabledCheckbox();
p = this._appendSection(WebInspector.UIString("Appearance"));
var splitVerticallyTitle = WebInspector.UIString("Split panels vertically when docked to %s", WebInspector.experimentsSettings.dockToLeft.isEnabled() ? "left or right" : "right");
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(splitVerticallyTitle, WebInspector.settings.splitVerticallyWhenDockedToRight));
var panelShortcutTitle = WebInspector.UIString("Enable %s + 1-9 shortcut to switch panels", WebInspector.isMac() ? "Cmd" : "Ctrl");
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(panelShortcutTitle, WebInspector.settings.shortcutPanelSwitch));
p = this._appendSection(WebInspector.UIString("Elements"));
var colorFormatElement = this._createSelectSetting(WebInspector.UIString("Color format"), [
[ WebInspector.UIString("As authored"), WebInspector.Color.Format.Original ],
[ "HEX: #DAC0DE", WebInspector.Color.Format.HEX ],
[ "RGB: rgb(128, 255, 255)", WebInspector.Color.Format.RGB ],
[ "HSL: hsl(300, 80%, 90%)", WebInspector.Color.Format.HSL ]
], WebInspector.settings.colorFormat);
p.appendChild(colorFormatElement);
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show user agent styles"), WebInspector.settings.showUserAgentStyles));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show user agent shadow DOM"), WebInspector.settings.showUAShadowDOM));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Word wrap"), WebInspector.settings.domWordWrap));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show rulers"), WebInspector.settings.showMetricsRulers));
p = this._appendSection(WebInspector.UIString("Sources"));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable JavaScript source maps"), WebInspector.settings.jsSourceMapsEnabled));
var checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Enable CSS source maps"), WebInspector.settings.cssSourceMapsEnabled);
p.appendChild(checkbox);
var fieldset = WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.cssSourceMapsEnabled);
var autoReloadCSSCheckbox = fieldset.createChild("input");
fieldset.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Auto-reload generated CSS"), WebInspector.settings.cssReloadEnabled, false, autoReloadCSSCheckbox));
checkbox.appendChild(fieldset);
var indentationElement = this._createSelectSetting(WebInspector.UIString("Default indentation"), [
[ WebInspector.UIString("2 spaces"), WebInspector.TextUtils.Indent.TwoSpaces ],
[ WebInspector.UIString("4 spaces"), WebInspector.TextUtils.Indent.FourSpaces ],
[ WebInspector.UIString("8 spaces"), WebInspector.TextUtils.Indent.EightSpaces ],
[ WebInspector.UIString("Tab character"), WebInspector.TextUtils.Indent.TabCharacter ]
], WebInspector.settings.textEditorIndent);
p.appendChild(indentationElement);
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Detect indentation"), WebInspector.settings.textEditorAutoDetectIndent));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Autocompletion"), WebInspector.settings.textEditorAutocompletion));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Bracket matching"), WebInspector.settings.textEditorBracketMatching));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show whitespace characters"), WebInspector.settings.showWhitespacesInEditor));
if (WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabled()) {
checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Skip stepping through sources with particular names"), WebInspector.settings.skipStackFramesSwitch);
fieldset = WebInspector.SettingsUI.createSettingFieldset(WebInspector.settings.skipStackFramesSwitch);
fieldset.appendChild(this._createInputSetting(WebInspector.UIString("Pattern"), WebInspector.settings.skipStackFramesPattern, false, 1000, "100px", WebInspector.SettingsScreen.regexValidator));
checkbox.appendChild(fieldset);
p.appendChild(checkbox);
}
WebInspector.settings.skipStackFramesSwitch.addChangeListener(this._skipStackFramesSwitchOrPatternChanged, this);
WebInspector.settings.skipStackFramesPattern.addChangeListener(this._skipStackFramesSwitchOrPatternChanged, this);
p = this._appendSection(WebInspector.UIString("Profiler"));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show advanced heap snapshot properties"), WebInspector.settings.showAdvancedHeapSnapshotProperties));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("High resolution CPU profiling"), WebInspector.settings.highResolutionCpuProfiling));
p = this._appendSection(WebInspector.UIString("Console"));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Log XMLHttpRequests"), WebInspector.settings.monitoringXHREnabled));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Preserve log upon navigation"), WebInspector.settings.preserveConsoleLog));
p.appendChild(WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show timestamps"), WebInspector.settings.consoleTimestampsEnabled));
if (WebInspector.openAnchorLocationRegistry.handlerNames.length > 0) {
var handlerSelector = new WebInspector.HandlerSelector(WebInspector.openAnchorLocationRegistry);
p = this._appendSection(WebInspector.UIString("Extensions"));
p.appendChild(this._createCustomSetting(WebInspector.UIString("Open links in"), handlerSelector.element));
}
p = this._appendSection();
var restoreDefaults = p.createChild("input", "settings-tab-text-button"); var restoreDefaults = this._appendSection().createChild("input", "settings-tab-text-button");
restoreDefaults.type = "button"; restoreDefaults.type = "button";
restoreDefaults.value = WebInspector.UIString("Restore defaults and reload"); restoreDefaults.value = WebInspector.UIString("Restore defaults and reload");
restoreDefaults.addEventListener("click", restoreAndReload); restoreDefaults.addEventListener("click", restoreAndReload);
...@@ -365,38 +218,118 @@ WebInspector.GenericSettingsTab = function() ...@@ -365,38 +218,118 @@ WebInspector.GenericSettingsTab = function()
} }
WebInspector.GenericSettingsTab.prototype = { WebInspector.GenericSettingsTab.prototype = {
_updateScriptDisabledCheckbox: function() _populateSectionsFromExtensions: function()
{ {
/** @const */
var explicitSectionOrder = ["", "Appearance", "Elements", "Sources", "Profiler", "Console", "Extensions"];
var allExtensions = WebInspector.moduleManager.extensions("ui-setting");
/** @type {!StringMultimap.<!WebInspector.ModuleManager.Extension>} */
var extensionsBySectionId = new StringMultimap();
/** @type {!StringMultimap.<!WebInspector.ModuleManager.Extension>} */
var childSettingExtensionsByParentName = new StringMultimap();
allExtensions.forEach(function(extension) {
var descriptor = extension.descriptor();
var sectionName = descriptor["section"] || "";
if (!sectionName && descriptor["parentSettingName"]) {
childSettingExtensionsByParentName.put(descriptor["parentSettingName"], extension);
return;
}
extensionsBySectionId.put(sectionName, extension);
});
var sectionIds = extensionsBySectionId.keys();
var explicitlyOrderedSections = {};
for (var i = 0; i < explicitSectionOrder.length; ++i) {
explicitlyOrderedSections[explicitSectionOrder[i]] = true;
var extensions = /** @type {!Set.<!WebInspector.ModuleManager.Extension>} */ (extensionsBySectionId.get(explicitSectionOrder[i]));
if (!extensions)
continue;
this._addSectionWithExtensionProvidedSettings(explicitSectionOrder[i], extensions.items(), childSettingExtensionsByParentName);
}
for (var i = 0; i < sectionIds.length; ++i) {
if (explicitlyOrderedSections[sectionIds[i]])
continue;
this._addSectionWithExtensionProvidedSettings(sectionIds[i], /** @type {!Set.<!WebInspector.ModuleManager.Extension>} */ (extensionsBySectionId.get(sectionIds[i])).items(), childSettingExtensionsByParentName);
}
},
/**
* @param {string} sectionName
* @param {!Array.<!WebInspector.ModuleManager.Extension>} extensions
* @param {!StringMultimap.<!WebInspector.ModuleManager.Extension>} childSettingExtensionsByParentName
*/
_addSectionWithExtensionProvidedSettings: function(sectionName, extensions, childSettingExtensionsByParentName)
{
var uiSectionName = sectionName && WebInspector.UIString(sectionName);
var sectionElement = this._appendSection(uiSectionName);
extensions.forEach(processSetting.bind(this, null));
/** /**
* @param {?Protocol.Error} error * @param {?Element} parentFieldset
* @param {string} status * @param {!WebInspector.ModuleManager.Extension} extension
* @this {WebInspector.GenericSettingsTab} * @this {WebInspector.GenericSettingsTab}
*/ */
function executionStatusCallback(error, status) function processSetting(parentFieldset, extension)
{ {
if (error || !status) var descriptor = extension.descriptor();
var experimentName = descriptor["experiment"];
if (experimentName && (!WebInspector.experimentsSettings[experimentName] || !WebInspector.experimentsSettings[experimentName].isEnabled()))
return; return;
var forbidden = (status === "forbidden"); var settingName = descriptor["settingName"];
var disabled = forbidden || (status === "disabled"); var setting = WebInspector.settings[settingName];
var instance = extension.instance();
this._disableJSInfo.classList.toggle("hidden", !forbidden); var settingControl;
this._disableJSCheckbox.checked = disabled; if (instance && descriptor["settingType"] === "custom") {
this._disableJSCheckbox.disabled = forbidden; settingControl = instance.settingElement();
if (!settingControl)
return;
}
if (!settingControl) {
var uiTitle = WebInspector.UIString(descriptor["title"]);
settingControl = createSettingControl.call(this, uiTitle, setting, descriptor, instance);
}
if (settingName) {
var childSettings = /** @type {!Set.<!WebInspector.ModuleManager.Extension>|undefined} */ (childSettingExtensionsByParentName.get(settingName));
if (childSettings) {
var fieldSet = WebInspector.SettingsUI.createSettingFieldset(setting);
settingControl.appendChild(fieldSet);
childSettings.items().forEach(function(item) { processSetting.call(this, fieldSet, item); }, this);
}
}
var containerElement = parentFieldset || sectionElement;
containerElement.appendChild(settingControl);
} }
PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this)); /**
}, * @param {string} uiTitle
* @param {!WebInspector.Setting} setting
_javaScriptDisabledChanged: function() * @param {!Object} descriptor
{ * @param {?Object} instance
// We need to manually update the checkbox state, since enabling JavaScript in the page can actually uncover the "forbidden" state. * @return {!Element}
PageAgent.setScriptExecutionDisabled(WebInspector.settings.javaScriptDisabled.get(), this._updateScriptDisabledCheckbox.bind(this)); * @this {WebInspector.GenericSettingsTab}
}, */
function createSettingControl(uiTitle, setting, descriptor, instance)
_skipStackFramesSwitchOrPatternChanged: function() {
{ switch (descriptor["settingType"]) {
WebInspector.debuggerModel.applySkipStackFrameSettings(); case "checkbox":
return WebInspector.SettingsUI.createSettingCheckbox(uiTitle, setting);
case "select":
var descriptorOptions = descriptor["options"]
var options = new Array(descriptorOptions.length);
for (var i = 0; i < options.length; ++i) {
// The third array item flags that the option name is "raw" (non-i18n-izable).
var optionName = descriptorOptions[i][2] ? descriptorOptions[i][0] : WebInspector.UIString(descriptorOptions[i][0]);
options[i] = [WebInspector.UIString(descriptorOptions[i][0]), descriptorOptions[i][1]];
}
return this._createSelectSetting(uiTitle, options, setting);
default:
throw "Invalid setting type: " + descriptor["settingType"];
}
}
}, },
/** /**
...@@ -426,7 +359,7 @@ WebInspector.WorkspaceSettingsTab = function() ...@@ -426,7 +359,7 @@ WebInspector.WorkspaceSettingsTab = function()
WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
this._commonSection = this._appendSection(WebInspector.UIString("Common")); this._commonSection = this._appendSection(WebInspector.UIString("Common"));
var folderExcludePatternInput = this._createInputSetting(WebInspector.UIString("Folder exclude pattern"), WebInspector.settings.workspaceFolderExcludePattern, false, 0, "270px", WebInspector.SettingsScreen.regexValidator); var folderExcludePatternInput = WebInspector.SettingsUI.createSettingInputField(WebInspector.UIString("Folder exclude pattern"), WebInspector.settings.workspaceFolderExcludePattern, false, 0, "270px", WebInspector.SettingsUI.regexValidator);
this._commonSection.appendChild(folderExcludePatternInput); this._commonSection.appendChild(folderExcludePatternInput);
this._fileSystemsSection = this._appendSection(WebInspector.UIString("Folders")); this._fileSystemsSection = this._appendSection(WebInspector.UIString("Folders"));
......
...@@ -79,6 +79,64 @@ WebInspector.SettingsUI.createSettingCheckbox = function(name, setting, omitPara ...@@ -79,6 +79,64 @@ WebInspector.SettingsUI.createSettingCheckbox = function(name, setting, omitPara
return WebInspector.SettingsUI.createCheckbox(name, setting.get.bind(setting), setting.set.bind(setting), omitParagraphElement, inputElement, tooltip); return WebInspector.SettingsUI.createCheckbox(name, setting.get.bind(setting), setting.set.bind(setting), omitParagraphElement, inputElement, tooltip);
} }
/**
* @param {string} label
* @param {!WebInspector.Setting} setting
* @param {boolean} numeric
* @param {number=} maxLength
* @param {string=} width
* @param {function(string):?string=} validatorCallback
*/
WebInspector.SettingsUI.createSettingInputField = function(label, setting, numeric, maxLength, width, validatorCallback)
{
var p = document.createElement("p");
var labelElement = p.createChild("label");
labelElement.textContent = label;
var inputElement = p.createChild("input");
inputElement.value = setting.get();
inputElement.type = "text";
if (numeric)
inputElement.className = "numeric";
if (maxLength)
inputElement.maxLength = maxLength;
if (width)
inputElement.style.width = width;
var errorMessageLabel;
if (validatorCallback) {
errorMessageLabel = p.createChild("div");
errorMessageLabel.classList.add("field-error-message");
inputElement.oninput = onInput;
onInput();
}
function onInput()
{
var error = validatorCallback(inputElement.value);
if (!error)
error = "";
errorMessageLabel.textContent = error;
}
function onBlur()
{
setting.set(numeric ? Number(inputElement.value) : inputElement.value);
}
inputElement.addEventListener("blur", onBlur, false);
return p;
}
WebInspector.SettingsUI.createCustomSetting = function(name, element)
{
var p = document.createElement("p");
var fieldsetElement = document.createElement("fieldset");
fieldsetElement.createChild("label").textContent = name;
fieldsetElement.appendChild(element);
p.appendChild(fieldsetElement);
return p;
}
/** /**
* @param {!WebInspector.Setting} setting * @param {!WebInspector.Setting} setting
* @return {!Element} * @return {!Element}
...@@ -95,3 +153,34 @@ WebInspector.SettingsUI.createSettingFieldset = function(setting) ...@@ -95,3 +153,34 @@ WebInspector.SettingsUI.createSettingFieldset = function(setting)
fieldset.disabled = !setting.get(); fieldset.disabled = !setting.get();
} }
} }
/**
* @param {string} text
* @return {?string}
*/
WebInspector.SettingsUI.regexValidator = function(text)
{
var regex;
try {
regex = new RegExp(text);
} catch (e) {
}
return regex ? null : WebInspector.UIString("Invalid pattern");
}
/**
* @constructor
*/
WebInspector.UISettingDelegate = function()
{
}
WebInspector.UISettingDelegate.prototype = {
/**
* @return {?Element}
*/
settingElement: function()
{
return null;
}
}
...@@ -1242,3 +1242,87 @@ WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate.prototype = { ...@@ -1242,3 +1242,87 @@ WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate.prototype = {
return true; return true;
} }
} }
/**
* @constructor
* @extends {WebInspector.UISettingDelegate}
*/
WebInspector.SourcesPanel.SkipStackFramePatternSettingDelegate = function()
{
WebInspector.UISettingDelegate.call(this);
}
WebInspector.SourcesPanel.SkipStackFramePatternSettingDelegate.prototype = {
/**
* @override
* @return {!Element}
*/
settingElement: function()
{
return WebInspector.SettingsUI.createSettingInputField(WebInspector.UIString("Pattern"), WebInspector.settings.skipStackFramesPattern, false, 1000, "100px", WebInspector.SettingsUI.regexValidator);
},
__proto__: WebInspector.UISettingDelegate.prototype
}
/**
* @constructor
* @extends {WebInspector.UISettingDelegate}
*/
WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate = function()
{
WebInspector.UISettingDelegate.call(this);
}
WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate.prototype = {
/**
* @override
* @return {!Element}
*/
settingElement: function()
{
var disableJSElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Disable JavaScript"), WebInspector.settings.javaScriptDisabled);
this._disableJSCheckbox = disableJSElement.getElementsByTagName("input")[0];
WebInspector.settings.javaScriptDisabled.addChangeListener(this._settingChanged, this);
var disableJSInfoParent = this._disableJSCheckbox.parentElement.createChild("span", "monospace");
this._disableJSInfo = disableJSInfoParent.createChild("span", "object-info-state-note hidden");
this._disableJSInfo.title = WebInspector.UIString("JavaScript is blocked on the inspected page (may be disabled in browser settings).");
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._updateScriptDisabledCheckbox, this);
this._updateScriptDisabledCheckbox();
return disableJSElement;
},
/**
* @param {!WebInspector.Event} event
*/
_settingChanged: function(event)
{
PageAgent.setScriptExecutionDisabled(event.data, this._updateScriptDisabledCheckbox.bind(this));
},
_updateScriptDisabledCheckbox: function()
{
PageAgent.getScriptExecutionStatus(executionStatusCallback.bind(this));
/**
* @param {?Protocol.Error} error
* @param {string} status
* @this {WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate}
*/
function executionStatusCallback(error, status)
{
if (error || !status)
return;
var forbidden = (status === "forbidden");
var disabled = forbidden || (status === "disabled");
this._disableJSInfo.classList.toggle("hidden", !forbidden);
this._disableJSCheckbox.checked = disabled;
this._disableJSCheckbox.disabled = forbidden;
}
},
__proto__: WebInspector.UISettingDelegate.prototype
}
...@@ -132,6 +132,7 @@ body.platform-mac .settings-tab .help-block { ...@@ -132,6 +132,7 @@ body.platform-mac .settings-tab .help-block {
.settings-tab .field-error-message { .settings-tab .field-error-message {
color: DarkRed; color: DarkRed;
height: 0px; // Avoid changing element height when content is set.
} }
.help-line { .help-line {
...@@ -197,7 +198,7 @@ body.platform-mac .help-key { ...@@ -197,7 +198,7 @@ body.platform-mac .help-key {
.settings-tab label { .settings-tab label {
padding-right: 4px; padding-right: 4px;
display: flex; display: inline-flex;
} }
#general-tab-content .help-block fieldset legend { #general-tab-content .help-block fieldset legend {
......
...@@ -42,6 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -42,6 +42,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="DOMExtension.js"></script> <script type="text/javascript" src="DOMExtension.js"></script>
<script type="text/javascript" src="treeoutline.js"></script> <script type="text/javascript" src="treeoutline.js"></script>
<script type="text/javascript" src="WebInspector.js"></script> <script type="text/javascript" src="WebInspector.js"></script>
<script type="text/javascript" src="SettingsUI.js"></script>
<script type="text/javascript" src="Main.js"></script> <script type="text/javascript" src="Main.js"></script>
<script type="text/javascript" src="ModuleManager.js"></script> <script type="text/javascript" src="ModuleManager.js"></script>
<script type="text/javascript" src="Platform.js"></script> <script type="text/javascript" src="Platform.js"></script>
...@@ -54,7 +55,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -54,7 +55,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="Target.js"></script> <script type="text/javascript" src="Target.js"></script>
<script type="text/javascript" src="NotificationService.js"></script> <script type="text/javascript" src="NotificationService.js"></script>
<script type="text/javascript" src="Settings.js"></script> <script type="text/javascript" src="Settings.js"></script>
<script type="text/javascript" src="SettingsUI.js"></script>
<script type="text/javascript" src="View.js"></script> <script type="text/javascript" src="View.js"></script>
<script type="text/javascript" src="UIUtils.js"></script> <script type="text/javascript" src="UIUtils.js"></script>
<script type="text/javascript" src="HelpScreen.js"></script> <script type="text/javascript" src="HelpScreen.js"></script>
......
...@@ -78,6 +78,31 @@ var allDescriptors = [ ...@@ -78,6 +78,31 @@ var allDescriptors = [
} }
], ],
className: "WebInspector.Main.DebugReloadActionDelegate" className: "WebInspector.Main.DebugReloadActionDelegate"
},
{
type: "ui-setting",
title: "Disable cache (while DevTools is open)",
settingName: "cacheDisabled",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Appearance",
title: "Split panels vertically when docked to right",
settingName: "splitVerticallyWhenDockedToRight",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Appearance",
settingType: "custom",
className: "WebInspector.Main.ShortcutPanelSwitchSettingDelegate"
},
{
type: "ui-setting",
section: "Extensions",
settingType: "custom",
className: "WebInspector.HandlerRegistry.OpenAnchorLocationSettingDelegate"
} }
] ]
}, },
...@@ -119,6 +144,47 @@ var allDescriptors = [ ...@@ -119,6 +144,47 @@ var allDescriptors = [
type: "@WebInspector.Revealer", type: "@WebInspector.Revealer",
contextTypes: ["WebInspector.DOMNode"], contextTypes: ["WebInspector.DOMNode"],
className: "WebInspector.ElementsPanel.DOMNodeRevealer" className: "WebInspector.ElementsPanel.DOMNodeRevealer"
},
{
type: "ui-setting",
section: "Elements",
title: "Color format",
settingName: "colorFormat",
settingType: "select",
options: [
[ "As authored", "original" ],
[ "HEX: #DAC0DE", "hex", true ],
[ "RGB: rgb(128, 255, 255)", "rgb", true ],
[ "HSL: hsl(300, 80%, 90%)", "hsl", true ]
]
},
{
type: "ui-setting",
section: "Elements",
title: "Show user agent styles",
settingName: "showUserAgentStyles",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Elements",
title: "Show user agent shadow DOM",
settingName: "showUAShadowDOM",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Elements",
title: "Word wrap",
settingName: "domWordWrap",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Elements",
title: "Show rulers",
settingName: "showMetricsRulers",
settingType: "checkbox"
} }
], ],
scripts: [ "ElementsPanel.js" ] scripts: [ "ElementsPanel.js" ]
...@@ -157,6 +223,19 @@ var allDescriptors = [ ...@@ -157,6 +223,19 @@ var allDescriptors = [
type: "@WebInspector.TokenizerFactory", type: "@WebInspector.TokenizerFactory",
className: "WebInspector.CodeMirrorUtils.TokenizerFactory" className: "WebInspector.CodeMirrorUtils.TokenizerFactory"
}, },
{
type: "ui-setting",
section: "Sources",
title: "Default indentation",
settingName: "textEditorIndent",
settingType: "select",
options: [
["2 spaces", " "],
["4 spaces", " "],
["8 spaces", " "],
["Tab character", "\t"]
]
}
], ],
scripts: [ "CodeMirrorTextEditor.js" ] scripts: [ "CodeMirrorTextEditor.js" ]
}, },
...@@ -237,6 +316,83 @@ var allDescriptors = [ ...@@ -237,6 +316,83 @@ var allDescriptors = [
} }
], ],
className: "WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate" className: "WebInspector.SourcesPanel.ShowGoToSourceDialogActionDelegate"
},
{
type: "ui-setting",
settingName: "javaScriptDisabled",
settingType: "custom",
className: "WebInspector.SourcesPanel.DisableJavaScriptSettingDelegate"
},
{
type: "ui-setting",
section: "Sources",
title: "Search in content scripts",
settingName: "searchInContentScripts",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Enable JavaScript source maps",
settingName: "jsSourceMapsEnabled",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Detect indentation",
settingName: "textEditorAutoDetectIndent",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Autocompletion",
settingName: "textEditorAutocompletion",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Bracket matching",
settingName: "textEditorBracketMatching",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Show whitespace characters",
settingName: "showWhitespacesInEditor",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
title: "Enable CSS source maps",
settingName: "cssSourceMapsEnabled",
settingType: "checkbox"
},
{
type: "ui-setting",
title: "Auto-reload generated CSS",
parentSettingName: "cssSourceMapsEnabled",
settingName: "cssReloadEnabled",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Sources",
experiment: "frameworksDebuggingSupport",
title: "Skip stepping through sources with particular names",
settingName: "skipStackFramesSwitch",
settingType: "checkbox"
},
{
type: "ui-setting",
experiment: "frameworksDebuggingSupport",
parentSettingName: "skipStackFramesSwitch",
settingType: "custom",
className: "WebInspector.SourcesPanel.SkipStackFramePatternSettingDelegate"
} }
], ],
scripts: [ "SourcesPanel.js" ] scripts: [ "SourcesPanel.js" ]
...@@ -268,6 +424,20 @@ var allDescriptors = [ ...@@ -268,6 +424,20 @@ var allDescriptors = [
type: "@WebInspector.ContextMenu.Provider", type: "@WebInspector.ContextMenu.Provider",
contextTypes: ["WebInspector.RemoteObject"], contextTypes: ["WebInspector.RemoteObject"],
className: "WebInspector.ProfilesPanel.ContextMenuProvider" className: "WebInspector.ProfilesPanel.ContextMenuProvider"
},
{
type: "ui-setting",
section: "Profiler",
title: "Show advanced heap snapshot properties",
settingName: "showAdvancedHeapSnapshotProperties",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Profiler",
title: "High resolution CPU profiling",
settingName: "highResolutionCpuProfiling",
settingType: "checkbox"
} }
], ],
scripts: [ "ProfilesPanel.js" ] scripts: [ "ProfilesPanel.js" ]
...@@ -333,6 +503,27 @@ var allDescriptors = [ ...@@ -333,6 +503,27 @@ var allDescriptors = [
} }
], ],
className: "WebInspector.ConsoleView.ShowConsoleActionDelegate" className: "WebInspector.ConsoleView.ShowConsoleActionDelegate"
},
{
type: "ui-setting",
section: "Console",
title: "Log XMLHttpRequests",
settingName: "monitoringXHREnabled",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Console",
title: "Preserve log upon navigation",
settingName: "preserveConsoleLog",
settingType: "checkbox"
},
{
type: "ui-setting",
section: "Console",
title: "Show timestamps",
settingName: "consoleTimestampsEnabled",
settingType: "checkbox"
} }
], ],
scripts: [ "ConsolePanel.js" ] scripts: [ "ConsolePanel.js" ]
......
...@@ -1389,6 +1389,43 @@ StringMap.prototype = { ...@@ -1389,6 +1389,43 @@ StringMap.prototype = {
} }
} }
/**
* @constructor
* @extends {StringMap.<Set.<!T>>}
* @template T
*/
var StringMultimap = function()
{
StringMap.call(this);
}
StringMultimap.prototype = {
/**
* @param {string} key
* @param {T} value
*/
put: function(key, value)
{
if (key === "__proto__") {
if (!this._hasProtoKey) {
++this._size;
this._hasProtoKey = true;
/** @type {!Set.<T>} */
this._protoValue = new Set();
}
this._protoValue.add(value);
return;
}
if (!Object.prototype.hasOwnProperty.call(this._map, key)) {
++this._size;
this._map[key] = new Set();
}
this._map[key].add(value);
},
__proto__: StringMap.prototype
}
/** /**
* @constructor * @constructor
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment