B2G/gecko/browser/components/tabview/groupitems.js
// Given a <TabItem>, files it in the appropriate groupItem.
Given a , files it in the appropriate groupItem.
Given a files it in the appropriate groupItem .
function GroupItems_newTab(tabItem, options) {
    let activeGroupItem = this.getActiveGroupItem();
    if (activeGroupItem && !activeGroupItem.hidden) {
      activeGroupItem.add(tabItem, options);
      return;
    }
    let targetGroupItem;
    gBrowser.visibleTabs.some(function(tab) {
      if (!tab.pinned && tab != tabItem.tab) {
        if (tab._tabViewTabItem && tab._tabViewTabItem.parent &&
            !tab._tabViewTabItem.parent.hidden) {
          targetGroupItem = tab._tabViewTabItem.parent;
        }
        return true;
      }
      return false;
    });
    let visibleGroupItems;
    if (targetGroupItem) {
      targetGroupItem.add(tabItem);
      UI.setActive(targetGroupItem);
      return;
    } else {
      visibleGroupItems = this.groupItems.filter(function(groupItem) {
        return (!groupItem.hidden);
      });
      if (visibleGroupItems.length > 0) {
        visibleGroupItems[0].add(tabItem);
        UI.setActive(visibleGroupItems[0]);
        return;
      }
    }
    tabItem.setPosition(60, 60, true);
    let newGroupItemBounds = tabItem.getBounds();
    newGroupItemBounds.inset(-40,-40);
    let newGroupItem = new GroupItem([tabItem], { bounds: newGroupItemBounds });
    newGroupItem.snap();
    UI.setActive(newGroupItem);
  }
function GroupItems_newTab ( tabItem , options ) { let activeGroupItem = this . getActiveGroupItem ( ) ; if ( activeGroupItem && ! activeGroupItem . hidden ) { activeGroupItem . add ( tabItem , options ) ; return ; } let targetGroupItem ; gBrowser . visibleTabs . some ( function ( tab ) { if ( ! tab . pinned && tab != tabItem . tab ) { if ( tab . _tabViewTabItem && tab . _tabViewTabItem . parent && ! tab . _tabViewTabItem . parent . hidden ) { targetGroupItem = tab . _tabViewTabItem . parent ; } return true ; } return false ; } ) ; let visibleGroupItems ; if ( targetGroupItem ) { targetGroupItem . add ( tabItem ) ; UI . setActive ( targetGroupItem ) ; return ; } else { visibleGroupItems = this . groupItems . filter ( function ( groupItem ) { return ( ! groupItem . hidden ) ; } ) ; if ( visibleGroupItems . length > 0 ) { visibleGroupItems [ 0 ] . add ( tabItem ) ; UI . setActive ( visibleGroupItems [ 0 ] ) ; return ; } } tabItem . setPosition ( 60 , 60 , true ) ; let newGroupItemBounds = tabItem . getBounds ( ) ; newGroupItemBounds . inset ( - 40 , - 40 ) ; let newGroupItem = new GroupItem ( [ tabItem ] , { bounds : newGroupItemBounds } ) ; newGroupItem . snap ( ) ; UI . setActive ( newGroupItem ) ; }
Given a <TabItem>, files it in the appropriate groupItem.
Given a <TabItem > files it in the appropriate groupItem .
// 1. Active group // 2. First visible non-app tab (that's not the tab in question) // 3. First group // 4. At this point there should be no groups or tabs (except for app tabs and the // tab in question): make a new group // find first non-app visible tab belongs a group, and add the new tabItem // to that group // add the new tabItem to the first group item // find the first visible group item // create new group for the new tabItem