Bug 1526811 - Port more of bug 1472557 to fix attachment navigation. r=mkmelin a=jorgk
authorJorg K <jorgk@jorgk.com>
Tue, 02 Apr 2019 15:31:00 +0200
changeset 33986 e0ec15fa6c0626752a5ff03d6fdf2424f7d753fc
parent 33985 7578c17c775f6a571bd3f7747eaea85e8db0bd37
child 33987 a3b2ff50ea269c3c9bbaba2fea8711bd34c869d4
push id2400
push usermozilla@jorgk.com
push dateFri, 19 Apr 2019 16:50:45 +0000
treeherdercomm-beta@cc70860e0c10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1526811, 1472557
Bug 1526811 - Port more of bug 1472557 to fix attachment navigation. r=mkmelin a=jorgk
common/bindings/richlistbox.xml
mail/base/content/mailWidgets.xml
--- a/common/bindings/richlistbox.xml
+++ b/common/bindings/richlistbox.xml
@@ -847,18 +847,16 @@
         <![CDATA[
           if (this.getRowCount() > 0) {
             if (this.currentIndex == -1) {
               this.currentIndex = this.getIndexOfFirstVisibleRow();
               let currentItem = this.getItemAtIndex(this.currentIndex);
               if (currentItem) {
                 this.selectItem(currentItem);
               }
-            } else {
-              this.currentItem._fireEvent("DOMMenuItemActive");
             }
           }
           this._lastKeyTime = 0;
         ]]>
       </handler>
 
       <handler event="keypress" phase="target">
         <![CDATA[
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -93,17 +93,17 @@
       </method>
       <method name="getIndexOfFirstVisibleRow">
         <body><![CDATA[
           if (this._childNodes.length == 0)
             return -1;
 
           // First try to estimate which row is visible, assuming they're all
           // the same height.
-          let box = this.scrollbox;
+          let box = this;
           let estimatedRow = Math.floor(box.scrollTop /
                                         this._childNodes[0].boxObject.height);
           let estimatedIndex = estimatedRow * this._itemsPerRow();
           let offset = this._childNodes[estimatedIndex].boxObject.screenY -
                        box.boxObject.screenY;
 
           if (offset > 0) {
             // We went too far! Go back until we find an item totally off-
@@ -138,32 +138,32 @@
         <parameter name="index"/>
         <body><![CDATA[
           this.ensureElementIsVisible(this.getItemAtIndex(index));
         ]]></body>
       </method>
       <method name="ensureElementIsVisible">
         <parameter name="item"/>
         <body><![CDATA[
-          let box = this.scrollbox;
+          let box = this;
 
           // Are we too far down?
           if (item.boxObject.screenY < box.boxObject.screenY)
             box.scrollTop = item.boxObject.y - box.boxObject.y;
           // ... or not far enough?
           else if (item.boxObject.screenY + item.boxObject.height >
                    box.boxObject.screenY + box.boxObject.height)
             box.scrollTop = item.boxObject.y + item.boxObject.height -
                             box.boxObject.y - box.boxObject.height;
         ]]></body>
       </method>
       <method name="scrollToIndex">
         <parameter name="index"/>
         <body><![CDATA[
-          let box = this.scrollbox;
+          let box = this;
           let item = this.getItemAtIndex(index);
           if (!item)
             return;
           box.scrollTop = item.boxObject.y - box.boxObject.y;
         ]]></body>
       </method>
       <method name="appendItem">
         <parameter name="attachment"/>
@@ -212,17 +212,17 @@
           this.insertBefore(item, this.getItemAtIndex(index));
           return item;
         ]]></body>
       </method>
 
       <!-- Get the preferred height (the height that would allow us to fit
            everything without scrollbars) of the attachmentlist's boxObject. -->
       <property name="preferredHeight" readonly="true"
-                onget="return this.scrollbox.scrollHeight - this.scrollbox.clientHeight + this.boxObject.height;"/>
+                onget="return this.scrollHeight - this.clientHeight + this.boxObject.height;"/>
 
       <!-- Find the attachmentitem node for the specified nsIMsgAttachment. -->
       <method name="findItemForAttachment">
         <parameter name="aAttachment"/>
         <body><![CDATA[
           for (let i = 0; i < this.itemCount; i++) {
             let item = this.getItemAtIndex(i);
             if (item.attachment == aAttachment)
@@ -234,21 +234,16 @@
 
       <!-- ///////////////// private members ///////////////// -->
 
       <property name="_childNodes" readonly="true">
         <getter><![CDATA[
           return this.querySelectorAll("richlistitem.attachmentItem");
         ]]></getter>
       </property>
-      <property name="scrollbox" readonly="true">
-        <getter><![CDATA[
-          return document.getAnonymousElementByAttribute(this, "anonid", "scrollbox");
-        ]]></getter>
-      </property>
 
       <method name="_fireOnSelect">
         <body><![CDATA[
           if (!this._suppressOnSelect && !this.suppressOnSelect) {
             this.dispatchEvent(new Event("select",
                                          { bubbles: false, cancelable: true }));
           }
         ]]></body>
@@ -260,34 +255,34 @@
           if (this._childNodes.length < 2)
             return this._childNodes.length;
 
           let itemWidth = this._childNodes[1].boxObject.x -
                           this._childNodes[0].boxObject.x;
 
           if (itemWidth == 0) // Each item takes up a full row
             return 1;
-          return Math.floor(this.scrollbox.clientWidth / itemWidth);
+          return Math.floor(this.clientWidth / itemWidth);
         ]]></body>
       </method>
 
       <method name="_itemsPerCol">
         <parameter name="aItemsPerRow"/>
         <body><![CDATA[
           let itemsPerRow = aItemsPerRow || this._itemsPerRow();
 
           if (this._childNodes.length == 0)
             return 0;
           else if (this._childNodes.length <= itemsPerRow)
             return 1;
 
           let itemHeight = this._childNodes[itemsPerRow].boxObject.y -
                            this._childNodes[0].boxObject.y;
 
-          return Math.floor(this.scrollbox.clientHeight / itemHeight);
+          return Math.floor(this.clientHeight / itemHeight);
         ]]></body>
       </method>
 
       <method name="_setImageSize">
         <body><![CDATA[
           let size = this.sizes[this.view] || 16;
 
           for (let i = 0; i < this._childNodes.length; i++)
@@ -318,23 +313,16 @@
       ]]></handler>
       <!-- make sure we keep the focus... -->
       <handler event="mousedown" button="0"
                action="if (document.commandDispatcher.focusedElement != this) this.focus();"/>
     </handlers>
   </binding>
 
   <binding id="attachmentlist-horizontal" extends="chrome://messenger/content/mailWidgets.xml#attachmentlist-base">
-    <content>
-      <xul:scrollbox flex="1" anonid="scrollbox" style="overflow: auto;">
-        <xul:hbox flex="1" class="attachmentlist-wrapper">
-          <children includes="richlistitem"/>
-        </xul:hbox>
-      </xul:scrollbox>
-    </content>
     <implementation>
       <method name="setOptimumWidth">
         <body><![CDATA[
           if (this._childNodes.length == 0)
             return;
 
           let width = 0;
           let border = this._childNodes[0].boxObject.width -