Title: [117462] trunk/Source/WebCore
Revision
117462
Author
pfeld...@chromium.org
Date
2012-05-17 10:52:33 -0700 (Thu, 17 May 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117461 => 117462)


--- trunk/Source/WebCore/ChangeLog	2012-05-17 17:50:30 UTC (rev 117461)
+++ trunk/Source/WebCore/ChangeLog	2012-05-17 17:52:33 UTC (rev 117462)
@@ -1,3 +1,31 @@
+2012-05-17  Pavel Feldman  <pfeld...@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  <m...@apple.com>
 
         REGRESSION (r117428): WebKit API/SPI was removed

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js (117461 => 117462)


--- trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-05-17 17:50:30 UTC (rev 117461)
+++ trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js	2012-05-17 17:52:33 UTC (rev 117462)
@@ -489,11 +489,6 @@
     WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
 }
 
-WebInspector._javascript_OutlineDialog.createShortcut = function()
-{
-    return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
-}
-
 WebInspector._javascript_OutlineDialog.prototype = {
     /**
      * @param {number} itemIndex

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (117461 => 117462)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-17 17:50:30 UTC (rev 117461)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-05-17 17:52:33 UTC (rev 117462)
@@ -54,7 +54,8 @@
     }
     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;
@@ -126,18 +127,17 @@
     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._javascript_OutlineDialog.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.");
@@ -784,7 +784,7 @@
             WebInspector.evaluateInConsole(selection.toString());
     },
 
-    _createDebugToolbar: function()
+    _createDebugToolbar: function(section)
     {
         var debugToolbar = document.createElement("div");
         debugToolbar.className = "status-bar";
@@ -799,7 +799,7 @@
         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.
@@ -808,7 +808,7 @@
         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.
@@ -817,7 +817,7 @@
         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.
@@ -826,7 +826,7 @@
         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");
@@ -841,7 +841,7 @@
         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";
@@ -856,7 +856,6 @@
             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;
@@ -946,9 +945,16 @@
         this.sidebarPanes.watchExpressions.addExpression(_expression_);
     },
 
-    _showJavaScriptOutlineDialog: function()
+    _showOutlineDialog: function()
     {
-         WebInspector._javascript_OutlineDialog.show(this.visibleView, this.visibleView);
+         var uiSourceCode = this._editorContainer.currentFile();
+         if (!uiSourceCode)
+             return;
+
+         if (uiSourceCode instanceof WebInspector._javascript_Source)
+             WebInspector._javascript_OutlineDialog.show(this.visibleView, uiSourceCode);
+         else if (uiSourceCode instanceof WebInspector.StyleSource)
+             WebInspector.StyleSheetOutlineDialog.show(this.visibleView, /** @type {WebInspector.StyleSource} */ uiSourceCode);
     },
 
     _installDebuggerSidebarController: function()

Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (117461 => 117462)


--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-05-17 17:50:30 UTC (rev 117461)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js	2012-05-17 17:52:33 UTC (rev 117462)
@@ -161,3 +161,111 @@
 }
 
 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;

Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (117461 => 117462)


--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-05-17 17:50:30 UTC (rev 117461)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js	2012-05-17 17:52:33 UTC (rev 117462)
@@ -346,6 +346,14 @@
     _generateTabId: function()
     {
         return "tab_" + (WebInspector.TabbedEditorContainer._tabId++);
+    },
+
+    /**
+     * @return {WebInspector.UISourceCode} uiSourceCode
+     */
+    currentFile: function()
+    {
+        return this._currentFile;
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to