Changeset 228024 in webkit


Ignore:
Timestamp:
Feb 2, 2018 1:04:52 PM (6 years ago)
Author:
Matt Baker
Message:

Web Inspector: TabBar redesign: remove New Tab button and add experimental feature flag
https://bugs.webkit.org/show_bug.cgi?id=182342
<rdar://problem/37078662>

Reviewed by Devin Rousso.

This patch adds a new experimental setting group, "User Interface", with
a single setting, "Enable New TabBar". When enabled, the New Tab button is
no longer available in the top-level TabBar. The 'open tabs' context menu
no longer allows the last non-ephemeral open tab to be closed (unchecked).

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Base/Main.js:

(WI.contentLoaded):
(WI._tryToRestorePendingTabs):
Retain legacy behavior behind experimental feature setting.
(WI.isNewTabWithTypeAllowed):

  • UserInterface/Base/Setting.js:
  • UserInterface/Main.html:
  • UserInterface/Views/CanvasTabContentView.js:

(WI.CanvasTabContentView):

  • UserInterface/Views/ConsoleTabContentView.js:

(WI.ConsoleTabContentView):

  • UserInterface/Views/DebuggerTabContentView.js:

(WI.DebuggerTabContentView):

  • UserInterface/Views/ElementsTabContentView.js:

(WI.ElementsTabContentView):

  • UserInterface/Views/GeneralTabBarItem.js:

(WI.GeneralTabBarItem):
(WI.GeneralTabBarItem.prototype.fromTabInfo):
(WI.GeneralTabBarItem.prototype.get isEphemeral):
(WI.GeneralTabBarItem.fromTabContentViewConstructor): Deleted.

  • UserInterface/Views/LayersTabContentView.js:

(WI.LayersTabContentView):

  • UserInterface/Views/LegacyTabBar.js: Copied from Source/WebInspectorUI/UserInterface/Views/TabBar.js.

(WI.LegacyTabBar):
(WI.LegacyTabBar.prototype.get newTabTabBarItem):
(WI.LegacyTabBar.prototype.updateNewTabTabBarItemState):
(WI.LegacyTabBar.prototype.addTabBarItem):
(WI.LegacyTabBar.prototype.insertTabBarItem.animateTabs):
(WI.LegacyTabBar.prototype.insertTabBarItem.removeStyles):
(WI.LegacyTabBar.prototype.insertTabBarItem):
(WI.LegacyTabBar.prototype.removeTabBarItem.animateTabs):
(WI.LegacyTabBar.prototype.removeTabBarItem.removeStyles):
(WI.LegacyTabBar.prototype.removeTabBarItem):
(WI.LegacyTabBar.prototype.selectPreviousTab):
(WI.LegacyTabBar.prototype.selectNextTab):
(WI.LegacyTabBar.prototype.get selectedTabBarItem):
(WI.LegacyTabBar.prototype.set selectedTabBarItem):
(WI.LegacyTabBar.prototype.get tabBarItems):
(WI.LegacyTabBar.prototype.get normalTabCount):
(WI.LegacyTabBar.prototype.layout.forceItemHidden):
(WI.LegacyTabBar.prototype.layout):
(WI.LegacyTabBar.prototype._tabBarItemsFromLeftToRight):
(WI.LegacyTabBar.prototype._findTabBarItem):
(WI.LegacyTabBar.prototype._hasMoreThanOneNormalTab):
(WI.LegacyTabBar.prototype._openDefaultTab):
(WI.LegacyTabBar.prototype._recordTabBarItemSizesAndPositions):
(WI.LegacyTabBar.prototype._applyTabBarItemSizesAndPositions):
(WI.LegacyTabBar.prototype._clearTabBarItemSizesAndPositions):
(WI.LegacyTabBar.prototype._finishExpandingTabsAfterClose.):
(WI.LegacyTabBar.prototype._finishExpandingTabsAfterClose):
(WI.LegacyTabBar.prototype._handleMouseDown):
(WI.LegacyTabBar.prototype._handleClick):
(WI.LegacyTabBar.prototype._handleMouseMoved):
(WI.LegacyTabBar.prototype._handleMouseUp):
(WI.LegacyTabBar.prototype._handleMouseLeave):
(WI.LegacyTabBar.prototype._handleContextMenu):
(WI.LegacyTabBar.prototype._handleNewTabClick):
(WI.LegacyTabBar.prototype._handleTabPickerTabContextMenu):
(WI.LegacyTabBar.prototype._handleNewTabMouseEnter):

  • UserInterface/Views/NetworkTabContentView.js:

