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;
......
...@@ -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