Bug 1578375 - Stop flushing layout in SearchOneOffs::__rebuild when used with the address bar. r=adw

Differential Revision: https://phabricator.services.mozilla.com/D44449

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dão Gottwald 2019-09-03 18:32:32 +00:00
parent 2428076a35
commit 28ad95b9a1
3 changed files with 46 additions and 83 deletions

View File

@ -13,27 +13,15 @@
*/
/* These reflows happen only the first time the panel opens. */
const EXPECTED_REFLOWS_FIRST_OPEN = [
{
stack: [
"__rebuild@chrome://browser/content/search/search-one-offs.js",
/* This is limited to a one-line stack, because the next item is an async
function and as such not supported on all trees, according to bug 1501761.
"async*_rebuild@chrome://browser/content/search/search-one-offs.js",
"async*_on_popupshowing@chrome://browser/content/search/search-one-offs.js",
"handleEvent@chrome://browser/content/search/search-one-offs.js",
"_openPanel@resource:///modules/UrlbarView.jsm",
"onQueryResults@resource:///modules/UrlbarView.jsm",
"_notify@resource:///modules/UrlbarController.jsm",
"receiveResults@resource:///modules/UrlbarController.jsm",
"notifyResults@resource:///modules/UrlbarProvidersManager.jsm",
"add@resource:///modules/UrlbarProvidersManager.jsm",
"onSearchResult@resource:///modules/UrlbarProviderUnifiedComplete.jsm",
*/
],
},
];
const EXPECTED_REFLOWS_FIRST_OPEN = [];
/* These reflows happen every time the panel opens. */
const EXPECTED_REFLOWS_SECOND_OPEN = [];
add_task(async function quantumbar() {
await runUrlbarTest(true, EXPECTED_REFLOWS_FIRST_OPEN);
await runUrlbarTest(
true,
EXPECTED_REFLOWS_FIRST_OPEN,
EXPECTED_REFLOWS_SECOND_OPEN
);
});

View File

@ -13,26 +13,7 @@
*/
/* These reflows happen only the first time the panel opens. */
const EXPECTED_REFLOWS_FIRST_OPEN = [
{
stack: [
"__rebuild@chrome://browser/content/search/search-one-offs.js",
/* This is limited to a one-line stack, because the next item is an async
function and as such not supported on all trees, according to bug 1501761.
"async*_rebuild@chrome://browser/content/search/search-one-offs.js",
"async*_on_popupshowing@chrome://browser/content/search/search-one-offs.js",
"handleEvent@chrome://browser/content/search/search-one-offs.js",
"_openPanel@resource:///modules/UrlbarView.jsm",
"onQueryResults@resource:///modules/UrlbarView.jsm",
"_notify@resource:///modules/UrlbarController.jsm",
"receiveResults@resource:///modules/UrlbarController.jsm",
"notifyResults@resource:///modules/UrlbarProvidersManager.jsm",
"add@resource:///modules/UrlbarProvidersManager.jsm",
"onSearchResult@resource:///modules/UrlbarProviderUnifiedComplete.jsm",
*/
],
},
];
const EXPECTED_REFLOWS_FIRST_OPEN = [];
/* These reflows happen every time the panel opens. */
const EXPECTED_REFLOWS_SECOND_OPEN = [];

View File

@ -172,7 +172,7 @@ class SearchOneOffs {
* Width in pixels of the one-off buttons.
*/
get buttonWidth() {
return this.compact ? 40 : 48;
return 48;
}
/**
@ -476,51 +476,45 @@ class SearchOneOffs {
return;
}
// this.buttonWidth is for the compact settings button.
let buttonsWidth = this.compact
? this._textboxWidth - this.buttonWidth - this.header.clientWidth
: this.popup.clientWidth;
// There's one weird thing to guard against: when layout pixels
// aren't an integral multiple of device pixels, the last button
// of each row sometimes gets pushed to the next row, depending on the
// panel and button widths.
// This is likely because the clientWidth getter rounds the value, but
// the panel's border width is not an integer.
// As a workaround, decrement the width if the scale is not an integer.
let scale = window.windowUtils.screenPixelsPerCSSPixel;
if (Math.floor(scale) != scale) {
--buttonsWidth;
}
// If the header string is very long, then the searchbar buttons will
// overflow their container unless max-width is set.
if (this.compact) {
this.spacerCompact.setAttribute("flex", "1");
} else {
}
if (this.popup) {
let buttonsWidth = this.popup.clientWidth;
// There's one weird thing to guard against: when layout pixels
// aren't an integral multiple of device pixels, the last button
// of each row sometimes gets pushed to the next row, depending on the
// panel and button widths.
// This is likely because the clientWidth getter rounds the value, but
// the panel's border width is not an integer.
// As a workaround, decrement the width if the scale is not an integer.
let scale = window.windowUtils.screenPixelsPerCSSPixel;
if (Math.floor(scale) != scale) {
--buttonsWidth;
}
// If the header string is very long, then the searchbar buttons will
// overflow their container unless max-width is set.
this.buttons.style.setProperty("max-width", `${buttonsWidth}px`);
// In very narrow windows, we should always have at least one button
// per row.
buttonsWidth = Math.max(buttonsWidth, this.buttonWidth);
let enginesPerRow = Math.floor(buttonsWidth / this.buttonWidth);
// There will be an empty area of:
// buttonsWidth - enginesPerRow * this.buttonWidth px
// at the end of each row.
// If the <div> with the list of search engines doesn't have
// a fixed height, the panel will be sized incorrectly, causing the bottom
// of the suggestion <tree> to be hidden.
let rowCount = Math.ceil(oneOffCount / enginesPerRow);
let height = rowCount * this.buttonHeight;
this.buttons.style.setProperty("height", `${height}px`);
}
// 24: 12px left padding + 12px right padding.
if (this.compact) {
buttonsWidth -= 24;
}
// In very narrow windows, we should always have at least one button
// per row.
buttonsWidth = Math.max(buttonsWidth, this.buttonWidth);
let enginesPerRow = Math.floor(buttonsWidth / this.buttonWidth);
// There will be an empty area of:
// buttonsWidth - enginesPerRow * this.buttonWidth px
// at the end of each row.
// If the <div> with the list of search engines doesn't have
// a fixed height, the panel will be sized incorrectly, causing the bottom
// of the suggestion <tree> to be hidden.
let rowCount = Math.ceil(oneOffCount / enginesPerRow);
let height = rowCount * this.buttonHeight;
this.buttons.style.setProperty("height", `${height}px`);
// Ensure we can refer to the settings buttons by ID:
let origin = this.telemetryOrigin;
this.settingsButton.id = origin + "-anon-search-settings";