Files
desktop/src/browser/components/customizableui/CustomizableUI-sys-mjs.patch
2025-01-31 07:38:50 -08:00

170 lines
7.2 KiB
C++

diff --git a/browser/components/customizableui/CustomizableUI.sys.mjs b/browser/components/customizableui/CustomizableUI.sys.mjs
index e6b9b7dcfab179e7552c146eb1551b45ad042266..d9d838a7a51f67b52b69f419024cc3174ae5260b 100644
--- a/browser/components/customizableui/CustomizableUI.sys.mjs
+++ b/browser/components/customizableui/CustomizableUI.sys.mjs
@@ -13,6 +13,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
AddonManagerPrivate: "resource://gre/modules/AddonManager.sys.mjs",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.sys.mjs",
CustomizableWidgets: "resource:///modules/CustomizableWidgets.sys.mjs",
+ ZenCustomizableUI: "chrome://browser/content/ZenCustomizableUI.sys.mjs",
HomePage: "resource:///modules/HomePage.sys.mjs",
PanelMultiView: "resource:///modules/PanelMultiView.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
@@ -25,7 +26,7 @@ ChromeUtils.defineLazyGetter(lazy, "gWidgetsBundle", function () {
return Services.strings.createBundle(kUrl);
});
-const kDefaultThemeID = "default-theme@mozilla.org";
+const kDefaultThemeID = "firefox-compact-dark@mozilla.org";
const kSpecialWidgetPfx = "customizableui-special-";
@@ -317,13 +318,11 @@ var CustomizableUIInternal = {
"vertical-spacer",
"urlbar-container",
"spring",
- "save-to-pocket-button",
- "downloads-button",
+// "downloads-button",
AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
- "fxa-toolbar-menu-button",
lazy.resetPBMToolbarButtonEnabled ? "reset-pbm-toolbar-button" : null,
].filter(name => name);
-
+ lazy.ZenCustomizableUI.startup(this);
this.registerArea(
CustomizableUI.AREA_NAVBAR,
{
@@ -331,7 +330,6 @@ var CustomizableUIInternal = {
overflowable: true,
defaultPlacements: navbarPlacements,
verticalTabsDefaultPlacements: [
- "firefox-view-button",
"alltabs-button",
],
defaultCollapsed: false,
@@ -356,10 +354,7 @@ var CustomizableUIInternal = {
{
type: CustomizableUI.TYPE_TOOLBAR,
defaultPlacements: [
- "firefox-view-button",
"tabbrowser-tabs",
- "new-tab-button",
- "alltabs-button",
],
verticalTabsDefaultPlacements: [],
defaultCollapsed: null,
@@ -422,6 +417,7 @@ var CustomizableUIInternal = {
CustomizableUI.AREA_NAVBAR,
CustomizableUI.AREA_BOOKMARKS,
CustomizableUI.AREA_TABSTRIP,
+ "zen-sidebar-top-buttons",
]);
if (AppConstants.platform != "macosx") {
toolbars.add(CustomizableUI.AREA_MENUBAR);
@@ -1151,6 +1147,9 @@ var CustomizableUIInternal = {
placements = gPlacements.get(area);
}
+ // remove "zen-sidebar-top-buttons" from the placements
+ placements = placements.filter(p => p != "zen-sidebar-top-buttons");
+
// For toolbars that need it, mark as dirty.
let defaultPlacements = areaProperties.get("defaultPlacements");
if (
@@ -1564,7 +1563,7 @@ var CustomizableUIInternal = {
lazy.log.info(
"Widget " + aWidgetId + " not found, unable to remove from " + aArea
);
- continue;
+ // continue;
}
this.notifyDOMChange(widgetNode, null, container, true, () => {
@@ -1574,7 +1573,7 @@ var CustomizableUIInternal = {
// We also need to remove the panel context menu if it's there:
this.ensureButtonContextMenu(widgetNode);
if (gPalette.has(aWidgetId) || this.isSpecialWidget(aWidgetId)) {
- container.removeChild(widgetNode);
+ widgetNode.remove();
} else {
window.gNavToolbox.palette.appendChild(widgetNode);
}
@@ -2678,7 +2677,6 @@ var CustomizableUIInternal = {
if (!this.isWidgetRemovable(aWidgetId)) {
return;
}
-
let placements = gPlacements.get(oldPlacement.area);
let position = placements.indexOf(aWidgetId);
if (position != -1) {
@@ -3669,7 +3667,7 @@ var CustomizableUIInternal = {
}
},
- _rebuildRegisteredAreas() {
+ _rebuildRegisteredAreas(zenDontRebuildCollapsed = false) {
for (let [areaId, areaNodes] of gBuildAreas) {
let placements = gPlacements.get(areaId);
let isFirstChangedToolbar = true;
@@ -3680,7 +3678,7 @@ var CustomizableUIInternal = {
if (area.get("type") == CustomizableUI.TYPE_TOOLBAR) {
let defaultCollapsed = area.get("defaultCollapsed");
let win = areaNode.ownerGlobal;
- if (defaultCollapsed !== null) {
+ if (defaultCollapsed !== null && !zenDontRebuildCollapsed) {
win.setToolbarVisibility(
areaNode,
typeof defaultCollapsed == "string"
@@ -4658,6 +4656,7 @@ export var CustomizableUI = {
unregisterArea(aName, aDestroyPlacements) {
CustomizableUIInternal.unregisterArea(aName, aDestroyPlacements);
},
+ get zenInternalCU() { return CustomizableUIInternal; },
/**
* Add a widget to an area.
* If the area to which you try to add is not known to CustomizableUI,
@@ -6483,11 +6482,11 @@ class OverflowableToolbar {
parseFloat(style.paddingLeft) -
parseFloat(style.paddingRight) -
toolbarChildrenWidth;
- targetWidth = getInlineSize(this.#target);
+ targetWidth = getInlineSize(this.#target) - ((win.gZenVerticalTabsManager._hasSetSingleToolbar && this.#target.id == 'zen-sidebar-top-buttons-customization-target') ? win.gZenVerticalTabsManager._topButtonsSeparatorElement.getBoundingClientRect().width : 0);
targetChildrenWidth =
this.#target == this.#toolbar
? toolbarChildrenWidth
- : sumChildrenInlineSize(this.#target);
+ : sumChildrenInlineSize(this.#target, win.gZenVerticalTabsManager._topButtonsSeparatorElement);
});
lazy.log.debug(
@@ -6497,7 +6496,8 @@ class OverflowableToolbar {
// If the target has min-width: 0, their children might actually overflow
// it, so check for both cases explicitly.
let targetContentWidth = Math.max(targetWidth, targetChildrenWidth);
- let isOverflowing = Math.floor(targetContentWidth) > totalAvailWidth;
+ if (win.gZenVerticalTabsManager._hasSetSingleToolbar && this.#toolbar.id == 'nav-bar') return { isOverflowing: false, targetContentWidth, totalAvailWidth };
+ let isOverflowing = Math.floor(targetContentWidth) + (win.gZenVerticalTabsManager._hasSetSingleToolbar ? 0.1 : 0) > totalAvailWidth;
return { isOverflowing, targetContentWidth, totalAvailWidth };
}
@@ -6591,7 +6591,7 @@ class OverflowableToolbar {
}
}
if (!inserted) {
- this.#target.appendChild(child);
+ win.gZenVerticalTabsManager.appendCustomizableItem(this.#target, child, gPlacements.get(this.#toolbar.id));
}
child.removeAttribute("cui-anchorid");
child.removeAttribute("overflowedItem");
@@ -6753,6 +6753,9 @@ class OverflowableToolbar {
* @param {MouseEvent} aEvent the click event.
*/
#onClickDefaultListButton(aEvent) {
+ if (aEvent.view.gZenVerticalTabsManager._hasSetSingleToolbar && this.#toolbar.id == 'nav-bar') {
+ return;
+ }
if (this.#defaultListButton.open) {
this.#defaultListButton.open = false;
lazy.PanelMultiView.hidePopup(this.#defaultListPanel);