Changeset 201692 in webkit


Ignore:
Timestamp:
Jun 4, 2016 5:59:40 PM (8 years ago)
Author:
BJ Burg
Message:

Web Inspector: add a keyboard shortcut to open the new tab tab
https://bugs.webkit.org/show_bug.cgi?id=158365
<rdar://problem/26631897>

Reviewed by Timothy Hatcher.

Make Cmd-t show the new tab tab if it's not already open and
there is at least one tab type that's not currently in the tab bar.

  • UserInterface/Base/Main.js:

(WebInspector.contentLoaded):
(WebInspector._updateNewTabButtonState):
(WebInspector.showNewTabTab):
(WebInspector.isNewTabWithTypeAllowed):
Clean up the code that decides whether we can show the new tab tab.
It is now a special case inside WebInspector.isNewTabWithTypeAllowed.

  • UserInterface/Views/NewTabContentView.js:

(WebInspector.NewTabContentView.prototype._updateShownTabs):
Use Array.from.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r201686 r201692  
     12016-06-04  Brian Burg  <bburg@apple.com>
     2
     3        Web Inspector: add a keyboard shortcut to open the new tab tab
     4        https://bugs.webkit.org/show_bug.cgi?id=158365
     5        <rdar://problem/26631897>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Make Cmd-t show the new tab tab if it's not already open and
     10        there is at least one tab type that's not currently in the tab bar.
     11
     12        * UserInterface/Base/Main.js:
     13        (WebInspector.contentLoaded):
     14        (WebInspector._updateNewTabButtonState):
     15        (WebInspector.showNewTabTab):
     16        (WebInspector.isNewTabWithTypeAllowed):
     17        Clean up the code that decides whether we can show the new tab tab.
     18        It is now a special case inside WebInspector.isNewTabWithTypeAllowed.
     19
     20        * UserInterface/Views/NewTabContentView.js:
     21        (WebInspector.NewTabContentView.prototype._updateShownTabs):
     22        Use Array.from.
     23
    1242016-06-04  Matt Baker  <mattbaker@apple.com>
    225
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r201620 r201692  
    269269
    270270    this._showTabAtIndexKeyboardShortcuts = [1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, `${i}`, this._showTabAtIndex.bind(this, i)));
     271    this._openNewTabKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "T", this.showNewTabTab.bind(this));
    271272
    272273    this.tabBrowser = new WebInspector.TabBrowser(document.getElementById("tab-browser"), this.tabBar, this.navigationSidebar, this.detailsSidebar);
     
    521522WebInspector._updateNewTabButtonState = function(event)
    522523{
    523     let allTabs = [...this._knownTabClassesByType.values()];
    524     let addableTabs = allTabs.filter((tabClass) => !tabClass.isEphemeral());
    525     let canMakeNewTab = addableTabs.some((tabClass) => this.isNewTabWithTypeAllowed(tabClass.Type));
    526     this.tabBar.newTabItem.disabled = !canMakeNewTab;
     524    this.tabBar.newTabItem.disabled = this.isNewTabWithTypeAllowed(WebInspector.NewTabContentView.Type);
    527525};
    528526
     
    563561WebInspector.showNewTabTab = function(shouldAnimate)
    564562{
     563    if (!this.isNewTabWithTypeAllowed(WebInspector.NewTabContentView.Type))
     564        return;
     565
    565566    let tabContentView = this.tabBrowser.bestTabContentViewForClass(WebInspector.NewTabContentView);
    566567    if (!tabContentView)
     
    582583        if (tabContentView.constructor === tabClass)
    583584            return false;
     585    }
     586
     587    if (tabClass === WebInspector.NewTabContentView) {
     588        let allTabs = Array.from(this.knownTabClasses());
     589        let addableTabs = allTabs.filter((tabClass) => !tabClass.isEphemeral());
     590        let canMakeNewTab = addableTabs.some((tabClass) => WebInspector.isNewTabWithTypeAllowed(tabClass.Type));
     591        return canMakeNewTab;
    584592    }
    585593
  • trunk/Source/WebInspectorUI/UserInterface/Views/NewTabContentView.js

    r193508 r201692  
    131131    _updateShownTabs()
    132132    {
    133         let allTabClasses = [...WebInspector.knownTabClasses()];
     133        let allTabClasses = Array.from(WebInspector.knownTabClasses());
    134134        let allowedTabClasses = allTabClasses.filter((tabClass) => tabClass.isTabAllowed() && !tabClass.isEphemeral());
    135135        allowedTabClasses.sort((a, b) => a.tabInfo().title.localeCompare(b.tabInfo().title));
Note: See TracChangeset for help on using the changeset viewer.