Backed out changeset f04379a895c4 (bug 1926360) for causing bc failures @ browser_verticalTabs_widget_placements.js CLOSED TREE

This commit is contained in:
Sandor Molnar
2024-12-06 01:11:36 +02:00
parent 02598fd114
commit 0bf6cbf1f9
5 changed files with 7 additions and 203 deletions

View File

@@ -34,8 +34,6 @@ const kPrefCustomizationHorizontalTabstrip =
"browser.uiCustomization.horizontalTabstrip";
const kPrefCustomizationHorizontalTabsBackup =
"browser.uiCustomization.horizontalTabsBackup";
const kPrefCustomizationNavBarWhenVerticalTabs =
"browser.uiCustomization.navBarWhenVerticalTabs";
const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd";
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
const kPrefDrawInTitlebar = "browser.tabs.inTitlebar";
@@ -248,13 +246,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
""
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"verticalPlacementsPref",
kPrefCustomizationNavBarWhenVerticalTabs,
""
);
ChromeUtils.defineLazyGetter(lazy, "log", () => {
let { ConsoleAPI } = ChromeUtils.importESModule(
"resource://gre/modules/Console.sys.mjs"
@@ -2678,11 +2669,9 @@ var CustomizableUIInternal = {
if (
!gInBatchStack &&
CustomizableUI.verticalTabsEnabled &&
oldPlacement.area == CustomizableUI.AREA_NAVBAR &&
this.getSavedHorizontalSnapshotState().includes(aWidgetId)
oldPlacement.area == CustomizableUI.AREA_TABSTRIP
) {
this.deleteWidgetInSavedHorizontalTabStripState(aWidgetId);
this.deleteWidgetInSavedNavBarWhenVerticalTabsState(aWidgetId);
}
this.notifyListeners("onWidgetRemoved", aWidgetId, oldPlacement.area);
@@ -2736,7 +2725,7 @@ var CustomizableUIInternal = {
},
getSavedHorizontalSnapshotState() {
let state = [];
let state = null;
let prefValue = lazy.horizontalPlacementsPref;
if (prefValue) {
try {
@@ -2751,22 +2740,6 @@ var CustomizableUIInternal = {
return state;
},
getSavedVerticalSnapshotState() {
let state = [];
let prefValue = lazy.verticalPlacementsPref;
if (prefValue) {
try {
state = JSON.parse(prefValue);
} catch (e) {
lazy.log.warn(
`Failed to parse value of ${kPrefCustomizationNavBarWhenVerticalTabs}`,
e
);
}
}
return state;
},
// Note that this does not populate gPlacements, which is done lazily.
// The panel area is an exception here.
loadSavedState() {
@@ -2935,15 +2908,6 @@ var CustomizableUIInternal = {
}
},
deleteWidgetInSavedNavBarWhenVerticalTabsState(aWidgetId) {
const savedPlacements = this.getSavedVerticalSnapshotState();
let position = savedPlacements.indexOf(aWidgetId);
if (position != -1) {
savedPlacements.splice(position, 1);
this.saveNavBarWhenVerticalTabsState(savedPlacements);
}
},
saveHorizontalTabStripState(placements = []) {
if (!placements.length) {
placements = this.getAreaPlacementsForSaving(
@@ -2958,18 +2922,6 @@ var CustomizableUIInternal = {
);
},
saveNavBarWhenVerticalTabsState(placements = []) {
if (!placements.length) {
placements = this.getAreaPlacementsForSaving(CustomizableUI.AREA_NAVBAR);
}
let serialized = JSON.stringify(placements, this.serializerHelper);
lazy.log.debug("Saving vertical navbar state.", serialized);
Services.prefs.setCharPref(
kPrefCustomizationNavBarWhenVerticalTabs,
serialized
);
},
getAreaPlacementsForSaving(area) {
// An early call to saveState can occur before all the lazy-area building is complete
let placements;
@@ -4297,8 +4249,6 @@ var CustomizableUIInternal = {
}
CustomizableUI.beginBatchUpdate();
let customVerticalNavbarPlacements = this.getSavedVerticalSnapshotState();
let tabstripPlacements = this.getSavedHorizontalSnapshotState();
// Remove non-default widgets to the nav-bar
for (let id of CustomizableUI.getWidgetIdsInArea("TabsToolbar")) {
if (id == "tabbrowser-tabs") {
@@ -4308,13 +4258,6 @@ var CustomizableUIInternal = {
);
continue;
}
// We add the tab strip placements later in the case they have a custom position
if (
tabstripPlacements.includes(id) &&
customVerticalNavbarPlacements.includes(id)
) {
continue;
}
if (!CustomizableUI.isWidgetRemovable(id)) {
continue;
}
@@ -4325,16 +4268,10 @@ var CustomizableUIInternal = {
// Everything else gets moved to the nav-bar area while tabs are vertical
CustomizableUI.addWidgetToArea(id, CustomizableUI.AREA_NAVBAR);
}
// Remove new tab from nav-bar when vertical tabs enabled
// Remove new tab from AREA_NAVBAR when vertical tabs enabled.
this.removeWidgetFromArea("new-tab-button");
customVerticalNavbarPlacements.forEach((id, index) => {
if (tabstripPlacements.includes(id)) {
CustomizableUI.addWidgetToArea(id, CustomizableUI.AREA_NAVBAR, index);
}
});
CustomizableUI.endBatchUpdate();
} else {
this.saveNavBarWhenVerticalTabsState();
// We're switching to vertical in this session; pull saved state from pref and update placements
this.restoreSavedHorizontalTabStripState();
}