gh-13796: Fix tab order reversing on dnd & boosts window size / initial color state (gh-13799)

Co-authored-by: Mr. M <mr.m@tuta.com>
Signed-off-by: fen4flo <75260616+FlorianButz@users.noreply.github.com>
This commit is contained in:
fen4flo
2026-05-22 17:31:25 +02:00
committed by GitHub
parent cd1616d1c0
commit 7196527509
8 changed files with 140 additions and 103 deletions

View File

@@ -44,3 +44,10 @@
- name: browser.taskbarTabs.enabled
value: false
- name: browser.contentblocking.report.hide_vpn_banner
value: true
locked: true
- name: browser.vpn_promo.enabled
value: false

View File

@@ -65,6 +65,7 @@ export class nsZenBoostEditor {
once: true,
});
this.doc.getElementById("zenBoostWindow").setAttribute("editor", "boost");
this.doc.getElementById("zen-boost-editor-root").style.display = "flex";
this.doc.getElementById("zen-boost-code-editor-root").style.display =
"none";
@@ -366,20 +367,22 @@ export class nsZenBoostEditor {
// being smaller than it should be
this._boostEditorWidth = this.editorWindow.outerWidth;
this.editorWindow.resizeTo(
this._codeEditorWidth,
this.editorWindow.outerHeight
);
if (openRightAligned) {
this.editorWindow.moveTo(
this.editorWindow.screenX - offset,
this.editorWindow.screenY
this.editorWindow.requestAnimationFrame(() => {
this.editorWindow.resizeTo(
this._codeEditorWidth,
this.editorWindow.outerHeight
);
}
if (openRightAligned) {
this.editorWindow.moveTo(
this.editorWindow.screenX - offset,
this.editorWindow.screenY
);
}
this.doc.getElementById("zen-boost-editor-root").style.display = "none";
this.doc.getElementById("zen-boost-code-editor-root").style.display =
"initial";
this.doc.getElementById("zen-boost-editor-root").style.display = "none";
this.doc.getElementById("zen-boost-code-editor-root").style.display =
"initial";
});
}
/**
@@ -397,20 +400,22 @@ export class nsZenBoostEditor {
}
windowElem.setAttribute("editor", "boost");
this.editorWindow.resizeTo(
this._boostEditorWidth,
this.editorWindow.outerHeight
);
if (openRightAligned) {
this.editorWindow.moveTo(
this.editorWindow.screenX + offset,
this.editorWindow.screenY
this.editorWindow.requestAnimationFrame(() => {
this.editorWindow.resizeTo(
this._boostEditorWidth,
this.editorWindow.outerHeight
);
}
if (openRightAligned) {
this.editorWindow.moveTo(
this.editorWindow.screenX + offset,
this.editorWindow.screenY
);
}
this.doc.getElementById("zen-boost-editor-root").style.display = "flex";
this.doc.getElementById("zen-boost-code-editor-root").style.display =
"none";
this.doc.getElementById("zen-boost-editor-root").style.display = "flex";
this.doc.getElementById("zen-boost-code-editor-root").style.display =
"none";
});
// Disable picker mode
this.disableAllPickers();
@@ -564,6 +569,9 @@ ${cssSelector} {
this.wasDragging = true;
event.preventDefault();
this.currentBoostData.changeWasMade = true;
this.updateButtonToggleVisuals();
if (this.dragTarget == "zen-boost-color-picker-dot-secondary") {
this.setSecondaryDotPos(event.clientX, event.clientY);
} else if (event.target.id != "zen-boost-magic-theme") {
@@ -670,20 +678,6 @@ ${cssSelector} {
panel.openPopup(event.target, "bottomcenter topcenter", 0, 2);
}
/**
* Resets the color picker dot to the default position (default state).
*/
resetDotPosition() {
const gradient = this.doc.querySelector(".zen-boost-color-picker-gradient");
const rect = gradient.getBoundingClientRect();
const padding = 50;
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
const radius = (rect.width - padding) / 2;
this.setDotPos(centerX + radius / 1.25, centerY);
}
/**
* Handles clicks on the theme picker gradient or magic theme button.
* Updates the dot position or toggles auto-theme mode based on the click target.
@@ -695,14 +689,16 @@ ${cssSelector} {
this.currentBoostData.changeWasMade = true;
this.currentBoostData.enableColorBoost = true;
this.updateButtonToggleVisuals();
if (event.target.id == "zen-boost-magic-theme") {
this.currentBoostData.enableColorBoost = true;
this.currentBoostData.autoTheme = !this.currentBoostData.autoTheme;
this.updateButtonToggleVisuals();
this.updateCurrentBoost();
} else if (this.dragTarget != "zen-boost-color-picker-dot-secondary") {
this.setDotPos(event.clientX, event.clientY, !this.wasDragging);
}
this.wasDragging = false;
}
@@ -1310,6 +1306,23 @@ ${cssSelector} {
const resetBoost = this.doc.getElementById("zen-boost-edit-reset");
const popup = this.doc.getElementById("zenBoostContextMenu");
popup.addEventListener(
"popupshown",
() => {
// Don't give the user following options if the boost
// is not going to save / not currently saved (unchanged)
let shouldDisable = !this.currentBoostData.changeWasMade;
const items = [renameBoost, deleteBoost, resetBoost];
for (let item of items) {
if (shouldDisable) {
item.setAttribute("disabled", "");
} else {
item.removeAttribute("disabled");
}
}
},
{ once: true }
);
popup.openPopup(
event.target,
"bottomcenter topcenter",
@@ -1319,12 +1332,6 @@ ${cssSelector} {
false /* attributesOverride */,
event
);
// Don't give the user following options if the boost
// is not going to save / not currently saved (unchanged)
renameBoost.disabled = !this.currentBoostData.changeWasMade;
deleteBoost.disabled = !this.currentBoostData.changeWasMade;
resetBoost.disabled = !this.currentBoostData.changeWasMade;
}
/**
@@ -1566,44 +1573,32 @@ ${cssSelector} {
}
if (
this.currentBoostData.dotPos.x == null ||
this.currentBoostData.dotPos.y == null
) {
this.resetDotPosition();
} else {
// Test if the stored position is a non-normalized dot position
if (
this.currentBoostData.dotPos.x > 1 ||
this.currentBoostData.dotPos.x < 0 ||
this.currentBoostData.dotPos.y > 1 ||
this.currentBoostData.dotPos.y < 0
) {
// Normalize position
this.currentBoostData.dotPos.x =
this.currentBoostData.dotPos.x / rect.width;
this.currentBoostData.dotPos.y =
this.currentBoostData.dotPos.y / rect.height;
}
// Convert normalized position to relative position
const xPos = this.currentBoostData.dotPos.x * rect.width;
const yPos = this.currentBoostData.dotPos.y * rect.height;
dot.style.left = `${xPos}px`;
dot.style.top = `${yPos}px`;
}
if (
this.currentBoostData.secondaryDotPos?.x != null &&
this.currentBoostData.secondaryDotPos?.y != null
this.currentBoostData.dotPos.x > 1 ||
this.currentBoostData.dotPos.x < 0 ||
this.currentBoostData.dotPos.y > 1 ||
this.currentBoostData.dotPos.y < 0
) {
const xPosSec = this.currentBoostData.secondaryDotPos.x * rect.width;
const yPosSec = this.currentBoostData.secondaryDotPos.y * rect.height;
dotSec.style.left = `${xPosSec}px`;
dotSec.style.top = `${yPosSec}px`;
// Normalize position
this.currentBoostData.dotPos.x =
this.currentBoostData.dotPos.x / rect.width;
this.currentBoostData.dotPos.y =
this.currentBoostData.dotPos.y / rect.height;
}
// Convert normalized position to relative position
const xPos = this.currentBoostData.dotPos.x * rect.width;
const yPos = this.currentBoostData.dotPos.y * rect.height;
dot.style.left = `${xPos}px`;
dot.style.top = `${yPos}px`;
const xPosSec = this.currentBoostData.secondaryDotPos.x * rect.width;
const yPosSec = this.currentBoostData.secondaryDotPos.y * rect.height;
dotSec.style.left = `${xPosSec}px`;
dotSec.style.top = `${yPosSec}px`;
this.editorWindow._editor.setText(this.currentBoostData.customCSS || "");
this.updateFontButtonVisuals();

View File

@@ -115,11 +115,11 @@ class nsZenBoostsManager {
boostName: "My Boost",
dotAngleDeg: 0,
dotPos: { x: null, y: null },
dotPos: { x: 0.76, y: 0.66 },
dotDistance: 0,
secondaryDotAngleDegDelta: 55,
secondaryDotPos: { x: null, y: null },
secondaryDotPos: { x: 0.5, y: 0.81 },
brightness: 0.5,
saturation: 0.5,
@@ -559,7 +559,8 @@ class nsZenBoostsManager {
const domainEntry = this.#getDomainEntry(domain);
if (domainEntry) {
return domainEntry.boostEntries.has(domainEntry.activeBoostId);
const boost = this.loadActiveBoostFromStore(domain);
return boost?.boostEntry.boostData.changeWasMade ?? false;
}
return false;

View File

@@ -367,7 +367,14 @@ export class ZenBoostsChild extends JSWindowActorChild {
this.#loadStyleSheet(boost.styleSheet);
}
browsingContext.fullZoom = boostData.sizeOverride;
if (
boostData.sizeOverride &&
isFinite(boostData.sizeOverride) &&
boostData.sizeOverride !== 1
) {
browsingContext.fullZoom = boostData.sizeOverride;
}
browsingContext.isZenBoostsInverted = boostData.smartInvert;
if (boostData.enableColorBoost) {
let primaryColor;
@@ -390,17 +397,17 @@ export class ZenBoostsChild extends JSWindowActorChild {
// using the same modifiers as the color above
primaryColor = this.#buildBoostColor(
primaryGradientColor[0],
primaryGradientColor[1] * (1 - boostData.saturation),
0.1 + primaryGradientColor[2] * 0.9 * boostData.brightness,
1 - boostData.saturation,
0.1 + 0.9 * boostData.brightness,
boostData
);
} else {
primaryColor = this.#buildBoostColor(
boostData.dotAngleDeg,
/* already is [0, 1] */
boostData.dotDistance * (1 - boostData.saturation),
1 - boostData.saturation,
/* lightness range from [0.1, 0.9] */
0.1 + boostData.dotDistance * 0.8 * boostData.brightness,
0.1 + 0.9 * boostData.brightness,
boostData
);
}

