Bug 1353708 - Avoid autocomplete call to richlistbox's ensureElementIsVisible when there can't be a scrollbar. r=florian

EnsureElementIsVisible can cause a Layout flush, so we should try to avoid it when possible.

MozReview-Commit-ID: Dr0D8vPl9rd

--HG--
extra : rebase_source : e1d6de9c1449f0b4d9780d374e5632fb40498902
This commit is contained in:
Marco Bonardo 2017-04-05 18:45:16 +02:00
Родитель 2be3fb9f63
Коммит 9e2ecc36f9
1 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -1086,12 +1086,17 @@ extends="chrome://global/content/bindings/popup.xml#popup">
<setter>
<![CDATA[
this.richlistbox.selectedIndex = val;
// 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);
// 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) {
// 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>