Bug 1577000 - Fix Megabar breakout width on window resize. r=dao

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
harry 2019-08-30 00:10:43 +00:00
Родитель f5caa7f364
Коммит 8f234ac35d
3 изменённых файлов: 24 добавлений и 1 удалений

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

@ -179,6 +179,8 @@ class UrlbarInput {
this.dropmarker.addEventListener("mousedown", this); this.dropmarker.addEventListener("mousedown", this);
this.window.addEventListener("resize", this);
// This is used to detect commands launched from the panel, to avoid // This is used to detect commands launched from the panel, to avoid
// recording abandonment events when the command causes a blur event. // recording abandonment events when the command causes a blur event.
this.view.panel.addEventListener("command", this, true); this.view.panel.addEventListener("command", this, true);
@ -208,6 +210,7 @@ class UrlbarInput {
this.removeEventListener(name, this); this.removeEventListener(name, this);
} }
this.dropmarker.removeEventListener("mousedown", this); this.dropmarker.removeEventListener("mousedown", this);
this.window.removeEventListener("resize", this);
this.endLayoutBreakout(true); this.endLayoutBreakout(true);
@ -1678,6 +1681,22 @@ class UrlbarInput {
}); });
} }
async _on_resize(event) {
if (!(this.megabar && this._layoutBreakoutPlaceholder)) {
return;
}
let px = number => number.toFixed(2) + "px";
let width = await this.window.promiseDocumentFlushed(() => {
// We use the container because it remains flexible unlike the broken-out
// Urlbar.
return this.textbox.closest("#urlbar-container").clientWidth;
});
this.window.requestAnimationFrame(() => {
this.textbox.style.setProperty("--urlbar-width", px(width));
});
}
_on_select(event) { _on_select(event) {
// On certain user input, AutoCopyListener::OnSelectionChange() updates // On certain user input, AutoCopyListener::OnSelectionChange() updates
// the primary selection with user-selected text (when supported). // the primary selection with user-selected text (when supported).

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

@ -1045,6 +1045,10 @@ class UrlbarView {
} }
_on_resize() { _on_resize() {
if (this.megabar) {
return;
}
if (this._windowOuterWidth == this.window.outerWidth) { if (this._windowOuterWidth == this.window.outerWidth) {
// Sometimes a resize event is fired when the window's size doesn't // Sometimes a resize event is fired when the window's size doesn't
// actually change; at least, browser_tabMatchesInAwesomebar.js triggers // actually change; at least, browser_tabMatchesInAwesomebar.js triggers

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

@ -28,7 +28,7 @@
#urlbar-container, #urlbar-container,
#search-container { #search-container {
padding: 3px 5px; margin: 3px 5px;
} }
#urlbar, #urlbar,