View File

@@ -359,15 +359,24 @@ inline static nscolor zenInvertColorChannel(nscolor aColor) {
const auto gShifted = sum - gInv;
const auto bShifted = sum - bInv;
// Compress the channel range into [FLOOR, 255] so dark inversions are
// lifted while light inversions are left untouched. This preserves hue
// since all three channels are scaled by the same factor.
// If the resulting color is light, leave it untouched: mixing in the floor
// would raise its lowest channel and wash the color out toward grey. Only
// dark results get the floor lift, which keeps them off pure black.
const auto luma = (rShifted * 54 + gShifted * 183 + bShifted * 19) >> 8;
if (luma > 127) {
return NS_RGBA(static_cast<uint8_t>(rShifted),
static_cast<uint8_t>(gShifted),
static_cast<uint8_t>(bShifted), a);
}
// Compress the dark channel range into [FLOOR, 255] so dark inversions are
// lifted off pure black. This preserves hue since all three channels are
// scaled by the same factor.
const auto channelFloor = INVERT_CHANNEL_FLOOR();
const uint32_t range = 255 - channelFloor;
const auto lift = [channelFloor, range](uint8_t c) -> uint8_t {
return static_cast<uint8_t>(channelFloor + (c * range) / 255);
};
return NS_RGBA(lift(rShifted), lift(gShifted), lift(bShifted), a);
}

