Bug 971630 - Australis: Far right/left selected overflow tabs look bad on session restore. r=mconley, a=sledru.
authorJared Wein <jwein@mozilla.com>
Tue, 08 Apr 2014 16:56:12 -0400
changeset 183718 9798420b26fc8b7db2c2b3bfef1d8017f82ee36d
parent 183717 9dd4a9d6739ada89e584a49a9baa1e8fe389998b
child 183719 5aa6eb09fe62272fdc5293cdcc55476532078354
push id3458
push usermconley@mozilla.com
push dateSat, 12 Apr 2014 18:03:04 +0000
treeherdermozilla-beta@f1c211a4714d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, sledru
bugs971630
milestone29.0
Bug 971630 - Australis: Far right/left selected overflow tabs look bad on session restore. r=mconley, a=sledru.
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -3283,27 +3283,33 @@
       <method name="_canScrollToElement">
         <parameter name="tab"/>
         <body><![CDATA[
           return !tab.pinned && !tab.hidden;
         ]]></body>
       </method>
       <field name="_tabMarginLeft">null</field>
       <field name="_tabMarginRight">null</field>
-      <method name="_adjustElementStartAndEnd">
+      <method name="_calcTabMargins">
         <parameter name="aTab"/>
-        <parameter name="tabStart"/>
-        <parameter name="tabEnd"/>
         <body><![CDATA[
           if (this._tabMarginLeft === null || this._tabMarginRight === null) {
             let tabMiddle = document.getAnonymousElementByAttribute(aTab, "class", "tab-background-middle");
             let tabMiddleStyle = window.getComputedStyle(tabMiddle, null);
             this._tabMarginLeft = parseFloat(tabMiddleStyle.marginLeft);
             this._tabMarginRight = parseFloat(tabMiddleStyle.marginRight);
           }
+        ]]></body>
+      </method>
+      <method name="_adjustElementStartAndEnd">
+        <parameter name="aTab"/>
+        <parameter name="tabStart"/>
+        <parameter name="tabEnd"/>
+        <body><![CDATA[
+          this._calcTabMargins(aTab);
           if (this._tabMarginLeft < 0) {
             tabStart = tabStart + this._tabMarginLeft;
           }
           if (this._tabMarginRight < 0) {
             tabEnd = tabEnd - this._tabMarginRight;
           }
           return [tabStart, tabEnd];
         ]]></body>
@@ -3942,24 +3948,37 @@
       <method name="_notifyBackgroundTab">
         <parameter name="aTab"/>
         <body><![CDATA[
           if (aTab.pinned)
             return;
 
           var scrollRect = this.mTabstrip.scrollClientRect;
           var tab = aTab.getBoundingClientRect();
+          this.mTabstrip._calcTabMargins(aTab);
+
+          // DOMRect left/right properties are immutable.
+          tab = {left: tab.left, right: tab.right};
 
           // Is the new tab already completely visible?
           if (scrollRect.left <= tab.left && tab.right <= scrollRect.right)
             return;
 
           if (this.mTabstrip.smoothScroll) {
             let selected = !this.selectedItem.pinned &&
                            this.selectedItem.getBoundingClientRect();
+            if (selected) {
+              selected = {left: selected.left, right: selected.right};
+              // Need to take in to account the width of the left/right margins on tabs.
+              selected.left = selected.left + this.mTabstrip._tabMarginLeft;
+              selected.right = selected.right - this.mTabstrip._tabMarginRight;
+            }
+
+            tab.left += this.mTabstrip._tabMarginLeft;
+            tab.right -= this.mTabstrip._tabMarginRight;
 
             // Can we make both the new tab and the selected tab completely visible?
             if (!selected ||
                 Math.max(tab.right - selected.left, selected.right - tab.left) <=
                   scrollRect.width) {
               this.mTabstrip.ensureElementIsVisible(aTab);
               return;
             }