Changeset 117462 in webkit


Ignore:
Timestamp:
May 17, 2012 10:52:33 AM (12 years ago)
Author:
pfeldman@chromium.org
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):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117460 r117462  
     12012-05-17  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: implement Go To selector for stylesheet files.
     4        https://bugs.webkit.org/show_bug.cgi?id=86751
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        StyleSheetOutlineDialog is introduced.
     9
     10        * English.lproj/localizedStrings.js:
     11        * inspector/front-end/FilteredItemSelectionDialog.js:
     12        * inspector/front-end/ScriptsPanel.js:
     13        (WebInspector.ScriptsPanel.prototype._createDebugToolbar):
     14        (WebInspector.ScriptsPanel.prototype._createButtonAndRegisterShortcuts):
     15        (WebInspector.ScriptsPanel.prototype._showOutlineDialog):
     16        * inspector/front-end/StylesPanel.js:
     17        (WebInspector.StyleSheetOutlineDialog):
     18        (WebInspector.StyleSheetOutlineDialog.show):
     19        (WebInspector.StyleSheetOutlineDialog.prototype.itemTitleAt):
     20        (WebInspector.StyleSheetOutlineDialog.prototype.itemKeyAt):
     21        (WebInspector.StyleSheetOutlineDialog.prototype.itemsCount):
     22        (WebInspector.StyleSheetOutlineDialog.prototype.requestItems):
     23        (WebInspector.StyleSheetOutlineDialog.prototype.requestItems.didGetStyleSheet):
     24        (WebInspector.StyleSheetOutlineDialog.prototype.selectItem):
     25        * inspector/front-end/TabbedEditorContainer.js:
     26        (WebInspector.TabbedEditorContainer.prototype._generateTabId):
     27        (WebInspector.TabbedEditorContainer.prototype.currentFile):
     28
    1292012-05-17  Dan Bernstein  <mitz@apple.com>
    230
  • trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js

    r117277 r117462  
    490490}
    491491
    492 WebInspector.JavaScriptOutlineDialog.createShortcut = function()
    493 {
    494     return WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
    495 }
    496 
    497492WebInspector.JavaScriptOutlineDialog.prototype = {
    498493    /**
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r117455 r117462  
    5555    WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
    5656
    57     this.debugToolbar = this._createDebugToolbar();
     57    var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString(WebInspector.experimentsSettings.sourceCodePanel.isEnabled() ? "Source Code Panel" : "Scripts Panel"));
     58    this.debugToolbar = this._createDebugToolbar(helpSection);
    5859
    5960    const initialDebugSidebarWidth = 225;
     
    127128    this.sidebarPanes.jsBreakpoints.expanded = true;
    128129
    129     var helpSection = WebInspector.shortcutsScreen.section(WebInspector.UIString("Scripts Panel"));
    130130    this.sidebarPanes.callstack.registerShortcuts(helpSection, this.registerShortcut.bind(this));
    131131    var evaluateInConsoleShortcut = WebInspector.KeyboardShortcut.makeDescriptor("e", WebInspector.KeyboardShortcut.Modifiers.Shift | WebInspector.KeyboardShortcut.Modifiers.Ctrl);
     
    134134
    135135    var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
    136     helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open script"));
    137 
    138     var scriptOutlineShortcut = WebInspector.JavaScriptOutlineDialog.createShortcut();
    139     helpSection.addKey(scriptOutlineShortcut.name, WebInspector.UIString("Go to function"));
    140     this.registerShortcut(scriptOutlineShortcut.key, this._showJavaScriptOutlineDialog.bind(this));
     136    helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open file"));
     137
     138    var outlineShortcut = WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
     139    helpSection.addKey(outlineShortcut.name, WebInspector.UIString("Go to member"));
     140    this.registerShortcut(outlineShortcut.key, this._showOutlineDialog.bind(this));
    141141
    142142    var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel.");
     
    785785    },
    786786
    787     _createDebugToolbar: function()
     787    _createDebugToolbar: function(section)
    788788    {
    789789        var debugToolbar = document.createElement("div");
     
    800800        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F8));
    801801        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Slash, platformSpecificModifier));
    802         this.pauseButton = this._createButtonAndRegisterShortcuts("scripts-pause", title, handler, shortcuts, WebInspector.UIString("Pause/Continue"));
     802        this.pauseButton = this._createButtonAndRegisterShortcuts(section, "scripts-pause", title, handler, shortcuts, WebInspector.UIString("Pause/Continue"));
    803803        debugToolbar.appendChild(this.pauseButton);
    804804
     
    809809        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F10));
    810810        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.SingleQuote, platformSpecificModifier));
    811         this.stepOverButton = this._createButtonAndRegisterShortcuts("scripts-step-over", title, handler, shortcuts, WebInspector.UIString("Step over"));
     811        this.stepOverButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-over", title, handler, shortcuts, WebInspector.UIString("Step over"));
    812812        debugToolbar.appendChild(this.stepOverButton);
    813813
     
    818818        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F11));
    819819        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Semicolon, platformSpecificModifier));
    820         this.stepIntoButton = this._createButtonAndRegisterShortcuts("scripts-step-into", title, handler, shortcuts, WebInspector.UIString("Step into"));
     820        this.stepIntoButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-into", title, handler, shortcuts, WebInspector.UIString("Step into"));
    821821        debugToolbar.appendChild(this.stepIntoButton);
    822822
     
    827827        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.F11, WebInspector.KeyboardShortcut.Modifiers.Shift));
    828828        shortcuts.push(WebInspector.KeyboardShortcut.makeDescriptor(WebInspector.KeyboardShortcut.Keys.Semicolon, WebInspector.KeyboardShortcut.Modifiers.Shift | platformSpecificModifier));
    829         this.stepOutButton = this._createButtonAndRegisterShortcuts("scripts-step-out", title, handler, shortcuts, WebInspector.UIString("Step out"));
     829        this.stepOutButton = this._createButtonAndRegisterShortcuts(section, "scripts-step-out", title, handler, shortcuts, WebInspector.UIString("Step out"));
    830830        debugToolbar.appendChild(this.stepOutButton);
    831831
     
    842842    },
    843843
    844     _createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler, shortcuts, shortcutDescription)
     844    _createButtonAndRegisterShortcuts: function(section, buttonId, buttonTitle, handler, shortcuts, shortcutDescription)
    845845    {
    846846        var button = document.createElement("button");
     
    857857            shortcutNames.push(shortcuts[i].name);
    858858        }
    859         var section = WebInspector.shortcutsScreen.section(WebInspector.UIString("Scripts Panel"));
    860859        section.addAlternateKeys(shortcutNames, shortcutDescription);
    861860
     
    947946    },
    948947
    949     _showJavaScriptOutlineDialog: function()
    950     {
    951          WebInspector.JavaScriptOutlineDialog.show(this.visibleView, this.visibleView);
     948    _showOutlineDialog: function()
     949    {
     950         var uiSourceCode = this._editorContainer.currentFile();
     951         if (!uiSourceCode)
     952             return;
     953
     954         if (uiSourceCode instanceof WebInspector.JavaScriptSource)
     955             WebInspector.JavaScriptOutlineDialog.show(this.visibleView, uiSourceCode);
     956         else if (uiSourceCode instanceof WebInspector.StyleSource)
     957             WebInspector.StyleSheetOutlineDialog.show(this.visibleView, /** @type {WebInspector.StyleSource} */ uiSourceCode);
    952958    },
    953959
  • trunk/Source/WebCore/inspector/front-end/StylesPanel.js

    r117455 r117462  
    162162
    163163WebInspector.StyleSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
     164
     165/**
     166 * @constructor
     167 * @implements {WebInspector.SelectionDialogContentProvider}
     168 * @param {WebInspector.View} view
     169 * @param {WebInspector.StyleSource} styleSource
     170 */
     171WebInspector.StyleSheetOutlineDialog = function(view, styleSource)
     172{
     173    WebInspector.SelectionDialogContentProvider.call(this);
     174
     175    this._rules = [];
     176    this._view = view;
     177    this._styleSource = styleSource;
     178}
     179
     180/**
     181 * @param {WebInspector.View} view
     182 * @param {WebInspector.StyleSource} styleSource
     183 */
     184WebInspector.StyleSheetOutlineDialog.show = function(view, styleSource)
     185{
     186    if (WebInspector.Dialog.currentInstance())
     187        return null;
     188    var delegate = new WebInspector.StyleSheetOutlineDialog(view, styleSource);
     189    var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(delegate);
     190    WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
     191}
     192
     193WebInspector.StyleSheetOutlineDialog.prototype = {
     194    /**
     195     * @param {number} itemIndex
     196     * @return {string}
     197     */
     198    itemTitleAt: function(itemIndex)
     199    {
     200        return this._rules[itemIndex].selectorText;
     201    },
     202
     203    /**
     204     * @param {number} itemIndex
     205     * @return {string}
     206     */
     207    itemKeyAt: function(itemIndex)
     208    {
     209        return this._rules[itemIndex].selectorText;
     210    },
     211
     212    /**
     213     * @return {number}
     214     */
     215    itemsCount: function()
     216    {
     217        return this._rules.length;
     218    },
     219
     220    /**
     221     * @param {function(number, number, number, number)} callback
     222     */
     223    requestItems: function(callback)
     224    {
     225        function didGetAllStyleSheets(error, infos)
     226        {
     227            if (error) {
     228                callback(0, 0, 0, 0);
     229                return;
     230            }
     231 
     232            for (var i = 0; i < infos.length; ++i) {
     233                var info = infos[i];
     234                if (info.sourceURL === this._styleSource.contentURL()) {
     235                    WebInspector.CSSStyleSheet.createForId(info.styleSheetId, didGetStyleSheet.bind(this));
     236                    return;
     237                }
     238            }
     239            callback(0, 0, 0, 0);
     240        }
     241
     242        CSSAgent.getAllStyleSheets(didGetAllStyleSheets.bind(this));
     243
     244        /**
     245         * @param {?WebInspector.CSSStyleSheet} styleSheet
     246         */
     247        function didGetStyleSheet(styleSheet)
     248        {
     249            if (!styleSheet) {
     250                callback(0, 0, 0, 0);
     251                return;
     252            }
     253
     254            this._rules = styleSheet.rules;
     255            callback(0, this._rules.length, 0, 1);
     256        }
     257    },
     258
     259    /**
     260     * @param {number} itemIndex
     261     */
     262    selectItem: function(itemIndex)
     263    {
     264        var lineNumber = this._rules[itemIndex].sourceLine;
     265        if (!isNaN(lineNumber) && lineNumber >= 0)
     266            this._view.highlightLine(lineNumber);
     267        this._view.focus();
     268    }
     269}
     270
     271WebInspector.StyleSheetOutlineDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;
  • trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js

    r117274 r117462  
    347347    {
    348348        return "tab_" + (WebInspector.TabbedEditorContainer._tabId++);
     349    },
     350
     351    /**
     352     * @return {WebInspector.UISourceCode} uiSourceCode
     353     */
     354    currentFile: function()
     355    {
     356        return this._currentFile;
    349357    }
    350358}
Note: See TracChangeset for help on using the changeset viewer.