Changeset 92105 in webkit


Ignore:
Timestamp:
Aug 1, 2011 1:17:05 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: group scripts by folder in the scripts selector.
https://bugs.webkit.org/show_bug.cgi?id=65321

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/debugger/scripts-sorting.html

  • inspector/front-end/ScriptsPanel.js:

(WebInspector.ScriptsPanel.prototype._sourceFileAdded.get if):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered.optionCompare):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered):
(WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect):
(WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL):
(WebInspector.ScriptsPanel.prototype.reset):
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):

LayoutTests:

  • http/tests/inspector/debugger-test.js:

(initialize_DebuggerTest):

  • inspector/debugger/scripts-sorting-expected.txt: Added.
  • inspector/debugger/scripts-sorting.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r92104 r92105  
     12011-08-01  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: group scripts by folder in the scripts selector.
     4        https://bugs.webkit.org/show_bug.cgi?id=65321
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        * http/tests/inspector/debugger-test.js:
     9        (initialize_DebuggerTest):
     10        * inspector/debugger/scripts-sorting-expected.txt: Added.
     11        * inspector/debugger/scripts-sorting.html: Added.
     12
    1132011-07-28  Pavel Feldman  <pfeldman@google.com>
    214
  • trunk/LayoutTests/http/tests/inspector/debugger-test.js

    r91568 r92105  
    160160    var filesSelect = document.getElementById("scripts-files");
    161161    for (var i = 0; i < filesSelect.length; ++i) {
    162         if (filesSelect[i].text === scriptName) {
     162        if (filesSelect[i].scriptNameForTest === scriptName) {
    163163            filesSelect.selectedIndex = i;
    164164            WebInspector.panels.scripts._filesSelectChanged();
  • trunk/Source/WebCore/ChangeLog

    r92104 r92105  
     12011-08-01  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: group scripts by folder in the scripts selector.
     4        https://bugs.webkit.org/show_bug.cgi?id=65321
     5
     6        Reviewed by Yury Semikhatsky.
     7
     8        Test: inspector/debugger/scripts-sorting.html
     9
     10        * inspector/front-end/ScriptsPanel.js:
     11        (WebInspector.ScriptsPanel.prototype._sourceFileAdded.get if):
     12        (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered.optionCompare):
     13        (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect.insertOrdered):
     14        (WebInspector.ScriptsPanel.prototype._addOptionToFilesSelect):
     15        (WebInspector.ScriptsPanel.prototype._folderAndDisplayNameForScriptURL):
     16        (WebInspector.ScriptsPanel.prototype.reset):
     17        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
     18
    1192011-07-28  Pavel Feldman  <pfeldman@google.com>
    220
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r90365 r92105  
    241241
    242242        var lastViewedURL = WebInspector.settings.lastViewedScriptFile.get();
    243         if (this._filesSelectElement.length === 1) {
     243        if (!this._filesSelectElement.initialSelectionProcessed) {
     244            this._filesSelectElement.initialSelectionProcessed = true;
    244245            // Option we just added is the only option in files select.
    245246            // We have to show corresponding source frame immediately.
     
    255256    {
    256257        var select = this._filesSelectElement;
     258        if (!select.folderOptions)
     259            select.folderOptions = {};
     260
    257261        var option = document.createElement("option");
    258         option.text = this._displayNameForScriptURL(sourceFile.url) || WebInspector.UIString("(program)");
     262        var parsedURL = sourceFile.url.asParsedURL();
     263
     264        var names = this._folderAndDisplayNameForScriptURL(sourceFile.url);
     265        option.text = names.displayName ? "\u00a0\u00a0\u00a0\u00a0" + names.displayName : WebInspector.UIString("(program)");
     266        option.scriptNameForTest = names.displayName;
     267        var folderNameForSorting = (sourceFile.isContentScript ? "2" : "0") + names.folderName;
     268        option.nameForSorting = folderNameForSorting + "\t/\t" + names.displayName; // Use '\t' to make files stick to their folder.
    259269        option.title = sourceFile.url;
    260         option.isContentScript = sourceFile.isContentScript;
    261270        if (sourceFile.isContentScript)
    262271            option.addStyleClass("extension-script");
    263         function compare(a, b)
     272
     273        function insertOrdered(option)
    264274        {
    265             return a < b ? -1 : (a > b ? 1 : 0);
    266         }
    267         function optionCompare(a, b)
    268         {
    269             if (a === select.contentScriptSection)
    270                 return b.isContentScript ? -1 : 1;
    271             if (b === select.contentScriptSection)
    272                 return a.isContentScript ? 1 : -1;
    273 
    274             if (a.isContentScript && !b.isContentScript)
    275                 return 1;
    276             if (!a.isContentScript && b.isContentScript)
    277                 return -1;
    278 
    279             return compare(a.text, b.text) || compare(a.title, b.title);
    280         }
    281 
    282         var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare);
    283         select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
     275            function optionCompare(a, b)
     276            {
     277                return a.nameForSorting.localeCompare(b.nameForSorting);
     278            }
     279            var insertionIndex = insertionIndexForObjectInListSortedByFunction(option, select.childNodes, optionCompare);
     280            select.insertBefore(option, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
     281        }
     282
     283        insertOrdered(option);
    284284
    285285        if (sourceFile.isContentScript && !select.contentScriptSection) {
     
    287287            contentScriptSection.text = WebInspector.UIString("Content scripts");
    288288            contentScriptSection.disabled = true;
     289            option.nameForSorting = "1/ContentScriptSeparator";
    289290            select.contentScriptSection = contentScriptSection;
    290 
    291             var insertionIndex = insertionIndexForObjectInListSortedByFunction(contentScriptSection, select.childNodes, optionCompare);
    292             select.insertBefore(contentScriptSection, insertionIndex < 0 ? null : select.childNodes.item(insertionIndex));
    293         }
     291            insertOrdered(contentScriptSection);
     292        }
     293
     294        if (names.folderName && !select.folderOptions[names.folderName]) {
     295            var folderOption = document.createElement("option");
     296            folderOption.text = names.folderName;
     297            folderOption.nameForSorting = folderNameForSorting;
     298            folderOption.disabled = true;
     299            select.folderOptions[names.folderName] = folderOption;
     300            insertOrdered(folderOption);
     301        }
     302
    294303        option._sourceFileId = sourceFile.id;
    295304        this._sourceFileIdToFilesSelectOption[sourceFile.id] = option;
    296305    },
    297306
    298     _displayNameForScriptURL: function(url)
    299     {
     307    _folderAndDisplayNameForScriptURL: function(url)
     308    {
     309        var parsedURL = url.asParsedURL();
     310        if (parsedURL)
     311            url = parsedURL.path;
     312
     313        var folderName = "";
    300314        var displayName = url;
    301         var indexOfQuery = displayName.indexOf("?");
    302         if (indexOfQuery > 0)
    303             displayName = displayName.substring(0, indexOfQuery);
     315
    304316        var fromIndex = displayName.lastIndexOf("/", displayName.length - 2);
    305         if (fromIndex !== -1)
     317        if (fromIndex !== -1) {
     318            folderName = displayName.substring(0, fromIndex);
    306319            displayName = displayName.substring(fromIndex + 1);
    307         if (displayName.length > 100)
    308             displayName = displayName.substring(0, 80) + "...";
    309         return displayName;
     320        }
     321
     322        if (displayName.length > 80)
     323            displayName = "\u2026" + displayName.substring(displayName.length - 80);
     324
     325        if (folderName.length > 80)
     326            folderName = "\u2026" + folderName.substring(folderName.length - 80);
     327 
     328        return { folderName: folderName, displayName: displayName};
    310329    },
    311330
     
    496515        this._sourceFileIdToFilesSelectOption = {};
    497516        this._filesSelectElement.removeChildren();
     517        this._filesSelectElement.removeChildren();
     518        this._filesSelectElement.folderOptions = {};
     519        delete this._filesSelectElement.initialSelectionProcessed;
     520        delete this._filesSelectElement.contentScriptSection;
     521
    498522        this.functionsSelectElement.removeChildren();
    499523        this.viewsContainerElement.removeChildren();
     
    11821206    {
    11831207        var sourceFile = this._model.sourceFile(this._sourceFileId);
    1184         return WebInspector.panels.scripts._displayNameForScriptURL(sourceFile.url) || "untitled.js";
     1208        var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(sourceFile.url);
     1209        return names.displayName || "untitled.js";
    11851210    }
    11861211}
Note: See TracChangeset for help on using the changeset viewer.