View File

@@ -132,18 +132,18 @@
<html:input id="zen-boost-color-saturation" type="range" min="0" max="1" value="0.5" step="0.01"/>
</vbox>
</panel>
</popupset>
<menupopup id="zenBoostContextMenu">
<menuitem data-l10n-id="zen-boost-edit-rename" id="zen-boost-edit-rename" command="cmd_zenBoostEditName" />
<menuitem data-l10n-id="zen-boost-edit-shuffle" id="zen-boost-edit-shuffle" command="cmd_zenBoostShuffle" />
<menuitem data-l10n-id="zen-boost-edit-reset" id="zen-boost-edit-reset" command="cmd_zenBoostReset" />
<menuseparator/>
<menuitem data-l10n-id="zen-boost-load" id="zen-boost-load" command="cmd_zenBoostLoad" />
<menuitem data-l10n-id="zen-boost-save" id="zen-boost-save" command="cmd_zenBoostSave" />
<menuseparator/>
<menuitem data-l10n-id="zen-boost-edit-delete" id="zen-boost-edit-delete" command="cmd_zenBoostDelete" />
</menupopup>
<menupopup id="zenBoostContextMenu">
<menuitem data-l10n-id="zen-boost-edit-rename" id="zen-boost-edit-rename" command="cmd_zenBoostEditName" />
<menuitem data-l10n-id="zen-boost-edit-shuffle" id="zen-boost-edit-shuffle" command="cmd_zenBoostShuffle" />
<menuitem data-l10n-id="zen-boost-edit-reset" id="zen-boost-edit-reset" command="cmd_zenBoostReset" />
<menuseparator/>
<menuitem data-l10n-id="zen-boost-load" id="zen-boost-load" command="cmd_zenBoostLoad" />
<menuitem data-l10n-id="zen-boost-save" id="zen-boost-save" command="cmd_zenBoostSave" />
<menuseparator/>
<menuitem data-l10n-id="zen-boost-edit-delete" id="zen-boost-edit-delete" command="cmd_zenBoostDelete" />
</menupopup>
</popupset>
<commandset id="zenBoostCommandSet">
<command id="cmd_zenBoostEditName"

View File

@@ -11,6 +11,19 @@
}
appearance: none;
border: none;
min-height: 582px;
max-height: 582px;
}
#zenBoostWindow[editor="boost"] {
min-width: 192px;
max-width: 192px;
}
#zenBoostWindow[editor="code"] {
min-width: 452px;
max-width: 452px;
}
.source-editor-frame {
@@ -540,6 +553,7 @@ body {
height: 26px;
width: 26px;
transform-origin: center center;
aspect-ratio: 1;
&:hover {
background-color: #9a9a9a30;

View File

@@ -702,6 +702,10 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
}
return tab;
});
if (!fromDifferentWindow) {
// See gh-13796 and gh-12156
ownedTabs = ownedTabs.reverse();
}
movingTabs = [...ownedTabs];
if (fromDifferentWindow) {
gBrowser.addRangeToMultiSelectedTabs(