B2G/gecko/browser/components/tabview/ui.js
// Called when the user switches from one tab to another outside of the TabView UI.
Called when the user switches from one tab to another outside of the TabView UI.
Called when the user switches from one tab to another outside of the TabView UI .
function UI_onTabSelect(tab) {
    this._currentTab = tab;
    if (this.isTabViewVisible()) {
      if (!this.restoredClosedTab && !this._privateBrowsing.transitionMode &&
          this._lastOpenedTab == tab && tab._tabViewTabItem) {
        tab._tabViewTabItem.zoomIn(true);
        this._lastOpenedTab = null;
        return;
      }
      if (this._closedLastVisibleTab ||
          (this._closedSelectedTabInTabView && !this.closedLastTabInTabView) ||
          this.restoredClosedTab) {
        if (this.restoredClosedTab) {
          tab.linkedBrowser.addEventListener("load", function onLoad(event) {
            tab.linkedBrowser.removeEventListener("load", onLoad, true);
            TabItems._update(tab);
          }, true);
        }
        this._closedLastVisibleTab = false;
        this._closedSelectedTabInTabView = false;
        this.closedLastTabInTabView = false;
        this.restoredClosedTab = false;
        return;
      }
    }
    this._closedLastVisibleTab = false;
    this._closedSelectedTabInTabView = false;
    this.closedLastTabInTabView = false;
    this.restoredClosedTab = false;
    this._lastOpenedTab = null;
    if (this.isTabViewVisible()) {
      if (tab && tab._tabViewTabItem && tab._tabViewTabItem.parent &&
          tab._tabViewTabItem.parent.hidden)
        tab._tabViewTabItem.parent._unhide({immediately: true});
      this.hideTabView();
    }
    if (this._currentTab != tab)
      return;
    let newItem = null;
    if (tab && tab._tabViewTabItem) {
      if (!TabItems.reconnectingPaused()) {
        newItem = tab._tabViewTabItem;
        GroupItems.updateActiveGroupItemAndTabBar(newItem);
      }
    } else {
      if (!GroupItems.getActiveGroupItem()) {
        for (let a = 0; a < gBrowser.tabs.length; a++) {
          let theTab = gBrowser.tabs[a];
          if (!theTab.pinned) {
            let tabItem = theTab._tabViewTabItem;
            this.setActive(tabItem.parent);
            break;
          }
        }
      }
      if (GroupItems.getActiveGroupItem())
        GroupItems._updateTabBar();
    }
  }
function UI_onTabSelect ( tab ) { this . _currentTab = tab ; if ( this . isTabViewVisible ( ) ) { if ( ! this . restoredClosedTab && ! this . _privateBrowsing . transitionMode && this . _lastOpenedTab == tab && tab . _tabViewTabItem ) { tab . _tabViewTabItem . zoomIn ( true ) ; this . _lastOpenedTab = null ; return ; } if ( this . _closedLastVisibleTab || ( this . _closedSelectedTabInTabView && ! this . closedLastTabInTabView ) || this . restoredClosedTab ) { if ( this . restoredClosedTab ) { tab . linkedBrowser . addEventListener ( "load" , function onLoad ( event ) { tab . linkedBrowser . removeEventListener ( "load" , onLoad , true ) ; TabItems . _update ( tab ) ; } , true ) ; } this . _closedLastVisibleTab = false ; this . _closedSelectedTabInTabView = false ; this . closedLastTabInTabView = false ; this . restoredClosedTab = false ; return ; } } this . _closedLastVisibleTab = false ; this . _closedSelectedTabInTabView = false ; this . closedLastTabInTabView = false ; this . restoredClosedTab = false ; this . _lastOpenedTab = null ; if ( this . isTabViewVisible ( ) ) { if ( tab && tab . _tabViewTabItem && tab . _tabViewTabItem . parent && tab . _tabViewTabItem . parent . hidden ) tab . _tabViewTabItem . parent . _unhide ( { immediately : true } ) ; this . hideTabView ( ) ; } if ( this . _currentTab != tab ) return ; let newItem = null ; if ( tab && tab . _tabViewTabItem ) { if ( ! TabItems . reconnectingPaused ( ) ) { newItem = tab . _tabViewTabItem ; GroupItems . updateActiveGroupItemAndTabBar ( newItem ) ; } } else { if ( ! GroupItems . getActiveGroupItem ( ) ) { for ( let a = 0 ; a < gBrowser . tabs . length ; a ++ ) { let theTab = gBrowser . tabs [ a ] ; if ( ! theTab . pinned ) { let tabItem = theTab . _tabViewTabItem ; this . setActive ( tabItem . parent ) ; break ; } } } if ( GroupItems . getActiveGroupItem ( ) ) GroupItems . _updateTabBar ( ) ; } }
Called when the user switches from one tab to another outside of the TabView UI.
Called when the user switches from one tab to another outside of the TabView UI .
// We want to zoom in if: // 1) we didn't just restore a tab via Ctrl+Shift+T // 2) we're not in the middle of switching from/to private browsing // 3) the currently selected tab is the last created tab and has a tabItem // when the tab view UI is being displayed, update the thumb for the  // restored closed tab after the page load // reset these vars, just in case. // if TabView is visible but we didn't just close the last tab or // selected tab, show chrome. // Unhide the group of the tab the user is activating. // another tab might be selected when hideTabView() is invoked so a // validation is needed. // update the tab bar for the new tab's group // No tabItem; must be an app tab. Base the tab bar on the current group. // If no current group, figure it out based on what's already in the tab // bar.