B2G/gecko/browser/components/tabview/ui.js
//   force - true to update even when "unnecessary"; default false
true to update even when "unnecessary"; default false
true to update even when " unnecessary " ; default false
function UI__resize(force) {
    if (!this._pageBounds)
      return;
    if (!force && !this.isTabViewVisible())
      return;
    let oldPageBounds = new Rect(this._pageBounds);
    let newPageBounds = Items.getPageBounds();
    if (newPageBounds.equals(oldPageBounds))
      return;
    if (!this.shouldResizeItems())
      return;
    var items = Items.getTopLevelItems();
    var itemBounds = new Rect(this._pageBounds);
    itemBounds.width = 1;
    itemBounds.height = 1;
    items.forEach(function(item) {
      var bounds = item.getBounds();
      itemBounds = (itemBounds ? itemBounds.union(bounds) : new Rect(bounds));
    });
    if (newPageBounds.width < this._pageBounds.width &&
        newPageBounds.width > itemBounds.width)
      newPageBounds.width = this._pageBounds.width;
    if (newPageBounds.height < this._pageBounds.height &&
        newPageBounds.height > itemBounds.height)
      newPageBounds.height = this._pageBounds.height;
    var wScale;
    var hScale;
    if (Math.abs(newPageBounds.width - this._pageBounds.width)
         > Math.abs(newPageBounds.height - this._pageBounds.height)) {
      wScale = newPageBounds.width / this._pageBounds.width;
      hScale = newPageBounds.height / itemBounds.height;
    } else {
      wScale = newPageBounds.width / itemBounds.width;
      hScale = newPageBounds.height / this._pageBounds.height;
    }
    var scale = Math.min(hScale, wScale);
    var self = this;
    var pairs = [];
    items.forEach(function(item) {
      var bounds = item.getBounds();
      bounds.left += (UI.rtl ? -1 : 1) * (newPageBounds.left - self._pageBounds.left);
      bounds.left *= scale;
      bounds.width *= scale;
      bounds.top += newPageBounds.top - self._pageBounds.top;
      bounds.top *= scale;
      bounds.height *= scale;
      pairs.push({
        item: item,
        bounds: bounds
      });
    });
    Items.unsquish(pairs);
    pairs.forEach(function(pair) {
      pair.item.setBounds(pair.bounds, true);
      pair.item.snap();
    });
    this._pageBounds = Items.getPageBounds();
    this._save();
  }
function UI__resize ( force ) { if ( ! this . _pageBounds ) return ; if ( ! force && ! this . isTabViewVisible ( ) ) return ; let oldPageBounds = new Rect ( this . _pageBounds ) ; let newPageBounds = Items . getPageBounds ( ) ; if ( newPageBounds . equals ( oldPageBounds ) ) return ; if ( ! this . shouldResizeItems ( ) ) return ; var items = Items . getTopLevelItems ( ) ; var itemBounds = new Rect ( this . _pageBounds ) ; itemBounds . width = 1 ; itemBounds . height = 1 ; items . forEach ( function ( item ) { var bounds = item . getBounds ( ) ; itemBounds = ( itemBounds ? itemBounds . union ( bounds ) : new Rect ( bounds ) ) ; } ) ; if ( newPageBounds . width < this . _pageBounds . width && newPageBounds . width > itemBounds . width ) newPageBounds . width = this . _pageBounds . width ; if ( newPageBounds . height < this . _pageBounds . height && newPageBounds . height > itemBounds . height ) newPageBounds . height = this . _pageBounds . height ; var wScale ; var hScale ; if ( Math . abs ( newPageBounds . width - this . _pageBounds . width ) > Math . abs ( newPageBounds . height - this . _pageBounds . height ) ) { wScale = newPageBounds . width / this . _pageBounds . width ; hScale = newPageBounds . height / itemBounds . height ; } else { wScale = newPageBounds . width / itemBounds . width ; hScale = newPageBounds . height / this . _pageBounds . height ; } var scale = Math . min ( hScale , wScale ) ; var self = this ; var pairs = [ ] ; items . forEach ( function ( item ) { var bounds = item . getBounds ( ) ; bounds . left += ( UI . rtl ? - 1 : 1 ) * ( newPageBounds . left - self . _pageBounds . left ) ; bounds . left *= scale ; bounds . width *= scale ; bounds . top += newPageBounds . top - self . _pageBounds . top ; bounds . top *= scale ; bounds . height *= scale ; pairs . push ( { item : item , bounds : bounds } ) ; } ) ; Items . unsquish ( pairs ) ; pairs . forEach ( function ( pair ) { pair . item . setBounds ( pair . bounds , true ) ; pair . item . snap ( ) ; } ) ; this . _pageBounds = Items . getPageBounds ( ) ; this . _save ( ) ; }
force - true to update even when "unnecessary"; default false
force - true to update even when " unnecessary " ; default false
// Here are reasons why we *won't* resize: // 1. Panorama isn't visible (in which case we will resize when we do display) // 2. the screen dimensions haven't changed // 3. everything on the screen fits and nothing feels cramped // compute itemBounds: the union of all the top-level items' bounds. // We start with pageBounds so that we respect the empty space the user // has left on the page.