Bug 1269333 - Don't assume the height of the first row for all other rows. r=mak
authorJared Wein <jwein@mozilla.com>
Thu, 09 Jun 2016 19:01:31 -0400
changeset 301941 6f305ccfd7761c4215f024de0abe264f4e994437
parent 301940 f2c47201a3692bc157f68e096c82468adba74720
child 301942 7b2c25149bc18bc0e15a79779c812ad8143185dc
push id78510
push usercbook@mozilla.com
push dateThu, 16 Jun 2016 07:39:45 +0000
treeherdermozilla-inbound@40a413832349 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1269333
milestone50.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 1269333 - Don't assume the height of the first row for all other rows. r=mak MozReview-Commit-ID: C2BM3odV03m
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1020,17 +1020,16 @@ extends="chrome://global/content/binding
       <xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox" flex="1"/>
       <xul:hbox>
         <children/>
       </xul:hbox>
     </content>
 
     <implementation implements="nsIAutoCompletePopup">
       <field name="_currentIndex">0</field>
-      <field name="_rowHeight">0</field>
       <field name="_rlbAnimated">false</field>
 
       <!-- =================== nsIAutoCompletePopup =================== -->
 
       <property name="selectedIndex"
                 onget="return this.richlistbox.selectedIndex;">
         <setter>
           <![CDATA[
@@ -1160,36 +1159,40 @@ extends="chrome://global/content/binding
           let rows = this.richlistbox.childNodes;
           let numRows = Math.min(this._matchCount, this.maxRows, rows.length);
 
           this.removeAttribute("height");
 
           // Default the height to 0 if we have no rows to show
           let height = 0;
           if (numRows) {
-            if (!this._rowHeight) {
-              let firstRowRect = rows[0].getBoundingClientRect();
-              this._rowHeight = firstRowRect.height;
-
+            let firstRowRect = rows[0].getBoundingClientRect();
+            if (this._rlbPadding == undefined) {
               let style = window.getComputedStyle(this.richlistbox);
 
               let transition = style.transitionProperty;
               this._rlbAnimated = transition && transition != "none";
 
               let paddingTop = parseInt(style.paddingTop) || 0;
               let paddingBottom = parseInt(style.paddingBottom) || 0;
               this._rlbPadding = paddingTop + paddingBottom;
-
-              // Set a fixed max-height to avoid flicker when growing the panel.
-              this.richlistbox.style.maxHeight =
-                ((this._rowHeight * this.maxRows) + this._rlbPadding) + "px";
             }
 
+            if (numRows > this.maxRows) {
+              // Set a fixed max-height to avoid flicker when growing the panel.
+              let lastVisibleRowRect = rows[this.maxRows - 1].getBoundingClientRect();
+              let visibleHeight = lastVisibleRowRect.bottom - firstRowRect.top;
+              this.richlistbox.style.maxHeight =
+                visibleHeight + this._rlbPadding + "px";
+            }
+
+            let lastRowRect = rows[numRows - 1].getBoundingClientRect();
             // Calculate the height to have the first row to last row shown
-            height = (this._rowHeight * numRows) + this._rlbPadding;
+            height = lastRowRect.bottom - firstRowRect.top +
+                     this._rlbPadding;
           }
 
           let animate = this._rlbAnimated &&
                         this.getAttribute("dontanimate") != "true";
           let currentHeight = this.richlistbox.getBoundingClientRect().height;
           if (height > currentHeight) {
             // Grow immediately.
             if (animate) {