Bug 1582396 - Set width correctly on the searchbar autocomplete in the overflow menu. r=dao
authorHarry Twyford <htwyford@mozilla.com>
Tue, 24 Sep 2019 10:17:21 +0000
changeset 494700 ed063a8283becdc6d58d89c7ce6aef4989f9a371
parent 494699 d24d00b719aac4882dc4b23e2a6220cf5d535ca2
child 494701 c4ba0117c23dafa4a575fd1cb213ac9769d5a5ea
push id96173
push userhtwyford@mozilla.com
push dateTue, 24 Sep 2019 13:04:27 +0000
treeherderautoland@ed063a8283be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1582396
milestone71.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 1582396 - Set width correctly on the searchbar autocomplete in the overflow menu. r=dao Differential Revision: https://phabricator.services.mozilla.com/D46488
browser/components/search/content/autocomplete-popup.js
browser/components/search/content/searchbar.js
--- a/browser/components/search/content/autocomplete-popup.js
+++ b/browser/components/search/content/autocomplete-popup.js
@@ -10,28 +10,16 @@
    * A richlistbox popup custom element for for a browser search autocomplete
    * widget.
    */
   class MozSearchAutocompleteRichlistboxPopup extends MozElements.MozAutocompleteRichlistboxPopup {
     constructor() {
       super();
 
       this.addEventListener("popupshowing", event => {
-        // Force the panel to have the width of the searchbar rather than
-        // the width of the textfield.
-        let DOMUtils = window.windowUtils;
-        let textboxRect = DOMUtils.getBoundsWithoutFlushing(this.mInput);
-
-        // Ensure the panel is wide enough to fit at least 3 engines.
-        let minWidth = Math.max(
-          textboxRect.width,
-          this.oneOffButtons.buttonWidth * 3
-        );
-        this.style.minWidth = Math.round(minWidth) + "px";
-
         // First handle deciding if we are showing the reduced version of the
         // popup containing only the preferences button. We do this if the
         // glass icon has been clicked if the text field is empty.
         let searchbar = document.getElementById("searchbar");
         if (searchbar.hasAttribute("showonlysettings")) {
           searchbar.removeAttribute("showonlysettings");
           this.setAttribute("showonlysettings", "true");
 
--- a/browser/components/search/content/searchbar.js
+++ b/browser/components/search/content/searchbar.js
@@ -775,19 +775,22 @@
 
           popup.mInput = this.textbox;
           // clear any previous selection, see bugs 400671 and 488357
           popup.selectedIndex = -1;
 
           document.popupNode = null;
 
           let { width } = this.getBoundingClientRect();
-          popup.setAttribute("width", width > 100 ? width : 100);
+          // Ensure the panel is wide enough to fit at least 3 engines.
+          if (this.oneOffButtons) {
+            width = Math.max(width, this.oneOffButtons.buttonWidth * 3);
+          }
+          popup.style.minWidth = width + "px";
 
-          // invalidate() depends on the width attribute
           popup._invalidate();
 
           popup.openPopup(this, "after_start");
         }
       };
 
       this.textbox.openSearch = () => {
         if (!this.textbox.popupOpen) {