(WI.NetworkTabContentView):

  • UserInterface/Views/NewTabContentView.js:

(WI.NewTabContentView):
(WI.NewTabContentView.tabInfo):
(WI.NewTabContentView.isEphemeral): Deleted.

  • UserInterface/Views/ResourcesTabContentView.js:

(WI.ResourcesTabContentView):

  • UserInterface/Views/SearchTabContentView.js:

(WI.SearchTabContentView):
(WI.SearchTabContentView.tabInfo):
(WI.SearchTabContentView.isEphemeral): Deleted.

  • UserInterface/Views/SettingsTabContentView.js:

(WI.SettingsTabContentView.tabInfo):
(WI.SettingsTabContentView.prototype._createExperimentalSettingsView):
(WI.SettingsTabContentView.isEphemeral): Deleted.

  • UserInterface/Views/StorageTabContentView.js:

(WI.StorageTabContentView):

  • UserInterface/Views/TabBar.css:
  • UserInterface/Views/TabBar.js:

(WI.TabBar):
(WI.TabBar.prototype.insertTabBarItem):
(WI.TabBar.prototype.removeTabBarItem):
(WI.TabBar.prototype.set selectedTabBarItem):
(WI.TabBar.prototype.get normalNonEphemeralTabCount):
(WI.TabBar.prototype._handleMouseDown):
(WI.TabBar.prototype._handleClick):
(WI.TabBar.prototype._handleMouseMoved):
(WI.TabBar.prototype._handleMouseLeave):
(WI.TabBar.prototype._handleContextMenu):
(WI.TabBar.prototype._handleTabPickerTabContextMenu):
(WI.TabBar.prototype.get newTabTabBarItem): Deleted.
(WI.TabBar.prototype.updateNewTabTabBarItemState): Deleted.
(WI.TabBar.prototype._openDefaultTab): Deleted.
(WI.TabBar.prototype._handleNewTabClick): Deleted.
(WI.TabBar.prototype._handleNewTabMouseEnter): Deleted.
Remove support for the New Tab button and default tab. Without a default
tab, there is nothing to display when no tabs are open, so prevent the
last non-pinned tab from being removed.

  • UserInterface/Views/TabBrowser.js:

(WI.TabBrowser._tabBarItemRemoved):

  • UserInterface/Views/TabContentView.js:

(WI.TabContentView.isEphemeral): Deleted.

  • UserInterface/Views/TimelineTabContentView.js:

(WI.TimelineTabContentView):

