Bug 1356763 - Avoid ensureElementIsVisible if there's no popup open and correct reset maxRows. r=mak
authorThomas Nguyen <tnguyen@mozilla.com>
Fri, 12 May 2017 00:17:00 -0400
changeset 358333 95f2e76cdc8baebd352612dd45ec70ce5741b904
parent 358332 c60f2a5a69af6a62ceba71c775bacd8a367a654c
child 358334 a9f4846bc9ad9b876a94ee3418e3242dbdc96ad1
push id31819
push userarchaeopteryx@coole-files.de
push dateSun, 14 May 2017 16:04:50 +0000
treeherdermozilla-central@626efff0df63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1356763
milestone55.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 1356763 - Avoid ensureElementIsVisible if there's no popup open and correct reset maxRows. r=mak MozReview-Commit-ID: 8SelC4HZl0m
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1036,23 +1036,24 @@ extends="chrome://global/content/binding
         // Prevent opening popup from historydropmarker mousedown handler
         // on the same event tick the popup is hidden by the same mousedown
         // event.
         this.mIsPopupHidingTick = true;
         setTimeout(() => {
           this.mIsPopupHidingTick = false;
         }, 0);
 
-        // Reset the maxRows property to the cached "normal" value, and reset
-        // _normalMaxRows so that we can detect whether it was set by the input
-        // when the popupshowing handler runs.
+        // Reset the maxRows property to the cached "normal" value (if there's
+        // any), and reset normalMaxRows so that we can detect whether it was set
+        // by the input when the popupshowing handler runs.
 
         // Null-check this.mInput; see bug 1017914
-        if (this.mInput)
+        if (this.mInput && this._normalMaxRows > 0) {
           this.mInput.maxRows = this._normalMaxRows;
+        }
         this._normalMaxRows = -1;
         // If the list was being navigated and then closed, make sure
         // we fire accessible focus event back to textbox
 
         // Null-check this.mInput; see bug 1017914
         if (isListActive && this.mInput) {
           this.mInput.mIgnoreFocus = true;
           this.mInput._focus();
@@ -1086,17 +1087,17 @@ extends="chrome://global/content/binding
         <setter>
           <![CDATA[
           this.richlistbox.selectedIndex = val;
           // Since ensureElementIsVisible may cause an expensive Layout flush,
           // invoke it only if there may be a scrollbar, so if we could fetch
           // more results than we can show at once.
           // maxResults is the maximum number of fetched results, maxRows is the
           // maximum number of rows we show at once, without a scrollbar.
-          if (this.maxResults > this.maxRows) {
+          if (this.mPopupOpen && this.maxResults > this.maxRows) {
             // when clearing the selection (val == -1, so selectedItem will be
             // null), we want to scroll back to the top.  see bug #406194
             this.richlistbox.ensureElementIsVisible(
               this.richlistbox.selectedItem || this.richlistbox.firstChild);
           }
           return val;
         ]]>
         </setter>