Bug 1503824 - Migrate the treecols binding into a custom element. r=bgrins
authorVictor Porof <vporof@mozilla.com>
Tue, 27 Nov 2018 18:43:58 +0100
changeset 448459 4b9f8acdf5f780ed38490f40a74bb33cac3f264d
parent 448458 b1a6e2052ea19b8fbf7fde7e3aa25629ff5163be
child 448460 7a19fe6be68ce356cf2d94b09ad458d8c517bdcf
child 448481 9234dc84cd93547d60e7f74949b422003691677d
push id110178
push usercbrindusan@mozilla.com
push dateWed, 28 Nov 2018 07:05:59 +0000
treeherdermozilla-inbound@4b9f8acdf5f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1503824
milestone65.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 1503824 - Migrate the treecols binding into a custom element. r=bgrins
layout/generic/crashtests/crashtests.list
toolkit/content/widgets/tree.js
toolkit/content/widgets/tree.xml
toolkit/content/xul.css
--- a/layout/generic/crashtests/crashtests.list
+++ b/layout/generic/crashtests/crashtests.list
@@ -110,17 +110,17 @@ load 380012-1.html
 load 381152-1.html
 load 381786-1.html
 load 382129-1.xhtml
 load 382131-1.html
 load 382199-1.html
 load 382208-1.xhtml
 load 382262-1.html
 load 382396-1.xhtml
-asserts(1) load 382745-1.xhtml # Bug 758695
+load 382745-1.xhtml # Bug 758695
 load 383089-1.html
 load 385265-1.xhtml
 load 385295-1.xhtml
 load 385344-1.html
 load 385344-2.html
 load 385414-1.html
 load 385414-2.html
 load 385426-1.html
--- a/toolkit/content/widgets/tree.js
+++ b/toolkit/content/widgets/tree.js
@@ -405,9 +405,35 @@
       // prevent click event from firing after column drag and drop
       aEvent.stopPropagation();
       aEvent.preventDefault();
     }
   }
 
   customElements.define("treecol", MozTreecol);
 
+  class MozTreecols extends MozElements.BaseControl {
+    connectedCallback() {
+      if (this.delayConnectedCallback()) {
+        return;
+      }
+
+      if (!this.querySelector("treecolpicker")) {
+        this.appendChild(MozXULElement.parseXULToFragment(`
+          <treecolpicker class="treecol-image" fixed="true"></treecolpicker>
+        `));
+      }
+
+      let treecolpicker = this.querySelector("treecolpicker");
+      this.inheritAttribute(treecolpicker, "tooltiptext=pickertooltiptext");
+
+      // Set resizeafter="farthest" on the splitters if nothing else has been
+      // specified.
+      Array.forEach(this.getElementsByTagName("splitter"), function(splitter) {
+        if (!splitter.hasAttribute("resizeafter"))
+          splitter.setAttribute("resizeafter", "farthest");
+      });
+    }
+  }
+
+  customElements.define("treecols", MozTreecols);
+
 }
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -879,35 +879,16 @@
            }
            event.preventDefault();
          }
          ]]>
       </handler>
     </handlers>
   </binding>
 
-  <binding id="treecols">
-    <content orient="horizontal">
-      <xul:hbox class="tree-scrollable-columns" flex="1">
-        <children includes="treecol|splitter"/>
-      </xul:hbox>
-      <xul:treecolpicker class="treecol-image" fixed="true" xbl:inherits="tooltiptext=pickertooltiptext"/>
-    </content>
-    <implementation>
-      <constructor><![CDATA[
-        // Set resizeafter="farthest" on the splitters if nothing else has been
-        // specified.
-        Array.forEach(this.getElementsByTagName("splitter"), function(splitter) {
-          if (!splitter.hasAttribute("resizeafter"))
-            splitter.setAttribute("resizeafter", "farthest");
-        });
-      ]]></constructor>
-    </implementation>
-  </binding>
-
   <binding id="treerows" extends="chrome://global/content/bindings/general.xml#basecontrol">
     <content>
       <xul:hbox flex="1" class="tree-bodybox">
         <children/>
       </xul:hbox>
       <xul:scrollbar height="0" minwidth="0" minheight="0" orient="vertical" xbl:inherits="collapsed=hidevscroll" style="position:relative; z-index:2147483647;"
         oncontextmenu="event.stopPropagation(); event.preventDefault();"
         onclick="event.stopPropagation(); event.preventDefault();"
@@ -1003,16 +984,17 @@
             this.buildPopup(popup);
             popup.openPopup(this, "after_end");
           } else {
             var tree = this.parentNode.parentNode;
             tree.stopEditing(true);
             var menuitem = document.getAnonymousElementByAttribute(this, "anonid", "menuitem");
             if (event.originalTarget == menuitem) {
               tree.columns.restoreNaturalOrder();
+              this.removeAttribute("ordinal");
               tree._ensureColumnOrder();
             } else {
               var colindex = event.originalTarget.getAttribute("colindex");
               var column = tree.columns[colindex];
               if (column) {
                 var element = column.element;
                 if (element.getAttribute("hidden") == "true")
                   element.setAttribute("hidden", "false");
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -433,21 +433,17 @@ column {
 }
 
 /******** tree ******/
 
 tree {
   -moz-binding: url("chrome://global/content/bindings/tree.xml#tree");
 }
 
-treecols {
-  -moz-binding: url("chrome://global/content/bindings/tree.xml#treecols");
-}
-
-treecol {
+treecolpicker {
   -moz-box-ordinal-group: 2147483646;
 }
 
 tree > treechildren {
   display: -moz-box;
   -moz-user-select: none;
   -moz-box-flex: 1;
 }
@@ -476,21 +472,16 @@ treecol {
   min-width: 16px;
 }
 
 treecol[hidden="true"] {
   visibility: collapse;
   display: -moz-box;
 }
 
-.tree-scrollable-columns {
-  /* Yes, Virginia, this makes it scrollable */
-  overflow: hidden;
-}
-
 /* ::::: lines connecting cells ::::: */
 tree:not([treelines="true"]) > treechildren::-moz-tree-line {
   visibility: hidden;
 }
 
 treechildren::-moz-tree-cell(ltr) {
   direction: ltr !important;
 }