Location:
trunk/Source/WebInspectorUI
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r227864 r228024  
     12018-02-02  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: TabBar redesign: remove New Tab button and add experimental feature flag
     4        https://bugs.webkit.org/show_bug.cgi?id=182342
     5        <rdar://problem/37078662>
     6
     7        Reviewed by Devin Rousso.
     8
     9        This patch adds a new experimental setting group, "User Interface", with
     10        a single setting, "Enable New TabBar". When enabled, the New Tab button is
     11        no longer available in the top-level TabBar. The 'open tabs' context menu
     12        no longer allows the last non-ephemeral open tab to be closed (unchecked).
     13
     14        * Localizations/en.lproj/localizedStrings.js:
     15
     16        * UserInterface/Base/Main.js:
     17        (WI.contentLoaded):
     18        (WI._tryToRestorePendingTabs):
     19        Retain legacy behavior behind experimental feature setting.
     20        (WI.isNewTabWithTypeAllowed):
     21
     22        * UserInterface/Base/Setting.js:
     23        * UserInterface/Main.html:
     24
     25        * UserInterface/Views/CanvasTabContentView.js:
     26        (WI.CanvasTabContentView):
     27        * UserInterface/Views/ConsoleTabContentView.js:
     28        (WI.ConsoleTabContentView):
     29        * UserInterface/Views/DebuggerTabContentView.js:
     30        (WI.DebuggerTabContentView):
     31        * UserInterface/Views/ElementsTabContentView.js:
     32        (WI.ElementsTabContentView):
     33
     34        * UserInterface/Views/GeneralTabBarItem.js:
     35        (WI.GeneralTabBarItem):
     36        (WI.GeneralTabBarItem.prototype.fromTabInfo):
     37        (WI.GeneralTabBarItem.prototype.get isEphemeral):
     38        (WI.GeneralTabBarItem.fromTabContentViewConstructor): Deleted.
     39
     40        * UserInterface/Views/LayersTabContentView.js:
     41        (WI.LayersTabContentView):
     42
     43        * UserInterface/Views/LegacyTabBar.js: Copied from Source/WebInspectorUI/UserInterface/Views/TabBar.js.
     44        (WI.LegacyTabBar):
     45        (WI.LegacyTabBar.prototype.get newTabTabBarItem):
     46        (WI.LegacyTabBar.prototype.updateNewTabTabBarItemState):
     47        (WI.LegacyTabBar.prototype.addTabBarItem):
     48        (WI.LegacyTabBar.prototype.insertTabBarItem.animateTabs):
     49        (WI.LegacyTabBar.prototype.insertTabBarItem.removeStyles):
     50        (WI.LegacyTabBar.prototype.insertTabBarItem):
     51        (WI.LegacyTabBar.prototype.removeTabBarItem.animateTabs):
     52        (WI.LegacyTabBar.prototype.removeTabBarItem.removeStyles):
     53        (WI.LegacyTabBar.prototype.removeTabBarItem):
     54        (WI.LegacyTabBar.prototype.selectPreviousTab):
     55        (WI.LegacyTabBar.prototype.selectNextTab):
     56        (WI.LegacyTabBar.prototype.get selectedTabBarItem):
     57        (WI.LegacyTabBar.prototype.set selectedTabBarItem):
     58        (WI.LegacyTabBar.prototype.get tabBarItems):
     59        (WI.LegacyTabBar.prototype.get normalTabCount):
     60        (WI.LegacyTabBar.prototype.layout.forceItemHidden):
     61        (WI.LegacyTabBar.prototype.layout):
     62        (WI.LegacyTabBar.prototype._tabBarItemsFromLeftToRight):
     63        (WI.LegacyTabBar.prototype._findTabBarItem):
     64        (WI.LegacyTabBar.prototype._hasMoreThanOneNormalTab):
     65        (WI.LegacyTabBar.prototype._openDefaultTab):
     66        (WI.LegacyTabBar.prototype._recordTabBarItemSizesAndPositions):
     67        (WI.LegacyTabBar.prototype._applyTabBarItemSizesAndPositions):
     68        (WI.LegacyTabBar.prototype._clearTabBarItemSizesAndPositions):
     69        (WI.LegacyTabBar.prototype._finishExpandingTabsAfterClose.):
     70        (WI.LegacyTabBar.prototype._finishExpandingTabsAfterClose):
     71        (WI.LegacyTabBar.prototype._handleMouseDown):
     72        (WI.LegacyTabBar.prototype._handleClick):
     73        (WI.LegacyTabBar.prototype._handleMouseMoved):
     74        (WI.LegacyTabBar.prototype._handleMouseUp):
     75        (WI.LegacyTabBar.prototype._handleMouseLeave):
     76        (WI.LegacyTabBar.prototype._handleContextMenu):
     77        (WI.LegacyTabBar.prototype._handleNewTabClick):
     78        (WI.LegacyTabBar.prototype._handleTabPickerTabContextMenu):
     79        (WI.LegacyTabBar.prototype._handleNewTabMouseEnter):
     80
     81        * UserInterface/Views/NetworkTabContentView.js:
     82        (WI.NetworkTabContentView):
     83        * UserInterface/Views/NewTabContentView.js:
     84        (WI.NewTabContentView):
     85        (WI.NewTabContentView.tabInfo):
     86        (WI.NewTabContentView.isEphemeral): Deleted.
     87        * UserInterface/Views/ResourcesTabContentView.js:
     88        (WI.ResourcesTabContentView):
     89        * UserInterface/Views/SearchTabContentView.js:
     90        (WI.SearchTabContentView):
     91        (WI.SearchTabContentView.tabInfo):
     92        (WI.SearchTabContentView.isEphemeral): Deleted.
     93
     94        * UserInterface/Views/SettingsTabContentView.js:
     95        (WI.SettingsTabContentView.tabInfo):
     96        (WI.SettingsTabContentView.prototype._createExperimentalSettingsView):
     97        (WI.SettingsTabContentView.isEphemeral): Deleted.
     98
     99        * UserInterface/Views/StorageTabContentView.js:
     100        (WI.StorageTabContentView):
     101
     102        * UserInterface/Views/TabBar.css:
     103        * UserInterface/Views/TabBar.js:
     104        (WI.TabBar):
     105        (WI.TabBar.prototype.insertTabBarItem):
     106        (WI.TabBar.prototype.removeTabBarItem):
     107        (WI.TabBar.prototype.set selectedTabBarItem):
     108        (WI.TabBar.prototype.get normalNonEphemeralTabCount):
     109        (WI.TabBar.prototype._handleMouseDown):
     110        (WI.TabBar.prototype._handleClick):
     111        (WI.TabBar.prototype._handleMouseMoved):
     112        (WI.TabBar.prototype._handleMouseLeave):
     113        (WI.TabBar.prototype._handleContextMenu):
     114        (WI.TabBar.prototype._handleTabPickerTabContextMenu):
     115        (WI.TabBar.prototype.get newTabTabBarItem): Deleted.
     116        (WI.TabBar.prototype.updateNewTabTabBarItemState): Deleted.
     117        (WI.TabBar.prototype._openDefaultTab): Deleted.
     118        (WI.TabBar.prototype._handleNewTabClick): Deleted.
     119        (WI.TabBar.prototype._handleNewTabMouseEnter): Deleted.
     120        Remove support for the New Tab button and default tab. Without a default
     121        tab, there is nothing to display when no tabs are open, so prevent the
     122        last non-pinned tab from being removed.
     123
     124        * UserInterface/Views/TabBrowser.js:
     125        (WI.TabBrowser._tabBarItemRemoved):
     126        * UserInterface/Views/TabContentView.js:
     127        (WI.TabContentView.isEphemeral): Deleted.
     128        * UserInterface/Views/TimelineTabContentView.js:
     129        (WI.TimelineTabContentView):
     130
    11312018-01-30  Devin Rousso  <webkit@devinrousso.com>
    2132
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r227703 r228024  
    368368localizedStrings["Enable Event Listener"] = "Enable Event Listener";
    369369localizedStrings["Enable Layers Tab"] = "Enable Layers Tab";
     370localizedStrings["Enable New Tab Bar"] = "Enable New Tab Bar";
    370371localizedStrings["Enable Program"] = "Enable Program";
    371372localizedStrings["Enable all breakpoints (%s)"] = "Enable all breakpoints (%s)";
     
    10091010localizedStrings["User Agent"] = "User Agent";
    10101011localizedStrings["User Agent Stylesheet"] = "User Agent Stylesheet";
     1012localizedStrings["User Interface:"] = "User Interface:";
    10111013localizedStrings["User Stylesheet"] = "User Stylesheet";
    10121014localizedStrings["Using Keyword Value"] = "Using Keyword Value";
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r227864 r228024  
    271271    this.toolbar = new WI.Toolbar(document.getElementById("toolbar"));
    272272
    273     this.tabBar = new WI.TabBar(document.getElementById("tab-bar"));
    274     this.tabBar.addEventListener(WI.TabBar.Event.OpenDefaultTab, this._openDefaultTab, this);
     273    if (WI.settings.experimentalEnableNewTabBar.value)
     274        this.tabBar = new WI.TabBar(document.getElementById("tab-bar"));
     275    else {
     276        this.tabBar = new WI.LegacyTabBar(document.getElementById("tab-bar"));
     277        this.tabBar.addEventListener(WI.TabBar.Event.OpenDefaultTab, this._openDefaultTab, this);
     278    }
    275279
    276280    this._contentElement = document.getElementById("content");
     
    602606    this._pendingOpenTabs = stillPendingOpenTabs;
    603607
    604     this.tabBrowser.tabBar.updateNewTabTabBarItemState();
     608    if (!WI.settings.experimentalEnableNewTabBar.value)
     609        this.tabBrowser.tabBar.updateNewTabTabBarItemState();
    605610};
    606611
     
    633638    if (tabClass === WI.NewTabContentView) {
    634639        let allTabs = Array.from(this.knownTabClasses());
    635         let addableTabs = allTabs.filter((tabClass) => !tabClass.isEphemeral());
     640        let addableTabs = allTabs.filter((tabClass) => !tabClass.tabInfo().isEphemeral);
    636641        let canMakeNewTab = addableTabs.some((tabClass) => WI.isNewTabWithTypeAllowed(tabClass.Type));
    637642        return canMakeNewTab;
  • trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js

    r225547 r228024  
    127127    experimentalLegacyStyleEditor: new WI.Setting("experimental-legacy-style-editor", false),
    128128    experimentalLegacyVisualSidebar: new WI.Setting("experimental-legacy-visual-sidebar", false),
     129    experimentalEnableNewTabBar: new WI.Setting("experimental-enable-new-tab-bar", false),
    129130};
  • trunk/Source/WebInspectorUI/UserInterface/Main.html

    r227244 r228024  
    480480    <script src="Views/TreeOutlineGroup.js"></script>
    481481
     482    <script src="Views/LegacyTabBar.js"></script>
     483
    482484    <script src="Views/ButtonNavigationItem.js"></script>
    483485    <script src="Views/DatabaseUserQueryViewBase.js"></script>
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasTabContentView.js

    r227703 r228024  
    3030        console.assert(!representedObject || representedObject instanceof WI.Canvas);
    3131
    32         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.CanvasTabContentView);
     32        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.CanvasTabContentView.tabInfo());
    3333
    3434        const navigationSidebarPanelConstructor = WI.RecordingNavigationSidebarPanel;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.ConsoleTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.ConsoleTabContentView.tabInfo());
    3131
    3232        super(identifier || "console", "console", tabBarItem, null, null, true);
  • trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.DebuggerTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.DebuggerTabContentView.tabInfo());
    3131        let detailsSidebarPanelConstructors = [WI.ScopeChainDetailsSidebarPanel, WI.ResourceDetailsSidebarPanel, WI.ProbeDetailsSidebarPanel];
    3232
  • trunk/Source/WebInspectorUI/UserInterface/Views/ElementsTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.ElementsTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.ElementsTabContentView.tabInfo());
    3131        let detailsSidebarPanelConstructors = [WI.RulesStyleDetailsSidebarPanel, WI.ComputedStyleDetailsSidebarPanel, WI.DOMNodeDetailsSidebarPanel];
    3232
  • trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js

    r227703 r228024  
    2727WI.GeneralTabBarItem = class GeneralTabBarItem extends WI.TabBarItem
    2828{
    29     constructor(image, title, isEphemeral)
     29    constructor(image, title, isEphemeral = false)
    3030    {
    3131        super(image, title);
    3232
    33         if (isEphemeral) {
     33        this._isEphemeral = isEphemeral;
     34
     35        if (this._isEphemeral) {
    3436            this.element.classList.add("ephemeral");
    3537
     
    4345    }
    4446
    45     static fromTabContentViewConstructor(constructor)
     47    static fromTabInfo({image, title, isEphemeral})
    4648    {
    47         let {image, title} = constructor.tabInfo();
    48         let isEphemeral = constructor.isEphemeral();
    4949        return new WI.GeneralTabBarItem(image, title, isEphemeral);
    5050    }
    5151
    5252    // Public
     53
     54    get isEphemeral() { return this._isEphemeral; }
    5355
    5456    get title()
  • trunk/Source/WebInspectorUI/UserInterface/Views/LayersTabContentView.js

    r227703 r228024  
    2828    constructor()
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.LayersTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.LayersTabContentView.tabInfo());
    3131
    3232        const navigationSidebarPanelConstructor = null;
  • trunk/Source/WebInspectorUI/UserInterface/Views/LegacyTabBar.js

    r228023 r228024  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WI.TabBar = class TabBar extends WI.View
     26WI.LegacyTabBar = class LegacyTabBar extends WI.View
    2727{
    2828    constructor(element, tabBarItems)
     
    805805
    806806        for (let tabClass of WI.knownTabClasses()) {
    807             if (tabClass.isEphemeral())
     807            if (tabClass.tabInfo().isEphemeral)
    808808                continue;
    809809
     
    855855    }
    856856};
    857 
    858 WI.TabBar.CachedWidthSymbol = Symbol("cached-width");
    859 
    860 WI.TabBar.Event = {
    861     TabBarItemSelected: "tab-bar-tab-bar-item-selected",
    862     TabBarItemAdded: "tab-bar-tab-bar-item-added",
    863     TabBarItemRemoved: "tab-bar-tab-bar-item-removed",
    864     TabBarItemsReordered: "tab-bar-tab-bar-items-reordered",
    865     OpenDefaultTab: "tab-bar-open-default-tab"
    866 };
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.NetworkTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.NetworkTabContentView.tabInfo());
    3131
    3232        super(identifier || "network", "network", tabBarItem);
  • trunk/Source/WebInspectorUI/UserInterface/Views/NewTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.NewTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.NewTabContentView.tabInfo());
    3131        tabBarItem.isDefaultTab = true;
    3232
     
    3636
    3737        let allTabClasses = Array.from(WI.knownTabClasses());
    38         this._shownTabClasses = allTabClasses.filter((tabClass) => tabClass.isTabAllowed() && !tabClass.isEphemeral());
     38        this._shownTabClasses = allTabClasses.filter((tabClass) => tabClass.isTabAllowed() && !tabClass.tabInfo().isEphemeral);
    3939        this._shownTabClasses.sort((a, b) => a.tabInfo().title.extendedLocaleCompare(b.tabInfo().title));
    4040    }
     
    4545            image: "Images/NewTab.svg",
    4646            title: WI.UIString("New Tab"),
     47            isEphemeral: true,
    4748        };
    48     }
    49 
    50     static isEphemeral()
    51     {
    52         return true;
    5349    }
    5450
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourcesTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.ResourcesTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.ResourcesTabContentView.tabInfo());
    3131        const detailsSidebarPanelConstructors = [WI.ResourceDetailsSidebarPanel, WI.ProbeDetailsSidebarPanel];
    3232        super(identifier || "resources", "resources", tabBarItem, WI.ResourceSidebarPanel, detailsSidebarPanelConstructors);
  • trunk/Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.SearchTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.SearchTabContentView.tabInfo());
    3131        let detailsSidebarPanelConstructors = [WI.ResourceDetailsSidebarPanel, WI.ProbeDetailsSidebarPanel,
    3232            WI.DOMNodeDetailsSidebarPanel, WI.ComputedStyleDetailsSidebarPanel, WI.RulesStyleDetailsSidebarPanel];
     
    4545            image: "Images/SearchResults.svg",
    4646            title: WI.UIString("Search"),
     47            isEphemeral: true,
    4748        };
    48     }
    49 
    50     static isEphemeral()
    51     {
    52         return true;
    5349    }
    5450
  • trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js

    r225663 r228024  
    4545            image: "Images/Gear.svg",
    4646            title: WI.UIString("Settings"),
     47            isEphemeral: true,
    4748        };
    48     }
    49 
    50     static isEphemeral()
    51     {
    52         return true;
    5349    }
    5450
     
    255251        }
    256252
     253        experimentalSettingsView.addSetting(WI.UIString("User Interface:"), WI.settings.experimentalEnableNewTabBar, WI.UIString("Enable New Tab Bar"));
     254        experimentalSettingsView.addSeparator();
     255
    257256        let reloadInspectorButton = document.createElement("button");
    258257        reloadInspectorButton.textContent = WI.UIString("Reload Web Inspector");
     
    272271        listenForChange(WI.settings.experimentalLegacyVisualSidebar);
    273272        listenForChange(WI.settings.experimentalEnableLayersTab);
     273        listenForChange(WI.settings.experimentalEnableNewTabBar);
    274274
    275275        this.addSettingsView(experimentalSettingsView);
  • trunk/Source/WebInspectorUI/UserInterface/Views/StorageTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.StorageTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.StorageTabContentView.tabInfo());
    3131        let detailsSidebarPanelConstructors = [WI.ApplicationCacheDetailsSidebarPanel, WI.IndexedDatabaseDetailsSidebarPanel];
    3232
  • trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.css

    r227703 r228024  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
  • trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js

    r227703 r228024  
    4949        this.addTabBarItem(WI.settingsTabContentView.tabBarItem, {suppressAnimations: true});
    5050
    51         this._newTabTabBarItem = new WI.PinnedTabBarItem("Images/NewTabPlus.svg", WI.UIString("Create a new tab"));
    52         this._newTabTabBarItem.element.addEventListener("mouseenter", this._handleNewTabMouseEnter.bind(this));
    53         this._newTabTabBarItem.element.addEventListener("click", this._handleNewTabClick.bind(this));
    54         this.addTabBarItem(this._newTabTabBarItem, {suppressAnimations: true});
    55 
    5651        this._tabPickerTabBarItem = new WI.PinnedTabBarItem("Images/TabPicker.svg", WI.UIString("Show hidden tabs"));
    5752        this._tabPickerTabBarItem.element.classList.add("tab-picker");
     
    6156
    6257    // Public
    63 
    64     get newTabTabBarItem() { return this._newTabTabBarItem; }
    65 
    66     updateNewTabTabBarItemState()
    67     {
    68         let newTabExists = !WI.isNewTabWithTypeAllowed(WI.NewTabContentView.Type);
    69         this._newTabTabBarItem.disabled = newTabExists;
    70     }
    7158
    7259    addTabBarItem(tabBarItem, options = {})
     
    171158            this.needsLayout();
    172159
    173         if (!(tabBarItem instanceof WI.PinnedTabBarItem))
    174             this.updateNewTabTabBarItemState();
    175 
    176160        this.dispatchEventToListeners(WI.TabBar.Event.TabBarItemAdded, {tabBarItem});
    177161
     
    183167        let tabBarItem = this._findTabBarItem(tabBarItemOrIndex);
    184168        if (!tabBarItem || tabBarItem instanceof WI.PinnedTabBarItem)
     169            return null;
     170
     171        if (!tabBarItem.isEphemeral && this.normalNonEphemeralTabCount === 1)
    185172            return null;
    186173
     
    213200        var hasMoreThanOneNormalTab = this._hasMoreThanOneNormalTab();
    214201        this.element.classList.toggle("single-tab", !hasMoreThanOneNormalTab);
    215 
    216         const shouldOpenDefaultTab = !tabBarItem.isDefaultTab && !this.normalTabCount;
    217         if (shouldOpenDefaultTab)
    218             options.suppressAnimations = true;
    219202
    220203        if (!hasMoreThanOneNormalTab || wasLastNormalTab || !options.suppressExpansion) {
     
    225208                this.needsLayout();
    226209
    227             this.updateNewTabTabBarItemState();
    228 
    229210            this.dispatchEventToListeners(WI.TabBar.Event.TabBarItemRemoved, {tabBarItem});
    230 
    231             if (shouldOpenDefaultTab)
    232                 this._openDefaultTab();
    233 
    234211            return tabBarItem;
    235212        }
     
    301278            this.needsLayout();
    302279
    303         this.updateNewTabTabBarItemState();
    304 
    305280        this.dispatchEventToListeners(WI.TabBar.Event.TabBarItemRemoved, {tabBarItem});
    306 
    307         if (shouldOpenDefaultTab)
    308             this._openDefaultTab();
    309281
    310282        return tabBarItem;
     
    365337    {
    366338        let tabBarItem = this._findTabBarItem(tabBarItemOrIndex);
    367         if (tabBarItem === this._newTabTabBarItem) {
    368             // Get the item before the New-Tab item since it is not selectable.
    369             tabBarItem = this._tabBarItems[this.normalTabCount - 1];
    370         }
    371 
    372339        if (this._selectedTabBarItem === tabBarItem)
    373340            return;
     
    395362    {
    396363        return this._tabBarItems.filter((item) => !(item instanceof WI.PinnedTabBarItem)).length;
     364    }
     365
     366    get normalNonEphemeralTabCount()
     367    {
     368        return this._tabBarItems.filter((item) => !item.isEphemeral && !(item instanceof WI.PinnedTabBarItem)).length;
    397369    }
    398370
     
    492464    }
    493465
    494     _openDefaultTab()
    495     {
    496         this.dispatchEventToListeners(WI.TabBar.Event.OpenDefaultTab);
    497     }
    498 
    499466    _recordTabBarItemSizesAndPositions()
    500467    {
     
    597564            return;
    598565
    599         if (tabBarItem === this._newTabTabBarItem)
    600             return;
    601 
    602566        if (tabBarItem === this._tabPickerTabBarItem) {
    603567            if (!this._hiddenTabBarItems.length)
     
    660624        var closeButtonElement = event.target.enclosingNodeOrSelfWithClass(WI.TabBarItem.CloseButtonStyleClassName);
    661625        if (closeButtonElement || clickedMiddleButton) {
    662             // Disallow closing the default tab if it is the only tab.
    663             if (tabBarItem.isDefaultTab && this.element.classList.contains("single-tab"))
     626            // Disallow closing the only tab.
     627            if (this.element.classList.contains("single-tab"))
    664628                return;
    665629
     
    734698
    735699        let nextSibling = this._tabBarItems[newIndex + 1];
    736         let nextSiblingElement = nextSibling ? nextSibling.element : this._newTabTabBarItem.element;
     700        let nextSiblingElement = nextSibling ? nextSibling.element : null;
    737701
    738702        this.element.insertBefore(this._selectedTabBarItem.element, nextSiblingElement);
     
    742706        let left = 0;
    743707        for (let tabBarItem of this._tabBarItemsFromLeftToRight()) {
    744             if (tabBarItem !== this._selectedTabBarItem && tabBarItem !== this._newTabTabBarItem && parseFloat(tabBarItem.element.style.left) !== left)
     708            if (tabBarItem !== this._selectedTabBarItem && parseFloat(tabBarItem.element.style.left) !== left)
    745709                tabBarItem.element.style.left = left + "px";
    746710            left += parseFloat(tabBarItem.element.style.width);
     
    793757        // FIXME: Is this a WebKit bug or correct behavior?
    794758        const barRect = this.element.getBoundingClientRect();
    795         const newTabItemRect = this._newTabTabBarItem.element.getBoundingClientRect();
    796         if (event.pageY > barRect.top && event.pageY < barRect.bottom && event.pageX > barRect.left && event.pageX < (newTabItemRect ? newTabItemRect.right : barRect.right))
     759        if (event.pageY > barRect.top && event.pageY < barRect.bottom && event.pageX > barRect.left && event.pageX < barRect.right)
    797760            return;
    798761
     
    805768
    806769        for (let tabClass of WI.knownTabClasses()) {
    807             if (tabClass.isEphemeral())
     770            if (tabClass.tabInfo().isEphemeral)
    808771                continue;
    809772
     
    820783            }
    821784
     785            let checked = !!openTabBarItem;
     786            let disabled = checked && this.normalNonEphemeralTabCount === 1;
    822787            contextMenu.appendCheckboxItem(tabClass.tabInfo().title, () => {
    823788                if (openTabBarItem)
     
    825790                else
    826791                    WI.createNewTabWithType(tabClass.Type, {shouldShowNewTab: true});
    827             }, !!openTabBarItem);
    828         }
    829     }
    830 
    831     _handleNewTabClick(event)
    832     {
    833         WI.showNewTabTab();
     792            }, checked, disabled);
     793        }
    834794    }
    835795
     
    845805            });
    846806        }
    847     }
    848 
    849     _handleNewTabMouseEnter(event)
    850     {
    851         if (!this._tabAnimatedClosedSinceMouseEnter || !this.element.classList.contains("static-layout") || this.element.classList.contains("animating"))
    852             return;
    853 
    854         this._finishExpandingTabsAfterClose();
    855807    }
    856808};
  • trunk/Source/WebInspectorUI/UserInterface/Views/TabBrowser.js

    r226963 r228024  
    284284        this._recentTabContentViews.remove(tabContentView);
    285285
    286         if (!tabContentView.constructor.isEphemeral())
     286        if (!tabContentView.constructor.tabInfo().isEphemeral)
    287287            this._closedTabClasses.add(tabContentView.constructor);
    288288
  • trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js

    r224981 r228024  
    6464        // Returns false if a necessary domain or other features are unavailable.
    6565        return true;
    66     }
    67 
    68     static isEphemeral()
    69     {
    70         // Returns true if the tab should not be shown in the new tab content view.
    71         return false;
    7266    }
    7367
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js

    r227703 r228024  
    2828    constructor(identifier)
    2929    {
    30         let tabBarItem = WI.GeneralTabBarItem.fromTabContentViewConstructor(WI.TimelineTabContentView);
     30        let tabBarItem = WI.GeneralTabBarItem.fromTabInfo(WI.TimelineTabContentView.tabInfo());
    3131        let detailsSidebarPanelConstructors = [WI.ResourceDetailsSidebarPanel, WI.ProbeDetailsSidebarPanel];
    3232
Note: See TracChangeset for help on using the changeset viewer.