[Bug 631868] Tab drift in TabItem_setBounds code [r=ian, a=sdwilsh]
authorMichael Yoshitaka Erlewine <mitcho@mitcho.com>
Mon, 07 Feb 2011 21:00:07 -0500
changeset 62157 18b96505628988dcaacdc095e648240b958884f1
parent 62156 6f4c4e84943d63d7eaf3a1d0e8a56eb50da2c4aa
child 62158 a3a568807d829f04722d5bb9e2be1fa846f40058
push id18623
push usereakhgari@mozilla.com
push dateTue, 08 Feb 2011 19:21:11 +0000
treeherdermozilla-central@a3a568807d82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian, sdwilsh
bugs631868
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
[Bug 631868] Tab drift in TabItem_setBounds code [r=ian, a=sdwilsh]
browser/base/content/tabview/tabitems.js
--- a/browser/base/content/tabview/tabitems.js
+++ b/browser/base/content/tabview/tabitems.js
@@ -422,105 +422,105 @@ TabItem.prototype = Utils.extend(new Ite
 
     // force the input size to be valid
     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 = {};
+    var css = {};
 
-      if (rect.left != this.bounds.left || options.force)
-        css.left = rect.left;
+    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.top != this.bounds.top || options.force)
-        css.top = rect.top;
+    if (rect.width != this.bounds.width || options.force) {
+      css.width = rect.width - this.sizeExtra.x;
+      css.fontSize = this._getFontSizeFromWidth(rect.width);
+      css.fontSize += 'px';
+    }
 
-      if (rect.width != this.bounds.width || options.force) {
-        css.width = rect.width - this.sizeExtra.x;
-        css.fontSize = this._getFontSizeFromWidth(rect.width);
-        css.fontSize += 'px';
-      }
+    if (rect.height != this.bounds.height || options.force) {
+      if (!this.isStacked)
+        css.height = rect.height - this.sizeExtra.y - TabItems.fontSizeRange.max;
+      else
+        css.height = rect.height - this.sizeExtra.y;
+    }
+
+    if (Utils.isEmptyObject(css))
+      return;
+
+    this.bounds.copy(rect);
 
-      if (rect.height != this.bounds.height || options.force) {
-        if (!this.isStacked)
-          css.height = rect.height - this.sizeExtra.y - TabItems.fontSizeRange.max;
-        else
-          css.height = rect.height - this.sizeExtra.y;
-      }
-
-      if (Utils.isEmptyObject(css))
-        return;
-
-      this.bounds.copy(rect);
+    // 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.
+    if (immediately || (!this._hasBeenDrawn)) {
+      this.$container.css(css);
+    } else {
+      TabItems.pausePainting();
+      this.$container.animate(css, {
+          duration: 200,
+        easing: "tabviewBounce",
+        complete: function() {
+          TabItems.resumePainting();
+        }
+      });
+    }
 
-      // 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.
-      if (immediately || (!this._hasBeenDrawn)) {
-        this.$container.css(css);
+    if (css.fontSize && !this.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.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); // between 0 and 1
       } else {
-        TabItems.pausePainting();
-        this.$container.animate(css, {
-            duration: 200,
-          easing: "tabviewBounce",
-          complete: function() {
-            TabItems.resumePainting();
-          }
-        });
+        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); // between 0 and 1
       }
 
-      if (css.fontSize && !this.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 (proportion <= .1)
+        this.$close.hide();
+      else
+        this.$close.show().css({opacity:proportion});
 
-        if (this.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); // between 0 and 1
-        } 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); // between 0 and 1
-        }
+      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) +")",
+      });
+    }
 
-        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;
+    this._hasBeenDrawn = true;
 
     UI.clearShouldResizeItems();
 
     this._updateDebugBounds();
     rect = this.getBounds(); // ensure that it's a <Rect>
 
     if (!Utils.isRect(this.bounds))
       Utils.trace('TabItem.setBounds: this.bounds is not a real rectangle!', this.bounds);