Bug 1794630 - Use resize*=sibling for searchbar container. r=dao

This simplifies the widget tracker code to avoid having to remove random
width attributes in all children.

Resize only the searchbar, since that's the only thing that's
effectively restored already on nightly.

Differential Revision: https://phabricator.services.mozilla.com/D159071
This commit is contained in:
Emilio Cobos Álvarez 2022-10-13 15:01:20 +00:00
Родитель d6826d19e4
Коммит e641646909
4 изменённых файлов: 15 добавлений и 23 удалений

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

@ -3384,11 +3384,15 @@ function UpdateUrlbarSearchSplitterState() {
return;
}
var ibefore = null;
let ibefore = null;
let resizebefore = "none";
let resizeafter = "none";
if (urlbar && searchbar) {
if (urlbar.nextElementSibling == searchbar) {
resizeafter = "sibling";
ibefore = searchbar;
} else if (searchbar.nextElementSibling == urlbar) {
resizebefore = "sibling";
ibefore = urlbar;
}
}
@ -3397,8 +3401,8 @@ function UpdateUrlbarSearchSplitterState() {
if (!splitter) {
splitter = document.createXULElement("splitter");
splitter.id = "urlbar-search-splitter";
splitter.setAttribute("resizebefore", "flex");
splitter.setAttribute("resizeafter", "flex");
splitter.setAttribute("resizebefore", resizebefore);
splitter.setAttribute("resizeafter", resizeafter);
splitter.setAttribute("skipintoolbarset", "true");
splitter.setAttribute("overflows", "false");
splitter.className = "chromeclass-toolbar-additional";

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

@ -165,7 +165,7 @@
</toolbarbutton>
</toolbaritem>
<toolbarspring cui-areatype="toolbar" class="chromeclass-toolbar-additional"/>
<toolbaritem id="urlbar-container" persist="width"
<toolbaritem id="urlbar-container"
removable="false"
class="chromeclass-location" overflows="false">
<toolbartabstop/>

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

@ -3499,7 +3499,7 @@ BrowserGlue.prototype = {
_migrateUI: function BG__migrateUI() {
// Use an increasing number to keep track of the current migration state.
// Completely unrelated to the current Firefox release number.
const UI_VERSION = 130;
const UI_VERSION = 131;
const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
const PROFILE_DIR = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
@ -4300,6 +4300,10 @@ BrowserGlue.prototype = {
migrateXULAttributeToStyle("sidebar-box", "width");
}
if (currentUIVersion < 131) {
xulStore.removeValue(BROWSER_DOCURL, "urlbar-container", "width");
}
// Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
},

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

@ -110,24 +110,10 @@ const SearchWidgetTracker = {
removePersistedWidths() {
Services.xulStore.removeValue(
AppConstants.BROWSER_CHROME_URL,
"urlbar-container",
"width"
);
Services.xulStore.removeValue(
AppConstants.BROWSER_CHROME_URL,
this.WIDGET_ID,
WIDGET_ID,
"width"
);
for (let win of lazy.CustomizableUI.windows) {
let urlbar = win.document.getElementById("urlbar-container");
urlbar.removeAttribute("width");
win.document
.getElementById("nav-bar")
.querySelectorAll("toolbarspring")
.forEach(n => n.removeAttribute("width"));
win.PanelUI.overflowPanel
.querySelectorAll("toolbarspring")
.forEach(n => n.removeAttribute("width"));
let searchbar =
win.document.getElementById(WIDGET_ID) ||
win.gNavToolbox.palette.querySelector("#" + WIDGET_ID);
@ -137,8 +123,6 @@ const SearchWidgetTracker = {
get widgetIsInNavBar() {
let placement = lazy.CustomizableUI.getPlacementOfWidget(WIDGET_ID);
return placement
? placement.area == lazy.CustomizableUI.AREA_NAVBAR
: false;
return placement?.area == lazy.CustomizableUI.AREA_NAVBAR;
},
};