Changeset 117974 in webkit


Ignore:
Timestamp:
May 22, 2012 8:04:49 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: make "Go to source" shortcut accessible from all panels.
https://bugs.webkit.org/show_bug.cgi?id=87132

Reviewed by Vsevolod Vlasov.

  • English.lproj/localizedStrings.js:
  • inspector/front-end/AdvancedSearchController.js:

(WebInspector.AdvancedSearchController.prototype.handleShortcut):

  • inspector/front-end/FilteredItemSelectionDialog.js:

(WebInspector.OpenResourceDialog.filterOutEmptyURLs):
(WebInspector.OpenResourceDialog.compareFunction):
(WebInspector.OpenResourceDialog):
(WebInspector.OpenResourceDialog.prototype.itemTitleAt):
(WebInspector.OpenResourceDialog.prototype.itemKeyAt):
(WebInspector.OpenResourceDialog.prototype.itemsCount):
(WebInspector.OpenResourceDialog.prototype.requestItems):
(WebInspector.OpenResourceDialog.prototype.selectItem):
(WebInspector.OpenResourceDialog.show):

  • inspector/front-end/ScriptsPanel.js:

(WebInspector.ScriptsPanel.prototype.appendApplicableItems):
(WebInspector.ScriptsPanel.prototype.showGoToSourceDialog):

  • inspector/front-end/SearchController.js:

(WebInspector.SearchController.prototype.handleShortcut):

  • inspector/front-end/inspector.js:

