B2G/gecko/browser/components/tabview/items.js
//   ignore - an <Item> to not include in calculations (because it's about to be closed, for instance)
an  to not include in calculations (because it's about to be closed, for instance)
an to not include in calculations ( because it ' s about to be closed for instance )
function Items_unsquish(pairs, ignore) {
    var pairsProvided = (pairs ? true : false);
    if (!pairsProvided) {
      var items = Items.getTopLevelItems();
      pairs = [];
      items.forEach(function(item) {
        pairs.push({
          item: item,
          bounds: item.getBounds()
        });
      });
    }
    var pageBounds = Items.getSafeWindowBounds();
    pairs.forEach(function(pair) {
      var item = pair.item;
      if (item == ignore)
        return;
      var bounds = pair.bounds;
      var newBounds = new Rect(bounds);
      var newSize;
      if (Utils.isPoint(item.userSize))
        newSize = new Point(item.userSize);
      else if (item.isAGroupItem)
        newSize = GroupItems.calcValidSize(
          new Point(GroupItems.minGroupWidth, -1));
      else
        newSize = TabItems.calcValidSize(
          new Point(TabItems.tabWidth, -1));
      if (item.isAGroupItem) {
          newBounds.width = Math.max(newBounds.width, newSize.x);
          newBounds.height = Math.max(newBounds.height, newSize.y);
      } else {
        if (bounds.width < newSize.x) {
          newBounds.width = newSize.x;
          newBounds.height = newSize.y;
        }
      }
      newBounds.left -= (newBounds.width - bounds.width) / 2;
      newBounds.top -= (newBounds.height - bounds.height) / 2;
      var offset = new Point();
      if (newBounds.left < pageBounds.left)
        offset.x = pageBounds.left - newBounds.left;
      else if (newBounds.right > pageBounds.right)
        offset.x = pageBounds.right - newBounds.right;
      if (newBounds.top < pageBounds.top)
        offset.y = pageBounds.top - newBounds.top;
      else if (newBounds.bottom > pageBounds.bottom)
        offset.y = pageBounds.bottom - newBounds.bottom;
      newBounds.offset(offset);
      if (!bounds.equals(newBounds)) {
        var blocked = false;
        pairs.forEach(function(pair2) {
          if (pair2 == pair || pair2.item == ignore)
            return;
          var bounds2 = pair2.bounds;
          if (bounds2.intersects(newBounds))
            blocked = true;
          return;
        });
        if (!blocked) {
          pair.bounds.copy(newBounds);
        }
      }
      return;
    });
    if (!pairsProvided) {
      pairs.forEach(function(pair) {
        pair.item.setBounds(pair.bounds);
      });
    }
  }
function Items_unsquish ( pairs , ignore ) { var pairsProvided = ( pairs ? true : false ) ; if ( ! pairsProvided ) { var items = Items . getTopLevelItems ( ) ; pairs = [ ] ; items . forEach ( function ( item ) { pairs . push ( { item : item , bounds : item . getBounds ( ) } ) ; } ) ; } var pageBounds = Items . getSafeWindowBounds ( ) ; pairs . forEach ( function ( pair ) { var item = pair . item ; if ( item == ignore ) return ; var bounds = pair . bounds ; var newBounds = new Rect ( bounds ) ; var newSize ; if ( Utils . isPoint ( item . userSize ) ) newSize = new Point ( item . userSize ) ; else if ( item . isAGroupItem ) newSize = GroupItems . calcValidSize ( new Point ( GroupItems . minGroupWidth , - 1 ) ) ; else newSize = TabItems . calcValidSize ( new Point ( TabItems . tabWidth , - 1 ) ) ; if ( item . isAGroupItem ) { newBounds . width = Math . max ( newBounds . width , newSize . x ) ; newBounds . height = Math . max ( newBounds . height , newSize . y ) ; } else { if ( bounds . width < newSize . x ) { newBounds . width = newSize . x ; newBounds . height = newSize . y ; } } newBounds . left -= ( newBounds . width - bounds . width ) / 2 ; newBounds . top -= ( newBounds . height - bounds . height ) / 2 ; var offset = new Point ( ) ; if ( newBounds . left < pageBounds . left ) offset . x = pageBounds . left - newBounds . left ; else if ( newBounds . right > pageBounds . right ) offset . x = pageBounds . right - newBounds . right ; if ( newBounds . top < pageBounds . top ) offset . y = pageBounds . top - newBounds . top ; else if ( newBounds . bottom > pageBounds . bottom ) offset . y = pageBounds . bottom - newBounds . bottom ; newBounds . offset ( offset ) ; if ( ! bounds . equals ( newBounds ) ) { var blocked = false ; pairs . forEach ( function ( pair2 ) { if ( pair2 == pair || pair2 . item == ignore ) return ; var bounds2 = pair2 . bounds ; if ( bounds2 . intersects ( newBounds ) ) blocked = true ; return ; } ) ; if ( ! blocked ) { pair . bounds . copy ( newBounds ) ; } } return ; } ) ; if ( ! pairsProvided ) { pairs . forEach ( function ( pair ) { pair . item . setBounds ( pair . bounds ) ; } ) ; } }
ignore - an <Item> to not include in calculations (because it's about to be closed, for instance)
ignore - an <Item > to not include in calculations ( because it ' s about to be closed for instance )