B2G/gecko/browser/components/tabview/groupitems.js
// Restores to stored state, creating groupItems as needed.
Restores to stored state, creating groupItems as needed.
Restores to stored state creating groupItems as needed .
function GroupItems_reconstitute(groupItemsData, groupItemData) {
    try {
      let activeGroupId;
      if (groupItemsData) {
        if (groupItemsData.nextID)
          this.nextID = Math.max(this.nextID, groupItemsData.nextID);
        if (groupItemsData.activeGroupId)
          activeGroupId = groupItemsData.activeGroupId;
      }
      if (groupItemData) {
        var toClose = this.groupItems.concat();
        for (var id in groupItemData) {
          let data = groupItemData[id];
          if (this.groupItemStorageSanity(data)) {
            let groupItem = this.groupItem(data.id); 
            if (groupItem && !groupItem.hidden) {
              groupItem.userSize = data.userSize;
              groupItem.setTitle(data.title);
              groupItem.setBounds(data.bounds, true);
              let index = toClose.indexOf(groupItem);
              if (index != -1)
                toClose.splice(index, 1);
            } else {
              var options = {
                dontPush: true,
                immediately: true
              };
              new GroupItem([], Utils.extend({}, data, options));
            }
          }
        }
        toClose.forEach(function(groupItem) {
          groupItem.getChildren().forEach(function (tabItem) {
            if (tabItem.parent.hidden)
              iQ(tabItem.container).show();
            tabItem._reconnected = false;
            let tabData = Storage.getTabData(tabItem.tab);
            if (tabData) {
              let parentGroup = GroupItems.groupItem(tabData.groupID);
              if (!parentGroup || -1 < toClose.indexOf(parentGroup)) {
                tabData.groupID = activeGroupId || Object.keys(groupItemData)[0];
                Storage.saveTab(tabItem.tab, tabData);
              }
            }
          });
          groupItem.close({immediately: true});
        });
      }
      if (activeGroupId) {
        let activeGroupItem = this.groupItem(activeGroupId);
        if (activeGroupItem)
          UI.setActive(activeGroupItem);
      }
      this._inited = true;
      this._save(); 
    } catch(e) {
      Utils.log("error in recons: "+e);
    }
  }
function GroupItems_reconstitute ( groupItemsData , groupItemData ) { try { let activeGroupId ; if ( groupItemsData ) { if ( groupItemsData . nextID ) this . nextID = Math . max ( this . nextID , groupItemsData . nextID ) ; if ( groupItemsData . activeGroupId ) activeGroupId = groupItemsData . activeGroupId ; } if ( groupItemData ) { var toClose = this . groupItems . concat ( ) ; for ( var id in groupItemData ) { let data = groupItemData [ id ] ; if ( this . groupItemStorageSanity ( data ) ) { let groupItem = this . groupItem ( data . id ) ; if ( groupItem && ! groupItem . hidden ) { groupItem . userSize = data . userSize ; groupItem . setTitle ( data . title ) ; groupItem . setBounds ( data . bounds , true ) ; let index = toClose . indexOf ( groupItem ) ; if ( index != - 1 ) toClose . splice ( index , 1 ) ; } else { var options = { dontPush : true , immediately : true } ; new GroupItem ( [ ] , Utils . extend ( { } , data , options ) ) ; } } } toClose . forEach ( function ( groupItem ) { groupItem . getChildren ( ) . forEach ( function ( tabItem ) { if ( tabItem . parent . hidden ) iQ ( tabItem . container ) . show ( ) ; tabItem . _reconnected = false ; let tabData = Storage . getTabData ( tabItem . tab ) ; if ( tabData ) { let parentGroup = GroupItems . groupItem ( tabData . groupID ) ; if ( ! parentGroup || - 1 < toClose . indexOf ( parentGroup ) ) { tabData . groupID = activeGroupId || Object . keys ( groupItemData ) [ 0 ] ; Storage . saveTab ( tabItem . tab , tabData ) ; } } } ) ; groupItem . close ( { immediately : true } ) ; } ) ; } if ( activeGroupId ) { let activeGroupItem = this . groupItem ( activeGroupId ) ; if ( activeGroupItem ) UI . setActive ( activeGroupItem ) ; } this . _inited = true ; this . _save ( ) ; } catch ( e ) { Utils . log ( "error in recons: " + e ) ; } }
Restores to stored state, creating groupItems as needed.
Restores to stored state creating groupItems as needed .
// all tabs still existing in closed groups will be moved to new // groups. prepare them to be reconnected later. // sanity check the tab's groupID // the tab's group id could be invalid or point to a non-existing // group. correct it by assigning the active group id or the first // group of the just restored session. // this closes the group but not its children // set active group item // for nextID