(WebInspector._registerShortcuts):
(WebInspector.documentKeyDown):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117973 r117974  
     12012-05-22  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: make "Go to source" shortcut accessible from all panels.
     4        https://bugs.webkit.org/show_bug.cgi?id=87132
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        * English.lproj/localizedStrings.js:
     9        * inspector/front-end/AdvancedSearchController.js:
     10        (WebInspector.AdvancedSearchController.prototype.handleShortcut):
     11        * inspector/front-end/FilteredItemSelectionDialog.js:
     12        (WebInspector.OpenResourceDialog.filterOutEmptyURLs):
     13        (WebInspector.OpenResourceDialog.compareFunction):
     14        (WebInspector.OpenResourceDialog):
     15        (WebInspector.OpenResourceDialog.prototype.itemTitleAt):
     16        (WebInspector.OpenResourceDialog.prototype.itemKeyAt):
     17        (WebInspector.OpenResourceDialog.prototype.itemsCount):
     18        (WebInspector.OpenResourceDialog.prototype.requestItems):
     19        (WebInspector.OpenResourceDialog.prototype.selectItem):
     20        (WebInspector.OpenResourceDialog.show):
     21        * inspector/front-end/ScriptsPanel.js:
     22        (WebInspector.ScriptsPanel.prototype.appendApplicableItems):
     23        (WebInspector.ScriptsPanel.prototype.showGoToSourceDialog):
     24        * inspector/front-end/SearchController.js:
     25        (WebInspector.SearchController.prototype.handleShortcut):
     26        * inspector/front-end/inspector.js:
     27        (WebInspector._registerShortcuts):
     28        (WebInspector.documentKeyDown):
     29
    1302012-05-22  Ilya Tikhonovsky  <loislo@chromium.org>
    231
  • trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js

    r117750 r117974  
    5151    /**
    5252     * @param {Event} event
     53     * @return {boolean}
    5354     */
    5455    handleShortcut: function(event)
     
    6162                this.close();
    6263            event.consume();
     64            return true;
    6365        }
     66        return false;
    6467    },
    6568
  • trunk/Source/WebCore/inspector/front-end/FilteredItemSelectionDialog.js

    r117462 r117974  
    573573 * @constructor
    574574 * @implements {WebInspector.SelectionDialogContentProvider}
    575  * @param {Array.<WebInspector.Resource>} resources
     575 * @param {WebInspector.ScriptsPanel} panel
     576 * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
    576577 */
    577 WebInspector.OpenResourceDialog = function(resources)
     578WebInspector.OpenResourceDialog = function(panel, uiSourceCodeProvider)
    578579{
    579     // FIXME: migrate from WebInspector.Resource to WebInspector.Source (base for Resource and UISourceCode) and make this dialog OpenSource.
    580580    WebInspector.SelectionDialogContentProvider.call(this);
    581 
    582     this.resources = resources;
    583 
    584     function filterOutEmptyURLs(resource)
    585     {
    586         return !!resource.parsedURL.lastPathComponent;
     581    this._panel = panel;
     582
     583    this._uiSourceCodes = uiSourceCodeProvider.uiSourceCodes();
     584
     585    function filterOutEmptyURLs(uiSourceCode)
     586    {
     587        return !!uiSourceCode.parsedURL.lastPathComponent;
    587588    }
    588     this.resources = this.resources.filter(filterOutEmptyURLs);
    589 
    590     function compareFunction(resource1, resource2)
    591     {
    592         return resource1.parsedURL.lastPathComponent.localeCompare(resource2.parsedURL.lastPathComponent);
     589    this._uiSourceCodes = this._uiSourceCodes.filter(filterOutEmptyURLs);
     590
     591    function compareFunction(uiSourceCode1, uiSourceCode2)
     592    {
     593        return uiSourceCode1.parsedURL.lastPathComponent.localeCompare(uiSourceCode2.parsedURL.lastPathComponent);
    593594    }
    594     this.resources.sort(compareFunction);
     595    this._uiSourceCodes.sort(compareFunction);
    595596}
    596597
     
    607608    itemTitleAt: function(itemIndex)
    608609    {
    609         return this.resources[itemIndex].parsedURL.lastPathComponent;
     610        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
    610611    },
    611612
     
    616617    itemKeyAt: function(itemIndex)
    617618    {
    618         return this.resources[itemIndex].parsedURL.lastPathComponent;
     619        return this._uiSourceCodes[itemIndex].parsedURL.lastPathComponent;
    619620    },
    620621
     
    624625    itemsCount: function()
    625626    {
    626         return this.resources.length;
     627        return this._uiSourceCodes.length;
    627628    },
    628629
     
    632633    requestItems: function(callback)
    633634    {
    634         callback(0, this.resources.length, 1, 1);
     635        callback(0, this._uiSourceCodes.length, 1, 1);
    635636    },
    636637
     
    640641    selectItem: function(itemIndex)
    641642    {
    642         // Overriden by descendants;
     643        this._panel.showUISourceCode(this._uiSourceCodes[itemIndex]);
    643644    }
    644645}
    645646
    646647WebInspector.OpenResourceDialog.prototype.__proto__ = WebInspector.SelectionDialogContentProvider.prototype;
    647 
    648 /**
    649  * @constructor
    650  * @extends {WebInspector.OpenResourceDialog}
    651  * @param {WebInspector.ScriptsPanel} panel
    652  * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
    653  */
    654 WebInspector.OpenScriptDialog = function(panel, uiSourceCodeProvider)
    655 {
    656     WebInspector.OpenResourceDialog.call(this, uiSourceCodeProvider.uiSourceCodes());
    657     this._panel = panel;
    658 }
    659 
    660 /**
    661  * @param {WebInspector.ScriptsPanel} panel
    662  * @param {WebInspector.UISourceCodeProvider} uiSourceCodeProvider
    663  */
    664 WebInspector.OpenScriptDialog.install = function(panel, uiSourceCodeProvider, relativeToElement)
    665 {
    666     function showOpenResourceDialog()
    667     {
    668         WebInspector.OpenScriptDialog._show(panel, uiSourceCodeProvider, relativeToElement);
    669     }
    670 
    671     var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
    672     panel.registerShortcut(openResourceShortcut.key, showOpenResourceDialog);
    673 }
    674648
    675649/**
     
    678652 * @param {Element} relativeToElement
    679653 */
    680 WebInspector.OpenScriptDialog._show = function(panel, uiSourceCodeProvider, relativeToElement)
     654WebInspector.OpenResourceDialog.show = function(panel, uiSourceCodeProvider, relativeToElement)
    681655{
    682656    if (WebInspector.Dialog.currentInstance())
    683657        return;
    684658
    685     var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenScriptDialog(panel, uiSourceCodeProvider));
     659    var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(panel, uiSourceCodeProvider));
    686660    WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
    687661}
    688 
    689 WebInspector.OpenScriptDialog.prototype = {
    690     /**
    691      * @param {number} itemIndex
    692      */
    693     selectItem: function(itemIndex)
    694     {
    695         this._panel.showUISourceCode(this.resources[itemIndex]);
    696     }
    697 }
    698 
    699 WebInspector.OpenScriptDialog.prototype.__proto__ = WebInspector.OpenResourceDialog.prototype;
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r117917 r117974  
    8686    this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previouslyViewedFiles");
    8787    this._editorContainer.show(this.editorView.mainElement);
    88     WebInspector.OpenScriptDialog.install(this, this._uiSourceCodeProvider, this.editorView.mainElement);
    8988
    9089    this._navigatorController = new WebInspector.NavigatorOverlayController(this, this.editorView, this._navigator.view, this._editorContainer.view);
     
    132131    helpSection.addKey(evaluateInConsoleShortcut.name, WebInspector.UIString("Evaluate selection in console"));
    133132    this.registerShortcut(evaluateInConsoleShortcut.key, this._evaluateSelectionInConsole.bind(this));
    134 
    135     var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
    136     helpSection.addKey(openResourceShortcut.name, WebInspector.UIString("Open file"));
    137133
    138134    var outlineShortcut = WebInspector.KeyboardShortcut.makeDescriptor("o", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta | WebInspector.KeyboardShortcut.Modifiers.Shift);
     
    10701066            contextMenu.appendSeparator();
    10711067        }
     1068    },
     1069
     1070    showGoToSourceDialog: function()
     1071    {
     1072        WebInspector.inspectorView.setCurrentPanel(this);
     1073        WebInspector.OpenResourceDialog.show(this, this._uiSourceCodeProvider, this.editorView.mainElement);
    10721074    }
    10731075}
  • trunk/Source/WebCore/inspector/front-end/SearchController.js

    r116672 r117974  
    8585    },
    8686
     87    /**
     88     * @param {Event} event
     89     * @return {boolean}
     90     */
    8791    handleShortcut: function(event)
    8892    {
     
    98102                if (isFindKey) {
    99103                    this.focusSearchField();
    100                     event.handled = true;
     104                    event.consume();
     105                    return true;
    101106                }
    102107                break;
     
    106111                if (!isMac) {
    107112                    this.focusSearchField();
    108                     event.handled = true;
     113                    event.consume();
    109114                }
    110115                break;
     
    119124                    } else if (currentPanel.jumpToNextSearchResult)
    120125                        currentPanel.jumpToNextSearchResult();
    121                     event.handled = true;
     126                    event.consume();
     127                    return true;
    122128                }
    123129                break;
    124130        }
     131        return false;
    125132    },
    126133
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r117799 r117974  
    688688    section.addKey(shortcut.shortcutToString(shortcut.Keys.Esc), WebInspector.UIString("Toggle console"));
    689689    section.addKey(shortcut.shortcutToString("f", shortcut.Modifiers.CtrlOrMeta), WebInspector.UIString("Search"));
    690    
     690
    691691    var advancedSearchShortcut = WebInspector.AdvancedSearchController.createShortcut();
    692692    section.addKey(advancedSearchShortcut.name, WebInspector.UIString("Search across all sources"));
    693    
     693
     694    var openResourceShortcut = WebInspector.OpenResourceDialog.createShortcut();
     695    section.addKey(openResourceShortcut.name, WebInspector.UIString("Go to source"));
     696
    694697    if (WebInspector.isMac()) {
    695698        keys = [
     
    731734    }
    732735
    733     WebInspector.searchController.handleShortcut(event);
    734     WebInspector.advancedSearchController.handleShortcut(event);
    735     if (event.handled) {
    736         event.consume(true);
    737         return;
    738     }
    739 
    740     var isMac = WebInspector.isMac();
     736    if (WebInspector.searchController.handleShortcut(event))
     737        return;
     738    if (WebInspector.advancedSearchController.handleShortcut(event))
     739        return;
     740
    741741    switch (event.keyIdentifier) {
     742        case "U+004F": // O key
     743            if (!event.shiftKey && !event.altKey && WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) {
     744                WebInspector.panels.scripts.showGoToSourceDialog();
     745                event.consume(true);
     746            }
     747            break;
    742748        case "U+0052": // R key
    743             if ((event.metaKey && isMac) || (event.ctrlKey && !isMac)) {
     749            if (WebInspector.KeyboardShortcut.eventHasCtrlOrMeta(event)) {
    744750                PageAgent.reload(event.shiftKey);
    745751                event.consume(true);
     
    747753            break;
    748754        case "F5":
    749             if (!isMac) {
     755            if (!WebInspector.isMac()) {
    750756                PageAgent.reload(event.ctrlKey || event.shiftKey);
    751757                event.consume(true);
Note: See TracChangeset for help on using the changeset viewer.