+2012-05-17 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: implement Go To selector for stylesheet files.
+ https://bugs.webkit.org/show_bug.cgi?id=86751
+
+ Reviewed by Yury Semikhatsky.
+
+ StyleSheetOutlineDialog is introduced.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/FilteredItemSelectionDialog.js:
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._createDebugToolbar):
+ (WebInspector.ScriptsPanel.prototype._createButtonAndRegisterShortcuts):
+ (WebInspector.ScriptsPanel.prototype._showOutlineDialog):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSheetOutlineDialog):
+ (WebInspector.StyleSheetOutlineDialog.show):
+ (WebInspector.StyleSheetOutlineDialog.prototype.itemTitleAt):
+ (WebInspector.StyleSheetOutlineDialog.prototype.itemKeyAt):
+ (WebInspector.StyleSheetOutlineDialog.prototype.itemsCount):
+ (WebInspector.StyleSheetOutlineDialog.prototype.requestItems):
+ (WebInspector.StyleSheetOutlineDialog.prototype.requestItems.didGetStyleSheet):
+ (WebInspector.StyleSheetOutlineDialog.prototype.selectItem):
+ * inspector/front-end/TabbedEditorContainer.js:
+ (WebInspector.TabbedEditorContainer.prototype._generateTabId):
+ (WebInspector.TabbedEditorContainer.prototype.currentFile):
+
2012-05-17 Dan Bernstein <mitz@apple.com>
REGRESSION (r117428): WebKit API/SPI was removed
}
WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
- this.debugToolbar = this._createDebugToolbar();
+ var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString(WebInspector.experimentsSettings.sourceCodePanel.isEnabled() ? "Source Code Panel" : "Scripts Panel"));
+ this.debugToolbar = this._createDebugToolbar(helpSection);
const initialDebugSidebarWidth = 225;
const maximalDebugSidebarWidthPercent = 50;
this.sidebarPanes.scopechain.expanded = true;
this.sidebarPanes.jsBreakpoints.expanded = true;
- var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString("Scripts Panel"));
this.sidebarPanes.callstack.registerShortcuts(helpSection, this.registerShortcut.bind(this));
var evaluateInConsoleShortcut = WebInspector.KeyboardShortcut.makeDescriptor("e", WebInspector.KeyboardShortcut.Modifiers.Shift | WebInspector.KeyboardShortcut.Modifiers.Ctrl);
helpSection.addKey(evaluateInConsoleShortcut.name, WebInspector.UIString("Evaluate selection in console"));
this.registerShortcut(evaluateInConsoleShortcut.key, this._evaluateSelectionInConsole.bind(this));
var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
- helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open script"));
+ helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open file"));
- var scriptOutlineShortcut = WebInspector.JavaScriptOutlineDialog.createShortcut();
- helpSection.addKey(scriptOutlineShortcut.name, WebInspector.UIString("Go to function"));
- this.registerShortcut(scriptOutlineShortcut.key, this._showJavaScriptOutlineDialog.bind(this));
+ var outlineShortcut = WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
+ helpSection.addKey(outlineShortcut.name, WebInspector.UIString("Go to member"));
+ this.registerShortcut(outlineShortcut.key, this._showOutlineDialog.bind(this));
var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel.");
var panelEnablerDisclaimer = WebInspector.UIString("Enabling debugging will make scripts run slower.");
WebInspector.evaluateInConsole(selection.toString());
},
- _createDebugToolbar: function()
+ _createDebugToolbar: function(section)
{
var debugToolbar = document.createElement("div");
debugToolbar.className = "status-bar";
shortcuts = [];
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F8));
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Slash, platformSpecificModifier));
- this.pauseButton = this._createButtonAndRegisterShortcuts("scripts-pause", title, handler, shortcuts, WebInspector.UIString("Pause/Continue"));
+ this.pauseButton = this._createButtonAndRegisterShortcuts(section, "scripts-pause", title, handler, shortcuts, WebInspector.UIString("Pause/Continue"));
debugToolbar.appendChild(this.pauseButton);
// Step over.
shortcuts = [];
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F10));
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.SingleQuote, platformSpecificModifier));
- this.stepOverButton = this._createButtonAndRegisterShortcuts("scripts-step-over", title, handler, shortcuts, WebInspector.UIString("Step over"));
+ this.stepOverButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-over", title, handler, shortcuts, WebInspector.UIString("Step over"));
debugToolbar.appendChild(this.stepOverButton);
// Step into.
shortcuts = [];
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F11));
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Semicolon, platformSpecificModifier));
- this.stepIntoButton = this._createButtonAndRegisterShortcuts("scripts-step-into", title, handler, shortcuts, WebInspector.UIString("Step into"));
+ this.stepIntoButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-into", title, handler, shortcuts, WebInspector.UIString("Step into"));
debugToolbar.appendChild(this.stepIntoButton);
// Step out.
shortcuts = [];
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F11, WebInspector.KeyboardShortcut.Modifiers.Shift));
shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Semicolon, WebInspector.KeyboardShortcut.Modifiers.Shift | platformSpecificModifier));
- this.stepOutButton = this._createButtonAndRegisterShortcuts("scripts-step-out", title, handler, shortcuts, WebInspector.UIString("Step out"));
+ this.stepOutButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-out", title, handler, shortcuts, WebInspector.UIString("Step out"));
debugToolbar.appendChild(this.stepOutButton);
this._toggleBreakpointsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Deactivate all breakpoints."), "toggle-breakpoints");
return debugToolbar;
},
- _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler, shortcuts, shortcutDescription)
+ _createButtonAndRegisterShortcuts: function(section, buttonId, buttonTitle, handler, shortcuts, shortcutDescription)
{
var button = document.createElement("button");
button.className = "status-bar-item";
this.registerShortcut(shortcuts[i].key, handler);
shortcutNames.push(shortcuts[i].name);
}
- var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("Scripts Panel"));
section.addAlternateKeys(shortcutNames, shortcutDescription);
return button;
this.sidebarPanes.watchExpressions.addExpression(expression);
},
- _showJavaScriptOutlineDialog: function()
+ _showOutlineDialog: function()
{
- WebInspector.JavaScriptOutlineDialog.show(this.visibleView, this.visibleView);
+ var uiSourceCode = this._editorContainer.currentFile();
+ if (!uiSourceCode)
+ return;
+
+ if (uiSourceCode instanceof WebInspector.JavaScriptSource)
+ WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode);
+ else if (uiSourceCode instanceof WebInspector.StyleSource)
+ WebInspector.StyleSheetOutlineDialog.show(this.visibleView, /** @type {WebInspector.StyleSource} */ uiSourceCode);
},
_installDebuggerSidebarController: function()
}
WebInspector.StyleSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.SelectionDialogContentProvider}
+ * @param {WebInspector.View} view
+ * @param {WebInspector.StyleSource} styleSource
+ */
+WebInspector.StyleSheetOutlineDialog = function(view, styleSource)
+{
+ WebInspector.SelectionDialogContentProvider.call(this);
+
+ this._rules = [];
+ this._view = view;
+ this._styleSource = styleSource;
+}
+
+/**
+ * @param {WebInspector.View} view
+ * @param {WebInspector.StyleSource} styleSource
+ */
+WebInspector.StyleSheetOutlineDialog.show = function(view, styleSource)
+{
+ if (WebInspector.Dialog.currentInstance())
+ return null;
+ var delegate = new WebInspector.StyleSheetOutlineDialog(view, styleSource);
+ var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(delegate);
+ WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
+}
+
+WebInspector.StyleSheetOutlineDialog.prototype = {
+ /**
+ * @param {number} itemIndex
+ * @return {string}
+ */
+ itemTitleAt: function(itemIndex)
+ {
+ return this._rules[itemIndex].selectorText;
+ },
+
+ /**
+ * @param {number} itemIndex
+ * @return {string}
+ */
+ itemKeyAt: function(itemIndex)
+ {
+ return this._rules[itemIndex].selectorText;
+ },
+
+ /**
+ * @return {number}
+ */
+ itemsCount: function()
+ {
+ return this._rules.length;
+ },
+
+ /**
+ * @param {function(number, number, number, number)} callback
+ */
+ requestItems: function(callback)
+ {
+ function didGetAllStyleSheets(error, infos)
+ {
+ if (error) {
+ callback(0, 0, 0, 0);
+ return;
+ }
+
+ for (var i = 0; i < infos.length; ++i) {
+ var info = infos[i];
+ if (info.sourceURL === this._styleSource.contentURL()) {
+ WebInspector.CSSStyleSheet.createForId(info.styleSheetId, didGetStyleSheet.bind(this));
+ return;
+ }
+ }
+ callback(0, 0, 0, 0);
+ }
+
+ CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
+
+ /**
+ * @param {?WebInspector.CSSStyleSheet} styleSheet
+ */
+ function didGetStyleSheet(styleSheet)
+ {
+ if (!styleSheet) {
+ callback(0, 0, 0, 0);
+ return;
+ }
+
+ this._rules = styleSheet.rules;
+ callback(0, this._rules.length, 0, 1);
+ }
+ },
+
+ /**
+ * @param {number} itemIndex
+ */
+ selectItem: function(itemIndex)
+ {
+ var lineNumber = this._rules[itemIndex].sourceLine;
+ if (!isNaN(lineNumber) && lineNumber >= 0)
+ this._view.highlightLine(lineNumber);
+ this._view.focus();
+ }
+}
+
+WebInspector.StyleSheetOutlineDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;