B2G/gecko/browser/components/tabview/tabitems.js
//   force - true to always update the DOM even if the bounds haven't changed; default false
true to always update the DOM even if the bounds haven't changed; default false
true to always update the DOM even if the bounds haven ' t changed ; default false
function TabItem_setBounds(inRect, immediately, options) {
    Utils.assert(Utils.isRect(inRect), 'TabItem.setBounds: rect is not a real rectangle!');
    if (!options)
      options = {};
    let validSize = TabItems.calcValidSize(
      new Point(inRect.width, inRect.height), 
      {hideTitle: (this.isStacked || options.hideTitle === true)});
    let rect = new Rect(inRect.left, inRect.top, 
      validSize.x, validSize.y);
    var css = {};
    if (rect.left != this.bounds.left || options.force)
      css.left = rect.left;
    if (rect.top != this.bounds.top || options.force)
      css.top = rect.top;
    if (rect.width != this.bounds.width || options.force) {
      css.width = rect.width - TabItems.tabItemPadding.x;
      css.fontSize = TabItems.getFontSizeFromWidth(rect.width);
      css.fontSize += 'px';
    }
    if (rect.height != this.bounds.height || options.force) {
      css.height = rect.height - TabItems.tabItemPadding.y;
      if (!this.isStacked)
        css.height -= TabItems.fontSizeRange.max;
    }
    if (Utils.isEmptyObject(css))
      return;
    this.bounds.copy(rect);
    if (immediately || (!this._hasBeenDrawn)) {
      this.$container.css(css);
    } else {
      TabItems.pausePainting();
      this.$container.animate(css, {
          duration: 200,
        easing: "tabviewBounce",
        complete: function() {
          TabItems.resumePainting();
        }
      });
    }
    if (css.fontSize && !(this.parent && this.parent.isStacked())) {
      if (css.fontSize < TabItems.fontSizeRange.min)
        immediately ? this.$tabTitle.hide() : this.$tabTitle.fadeOut();
      else
        immediately ? this.$tabTitle.show() : this.$tabTitle.fadeIn();
    }
    if (css.width) {
      TabItems.update(this.tab);
      let widthRange, proportion;
      if (this.parent && this.parent.isStacked()) {
        if (UI.rtl) {
          this.$fav.css({top:0, right:0});
        } else {
          this.$fav.css({top:0, left:0});
        }
        widthRange = new Range(70, 90);
        proportion = widthRange.proportion(css.width); 
      } else {
        if (UI.rtl) {
          this.$fav.css({top:4, right:2});
        } else {
          this.$fav.css({top:4, left:4});
        }
        widthRange = new Range(40, 45);
        proportion = widthRange.proportion(css.width); 
      }
      if (proportion <= .1)
        this.$close.hide();
      else
        this.$close.show().css({opacity:proportion});
      var pad = 1 + 5 * proportion;
      var alphaRange = new Range(0.1,0.2);
      this.$fav.css({
       "-moz-padding-start": pad + "px",
       "-moz-padding-end": pad + 2 + "px",
       "padding-top": pad + "px",
       "padding-bottom": pad + "px",
       "border-color": "rgba(0,0,0,"+ alphaRange.scale(proportion) +")",
      });
    }
    this._hasBeenDrawn = true;
    UI.clearShouldResizeItems();
    rect = this.getBounds(); 
    Utils.assert(Utils.isRect(this.bounds), 'TabItem.setBounds: this.bounds is not a real rectangle!');
    if (!this.parent && Utils.isValidXULTab(this.tab))
      this.setTrenches(rect);
    this.save();
  }
function TabItem_setBounds ( inRect , immediately , options ) { Utils . assert ( Utils . isRect ( inRect ) , 'TabItem.setBounds: rect is not a real rectangle!' ) ; if ( ! options ) options = { } ; let validSize = TabItems . calcValidSize ( new Point ( inRect . width , inRect . height ) , { hideTitle : ( this . isStacked || options . hideTitle === true ) } ) ; let rect = new Rect ( inRect . left , inRect . top , validSize . x , validSize . y ) ; var css = { } ; if ( rect . left != this . bounds . left || options . force ) css . left = rect . left ; if ( rect . top != this . bounds . top || options . force ) css . top = rect . top ; if ( rect . width != this . bounds . width || options . force ) { css . width = rect . width - TabItems . tabItemPadding . x ; css . fontSize = TabItems . getFontSizeFromWidth ( rect . width ) ; css . fontSize += 'px' ; } if ( rect . height != this . bounds . height || options . force ) { css . height = rect . height - TabItems . tabItemPadding . y ; if ( ! this . isStacked ) css . height -= TabItems . fontSizeRange . max ; } if ( Utils . isEmptyObject ( css ) ) return ; this . bounds . copy ( rect ) ; if ( immediately || ( ! this . _hasBeenDrawn ) ) { this . $container . css ( css ) ; } else { TabItems . pausePainting ( ) ; this . $container . animate ( css , { duration : 200 , easing : "tabviewBounce" , complete : function ( ) { TabItems . resumePainting ( ) ; } } ) ; } if ( css . fontSize && ! ( this . parent && this . parent . isStacked ( ) ) ) { if ( css . fontSize < TabItems . fontSizeRange . min ) immediately ? this . $tabTitle . hide ( ) : this . $tabTitle . fadeOut ( ) ; else immediately ? this . $tabTitle . show ( ) : this . $tabTitle . fadeIn ( ) ; } if ( css . width ) { TabItems . update ( this . tab ) ; let widthRange , proportion ; if ( this . parent && this . parent . isStacked ( ) ) { if ( UI . rtl ) { this . $fav . css ( { top : 0 , right : 0 } ) ; } else { this . $fav . css ( { top : 0 , left : 0 } ) ; } widthRange = new Range ( 70 , 90 ) ; proportion = widthRange . proportion ( css . width ) ; } else { if ( UI . rtl ) { this . $fav . css ( { top : 4 , right : 2 } ) ; } else { this . $fav . css ( { top : 4 , left : 4 } ) ; } widthRange = new Range ( 40 , 45 ) ; proportion = widthRange . proportion ( css . width ) ; } if ( proportion <= .1 ) this . $close . hide ( ) ; else this . $close . show ( ) . css ( { opacity : proportion } ) ; var pad = 1 + 5 * proportion ; var alphaRange = new Range ( 0.1 , 0.2 ) ; this . $fav . css ( { "-moz-padding-start" : pad + "px" , "-moz-padding-end" : pad + 2 + "px" , "padding-top" : pad + "px" , "padding-bottom" : pad + "px" , "border-color" : "rgba(0,0,0," + alphaRange . scale ( proportion ) + ")" , } ) ; } this . _hasBeenDrawn = true ; UI . clearShouldResizeItems ( ) ; rect = this . getBounds ( ) ; Utils . assert ( Utils . isRect ( this . bounds ) , 'TabItem.setBounds: this.bounds is not a real rectangle!' ) ; if ( ! this . parent && Utils . isValidXULTab ( this . tab ) ) this . setTrenches ( rect ) ; this . save ( ) ; }
force - true to always update the DOM even if the bounds haven't changed; default false
force - true to always update the DOM even if the bounds haven ' t changed ; default false
// force the input size to be valid // If this is a brand new tab don't animate it in from // a random location (i.e., from [0,0]). Instead, just // have it appear where it should be. // between 0 and 1 // between 0 and 1 // ensure that it's a <Rect>