Bug 1187219 - Remove _visuallySelected, _logicallySelected from tabbox.xml, avoid code duplication with tabbrowser.xml. r=mconley
authorDão Gottwald <dao@mozilla.com>
Wed, 29 Jul 2015 17:33:31 +0200
changeset 287066 0a51403a45e98730384f18b580c3ca97887db651
parent 287065 5c66c559c14b2ae2828865783fdb932c9ae6fdb6
child 287067 9940e2af9ed70d951c95c418bd1a77341477cdb7
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
@@ -5663,49 +5663,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