diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 89df90f1eadf..8b2312b2b622 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -799,7 +799,6 @@ autocompletesearchparam="enable-actions" autocompletepopup="PopupAutoCompleteRichResult" completeselectedindex="true" - shrinkdelay="250" tabscrolling="true" newlines="stripsurroundingwhitespace" ontextentered="this.handleCommand(param);" diff --git a/browser/base/content/test/performance/browser_urlbar_keyed_search.js b/browser/base/content/test/performance/browser_urlbar_keyed_search.js index 6c9c91d5e3e8..48ef5afa0ccf 100644 --- a/browser/base/content/test/performance/browser_urlbar_keyed_search.js +++ b/browser/base/content/test/performance/browser_urlbar_keyed_search.js @@ -30,22 +30,6 @@ const EXPECTED_REFLOWS_FIRST_OPEN = [ ], }, - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "onxblpopupshown@chrome://global/content/bindings/autocomplete.xml" - ], - maxCount: 5, // This number should only ever go down - never up. - }, - - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "_invalidate/this._adjustHeightTimeout<@chrome://global/content/bindings/autocomplete.xml", - ], - maxCount: 51, // This number should only ever go down - never up. - }, - { stack: [ "_handleOverflow@chrome://global/content/bindings/autocomplete.xml", diff --git a/browser/base/content/test/performance/browser_urlbar_search.js b/browser/base/content/test/performance/browser_urlbar_search.js index bb38bcf93d79..9285fd6c3e01 100644 --- a/browser/base/content/test/performance/browser_urlbar_search.js +++ b/browser/base/content/test/performance/browser_urlbar_search.js @@ -30,22 +30,6 @@ const EXPECTED_REFLOWS_FIRST_OPEN = [ ], }, - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "onxblpopupshown@chrome://global/content/bindings/autocomplete.xml" - ], - maxCount: 5, // This number should only ever go down - never up. - }, - - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "_invalidate/this._adjustHeightTimeout<@chrome://global/content/bindings/autocomplete.xml", - ], - maxCount: 6, // This number should only ever go down - never up. - }, - { stack: [ "_handleOverflow@chrome://global/content/bindings/autocomplete.xml", @@ -83,22 +67,6 @@ const EXPECTED_REFLOWS_FIRST_OPEN = [ /* These reflows happen everytime the awesomebar panel opens. */ const EXPECTED_REFLOWS_SECOND_OPEN = [ - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "onxblpopupshown@chrome://global/content/bindings/autocomplete.xml" - ], - maxCount: 3, // This number should only ever go down - never up. - }, - - { - stack: [ - "adjustHeight@chrome://global/content/bindings/autocomplete.xml", - "_invalidate/this._adjustHeightTimeout<@chrome://global/content/bindings/autocomplete.xml", - ], - maxCount: 6, // This number should only ever go down - never up. - }, - { stack: [ "_handleOverflow@chrome://global/content/bindings/autocomplete.xml", diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 1d204a7400c4..76e6169d692f 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -1911,6 +1911,10 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. document.getAnonymousElementByAttribute(this, "anonid", "footer"); + + 250 + + document.getAnonymousElementByAttribute(this, "anonid", "one-off-search-buttons"); @@ -2195,6 +2199,83 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. ]]> + + + { + if (window.closed) { + return; + } + this._rowHeight = rows[0].getBoundingClientRect().height; + let style = window.getComputedStyle(this.richlistbox); + + let paddingTop = parseInt(style.paddingTop) || 0; + let paddingBottom = parseInt(style.paddingBottom) || 0; + this._rlbPadding = paddingTop + paddingBottom; + // Then re-run - but don't dirty layout from inside this callback. + window.requestAnimationFrame(() => this.adjustHeight()); + }); + return; + } + + // Calculate the height to have the first row to last row shown + height = (this._rowHeight * numRows) + this._rlbPadding; + } + + let animate = this.getAttribute("dontanimate") != "true"; + let currentHeight = + parseFloat(this.richlistbox.getAttribute("height"), 10) || + parseFloat(this.richlistbox.style.height, 10) || + 0; // It's possible we get here when we haven't set height on the richlistbox + // yet, which means parseFloat will return NaN. It should return 0 instead. + if (height > currentHeight) { + // Grow immediately. + if (animate) { + this.richlistbox.removeAttribute("height"); + this.richlistbox.style.height = height + "px"; + } else { + this.richlistbox.style.removeProperty("height"); + this.richlistbox.height = height; + } + } else if (height < currentHeight) { // Don't shrink if height matches exactly + // Delay shrinking to avoid flicker. + this._shrinkTimeout = setTimeout(() => { + this._collapseUnusedItems(); + if (animate) { + this.richlistbox.removeAttribute("height"); + this.richlistbox.style.height = height + "px"; + } else { + this.richlistbox.style.removeProperty("height"); + this.richlistbox.height = height; + } + }, this.shrinkDelay); + } + ]]> + + + diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index 514f7595266e..5743ff03e28d 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -131,10 +131,6 @@ - - parseInt(this.getAttribute("shrinkdelay")) || 0 - - null false 0 - false @@ -826,16 +821,14 @@ this.richlistbox.collapsed = (this.matchCount == 0); // Update the richlistbox height. - if (this._adjustHeightTimeout) { - clearTimeout(this._adjustHeightTimeout); - } - if (this._shrinkTimeout) { - clearTimeout(this._shrinkTimeout); + if (this._adjustHeightRAFToken) { + cancelAnimationFrame(this._adjustHeightRAFToken); + this._adjustHeightRAFToken = null; } if (this.mPopupOpen) { delete this._adjustHeightOnPopupShown; - this._adjustHeightTimeout = setTimeout(() => this.adjustHeight(), 0); + this._adjustHeightRAFToken = requestAnimationFrame(() => this.adjustHeight()); } else { this._adjustHeightOnPopupShown = true; } @@ -896,31 +889,17 @@ 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) { 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; } - 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"; - } - // The class `forceHandleUnderflow` is for the item might need to // handle OverUnderflow or Overflow when the height of an item will // be changed dynamically. @@ -936,31 +915,12 @@ this._rlbPadding; } - let animate = this._rlbAnimated && - this.getAttribute("dontanimate") != "true"; let currentHeight = this.richlistbox.getBoundingClientRect().height; - if (height > currentHeight) { - // Grow immediately. - if (animate) { - this.richlistbox.removeAttribute("height"); - this.richlistbox.style.height = height + "px"; - } else { - this.richlistbox.style.removeProperty("height"); - this.richlistbox.height = height; - } - } else { - // Delay shrinking to avoid flicker. - this._shrinkTimeout = setTimeout(() => { - this._collapseUnusedItems(); - if (animate) { - this.richlistbox.removeAttribute("height"); - this.richlistbox.style.height = height + "px"; - } else { - this.richlistbox.style.removeProperty("height"); - this.richlistbox.height = height; - } - }, this.mInput.shrinkDelay); + if (height <= currentHeight) { + this._collapseUnusedItems(); } + this.richlistbox.style.removeProperty("height"); + this.richlistbox.height = height; ]]>