Bug 1187219 - Remove _visuallySelected, _logicallySelected from tabbox.xml, avoid code duplication with tabbrowser.xml. r=mconley
☠☠ backed out by 8a62423b8343 ☠ ☠
authorDão Gottwald <dao@mozilla.com>
Wed, 29 Jul 2015 17:33:31 +0200
changeset 286876 1efbd6874bfb965d0ba4f469529afa5e07a36f25
parent 286874 130ef92fa5a74132d9d30a20bade21c5736457f5
child 286877 2cd865efd0b03212dfd10423d42a4bb2bd20fa65
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1187219
milestone42.0a1
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 1187219 - Remove _visuallySelected, _logicallySelected from tabbox.xml, avoid code duplication with tabbrowser.xml. r=mconley
browser/base/content/tabbrowser.xml
toolkit/content/widgets/tabbox.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5656,49 +5656,40 @@
                              xbl:inherits="fadein,pinned,selected,visuallyselected"
                              class="tab-close-button close-icon"/>
         </xul:hbox>
       </xul:stack>
     </content>
 
     <implementation>
 
-      <!--
-          This code is the same as in toolkit/content/widgets/tabbox.xml,
-          except for the _tabAttrModified call. If you modify it, tabbox.xml
-          might also need to be modified.
-      -->
       <property name="_visuallySelected">
         <setter>
           <![CDATA[
           if (val)
             this.setAttribute("visuallyselected", "true");
           else
             this.removeAttribute("visuallyselected");
-          gBrowser._tabAttrModified(this, ["visuallyselected"]);
-
-          if (this.previousSibling && this.previousSibling.localName == "tab") {
-            if (val)
-              this.previousSibling.setAttribute("beforeselected", "true");
-            else
-              this.previousSibling.removeAttribute("beforeselected");
-            this.removeAttribute("first-tab");
-          }
+          this.parentNode.tabbrowser._tabAttrModified(this, ["visuallyselected"]);
+
+          this._setPositionAttributes(val);
+
+          return val;
+          ]]>
+        </setter>
+      </property>
+
+      <property name="_logicallySelected">
+        <setter>
+          <![CDATA[
+          if (val)
+            this.setAttribute("selected", "true");
           else
-            this.setAttribute("first-tab", "true");
-
-          if (this.nextSibling && this.nextSibling.localName == "tab") {
-            if (val)
-              this.nextSibling.setAttribute("afterselected", "true");
-            else
-              this.nextSibling.removeAttribute("afterselected");
-            this.removeAttribute("last-tab");
-          }
-          else
-            this.setAttribute("last-tab", "true");
+            this.removeAttribute("selected");
+
           return val;
           ]]>
         </setter>
       </property>
 
       <property name="_selected">
         <setter>
           <![CDATA[
--- a/toolkit/content/widgets/tabbox.xml
+++ b/toolkit/content/widgets/tabbox.xml
@@ -722,76 +722,53 @@
             return null;
           ]]>
         </getter>
       </property>
 
       <property name="selected" readonly="true"
                 onget="return this.getAttribute('selected') == 'true';"/>
 
-      <!--
-          This code is the same as in browser/base/content/tabbrowser.xml,
-          except for the _tabAttrModified call. If you modify it, tabbrowser.xml
-          should probably also be modified.
-      -->
-      <property name="_visuallySelected">
-        <setter>
-          <![CDATA[
-          if (val)
-            this.setAttribute("visuallyselected", "true");
-          else
-            this.removeAttribute("visuallyselected");
-
-          if (this.previousSibling && this.previousSibling.localName == "tab") {
-            if (val)
-              this.previousSibling.setAttribute("beforeselected", "true");
-            else
-              this.previousSibling.removeAttribute("beforeselected");
-            this.removeAttribute("first-tab");
-          }
-          else
-            this.setAttribute("first-tab", "true");
-
-          if (this.nextSibling && this.nextSibling.localName == "tab") {
-            if (val)
-              this.nextSibling.setAttribute("afterselected", "true");
-            else
-              this.nextSibling.removeAttribute("afterselected");
-            this.removeAttribute("last-tab");
-          }
-          else
-            this.setAttribute("last-tab", "true");
-          return val;
-        ]]>
-        </setter>
-      </property>
-
-      <property name="_logicallySelected">
-        <setter>
-          <![CDATA[
+      <property name="_selected">
+        <setter><![CDATA[
           if (val)
             this.setAttribute("selected", "true");
           else
             this.removeAttribute("selected");
 
+          this._setPositionAttributes(val);
+
           return val;
-          ]]>
-        </setter>
+        ]]></setter>
       </property>
 
-      <property name="_selected">
-        <setter>
-          <![CDATA[
-          // If our tab switching is synchronous, then logical selection = visual selection
-          this._logicallySelected = val;
-          this._visuallySelected = val;
-          return val;
-          ]]>
-        </setter>
-      </property>
+      <method name="_setPositionAttributes">
+        <parameter name="aSelected"/>
+        <body><![CDATA[
+          if (this.previousSibling && this.previousSibling.localName == "tab") {
+            if (aSelected)
+              this.previousSibling.setAttribute("beforeselected", "true");
+            else
+              this.previousSibling.removeAttribute("beforeselected");
+            this.removeAttribute("first-tab");
+          } else {
+            this.setAttribute("first-tab", "true");
+          }
+
+          if (this.nextSibling && this.nextSibling.localName == "tab") {
+            if (aSelected)
+              this.nextSibling.setAttribute("afterselected", "true");
+            else
+              this.nextSibling.removeAttribute("afterselected");
+            this.removeAttribute("last-tab");
+          } else {
+            this.setAttribute("last-tab", "true");
+          }
+        ]]></body>
+      </method>
 
       <property name="linkedPanel" onget="return this.getAttribute('linkedpanel')"
                                    onset="this.setAttribute('linkedpanel', val); return val;"/>
 
       <field name="arrowKeysShouldWrap" readonly="true">
 #ifdef XP_MACOSX
         true
 #else