diff --git a/prefs/privatefox/disablemozilla.yaml b/prefs/privatefox/disablemozilla.yaml index 41b7d06e7..e974e977b 100644 --- a/prefs/privatefox/disablemozilla.yaml +++ b/prefs/privatefox/disablemozilla.yaml @@ -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 diff --git a/src/zen/boosts/ZenBoostsEditor.mjs b/src/zen/boosts/ZenBoostsEditor.mjs index 1708ca752..f362abe13 100644 --- a/src/zen/boosts/ZenBoostsEditor.mjs +++ b/src/zen/boosts/ZenBoostsEditor.mjs @@ -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(); diff --git a/src/zen/boosts/ZenBoostsManager.sys.mjs b/src/zen/boosts/ZenBoostsManager.sys.mjs index 0525b5378..b9bb534ed 100644 --- a/src/zen/boosts/ZenBoostsManager.sys.mjs +++ b/src/zen/boosts/ZenBoostsManager.sys.mjs @@ -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; diff --git a/src/zen/boosts/actors/ZenBoostsChild.sys.mjs b/src/zen/boosts/actors/ZenBoostsChild.sys.mjs index 78260f30a..637d81909 100644 --- a/src/zen/boosts/actors/ZenBoostsChild.sys.mjs +++ b/src/zen/boosts/actors/ZenBoostsChild.sys.mjs @@ -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 ); } diff --git a/src/zen/boosts/nsZenBoostsBackend.cpp b/src/zen/boosts/nsZenBoostsBackend.cpp index 1a54b0264..b94e2890f 100644 --- a/src/zen/boosts/nsZenBoostsBackend.cpp +++ b/src/zen/boosts/nsZenBoostsBackend.cpp @@ -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(rShifted), + static_cast(gShifted), + static_cast(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(channelFloor + (c * range) / 255); }; - return NS_RGBA(lift(rShifted), lift(gShifted), lift(bShifted), a); } diff --git a/src/zen/boosts/zen-boost-editor.inc.xhtml b/src/zen/boosts/zen-boost-editor.inc.xhtml index 508dc9c42..15c75f57c 100644 --- a/src/zen/boosts/zen-boost-editor.inc.xhtml +++ b/src/zen/boosts/zen-boost-editor.inc.xhtml @@ -132,18 +132,18 @@ - - - - - - - - - - - + + + + + + + + + + +