mirror of
https://github.com/zen-browser/desktop
synced 2026-04-26 01:25:02 +02:00
chore: Sync upstream Firefox to version 147.0, p=#11822
* chore: Sync upstream to `Firefox 147.0` * chore: Continued migration, b=no-bug, c=tests * chore: Finish migration without testing, b=no-bug, c=scripts, tabs, media, common, split-view * feat: Finish migration, b=no-bug, c=common, compact-mode, split-view, workspaces * feat: Finish basic migration, b=no-bug, c=kbs, common, folders * feat: Update surfer, b=no-bug, c=scripts
This commit is contained in:
336
src/browser/components/urlbar/content/UrlbarInput-mjs.patch
Normal file
336
src/browser/components/urlbar/content/UrlbarInput-mjs.patch
Normal file
@@ -0,0 +1,336 @@
|
||||
diff --git a/browser/components/urlbar/content/UrlbarInput.mjs b/browser/components/urlbar/content/UrlbarInput.mjs
|
||||
index edb0482f0bfb22c70a585b0770e5b0437983779e..545f65db4fe8b807b388d5552842cd9e56a72eb3 100644
|
||||
--- a/browser/components/urlbar/content/UrlbarInput.mjs
|
||||
+++ b/browser/components/urlbar/content/UrlbarInput.mjs
|
||||
@@ -68,6 +68,13 @@ const lazy = XPCOMUtils.declareLazy({
|
||||
logger: () => lazy.UrlbarUtils.getLogger({ prefix: "Input" }),
|
||||
});
|
||||
|
||||
+XPCOMUtils.defineLazyPreferenceGetter(
|
||||
+ lazy,
|
||||
+ "ZEN_URLBAR_BEHAVIOR",
|
||||
+ "zen.urlbar.behavior",
|
||||
+ 'default'
|
||||
+);
|
||||
+
|
||||
const UNLIMITED_MAX_RESULTS = 99;
|
||||
|
||||
let getBoundsWithoutFlushing = element =>
|
||||
@@ -630,7 +637,16 @@ export class UrlbarInput extends HTMLElement {
|
||||
// See _on_select(). HTMLInputElement.select() dispatches a "select"
|
||||
// event but does not set the primary selection.
|
||||
this._suppressPrimaryAdjustment = true;
|
||||
+ const zenToolbox = this.document.getElementById("navigator-toolbox");
|
||||
+ this.window.document.documentElement.setAttribute("supress-primary-adjustment", !(
|
||||
+ zenToolbox.hasAttribute("zen-has-hover") ||
|
||||
+ zenToolbox.hasAttribute("zen-has-empty-tab") ||
|
||||
+ zenToolbox.hasAttribute("zen-user-show")
|
||||
+ ));
|
||||
this.inputField.select();
|
||||
+ this.document.ownerGlobal.setTimeout(() => {
|
||||
+ this.window.document.documentElement.removeAttribute("supress-primary-adjustment");
|
||||
+ }, 0);
|
||||
this._suppressPrimaryAdjustment = false;
|
||||
}
|
||||
|
||||
@@ -704,6 +720,10 @@ export class UrlbarInput extends HTMLElement {
|
||||
hideSearchTerms = false,
|
||||
isSameDocument = false,
|
||||
} = {}) {
|
||||
+ if (this.hasAttribute("zen-newtab")) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (!this.#isAddressbar) {
|
||||
throw new Error(
|
||||
"Cannot set URI for UrlbarInput that is not an address bar"
|
||||
@@ -985,8 +1005,16 @@ export class UrlbarInput extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
}
|
||||
-
|
||||
+ const zenToolbox = this.document.getElementById("navigator-toolbox");
|
||||
+ this.window.document.documentElement.setAttribute("supress-primary-adjustment", !(
|
||||
+ zenToolbox.hasAttribute("zen-has-hover") ||
|
||||
+ zenToolbox.hasAttribute("zen-has-empty-tab") ||
|
||||
+ zenToolbox.hasAttribute("zen-user-show")
|
||||
+ ));
|
||||
this.handleNavigation({ event });
|
||||
+ this.document.ownerGlobal.setTimeout(() => {
|
||||
+ this.window.document.documentElement.removeAttribute("supress-primary-adjustment");
|
||||
+ }, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1405,7 +1433,11 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
|
||||
if (!this.#providesSearchMode(result)) {
|
||||
- this.view.close({ elementPicked: true });
|
||||
+ if (this._zenHandleUrlbarClose) {
|
||||
+ this._zenHandleUrlbarClose(true, true);
|
||||
+ } else {
|
||||
+ this.window.setTimeout(() => this.view.close({ elementPicked: true }), 0);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (isCanonized) {
|
||||
@@ -2529,6 +2561,32 @@ export class UrlbarInput extends HTMLElement {
|
||||
await this.#updateLayoutBreakoutDimensions();
|
||||
}
|
||||
|
||||
+ zenFormatURLValue() {
|
||||
+ return this.#lazy.valueFormatter._formatURL();
|
||||
+ }
|
||||
+
|
||||
+ get zenUrlbarBehavior() {
|
||||
+ if (this.document.documentElement.hasAttribute("inDOMFullscreen")) {
|
||||
+ return "float";
|
||||
+ }
|
||||
+ return lazy.ZEN_URLBAR_BEHAVIOR;
|
||||
+ }
|
||||
+
|
||||
+ get zenStrippedURI() {
|
||||
+ let strippedURI = null;
|
||||
+
|
||||
+ // Error check occurs during isClipboardURIValid
|
||||
+ let uri = this.window.gBrowser.currentURI;
|
||||
+ try {
|
||||
+ strippedURI = lazy.QueryStringStripper.stripForCopyOrShare(uri);
|
||||
+ } catch (e) {
|
||||
+ console.warn(`stripForCopyOrShare: ${e.message}`);
|
||||
+ return [uri, lazy.ClipboardHelper];
|
||||
+ }
|
||||
+
|
||||
+ return [strippedURI ? this.makeURIReadable(strippedURI) : uri, lazy.ClipboardHelper];
|
||||
+ }
|
||||
+
|
||||
startLayoutExtend() {
|
||||
if (!this.#allowBreakout || this.hasAttribute("breakout-extend")) {
|
||||
// Do not expand if the Urlbar does not support being expanded or it is
|
||||
@@ -2543,6 +2601,13 @@ export class UrlbarInput extends HTMLElement {
|
||||
|
||||
this.setAttribute("breakout-extend", "true");
|
||||
|
||||
+ this.window.gZenUIManager.onUrlbarOpen();
|
||||
+ if (this.zenUrlbarBehavior == 'float' || (this.zenUrlbarBehavior == 'floating-on-type' && !this.focusedViaMousedown)) {
|
||||
+ this.setAttribute("zen-floating-urlbar", "true");
|
||||
+ this.window.gZenUIManager.onFloatingURLBarOpen();
|
||||
+ } else {
|
||||
+ this.removeAttribute("zen-floating-urlbar");
|
||||
+ }
|
||||
// Enable the animation only after the first extend call to ensure it
|
||||
// doesn't run when opening a new window.
|
||||
if (!this.hasAttribute("breakout-extend-animate")) {
|
||||
@@ -2562,6 +2627,24 @@ export class UrlbarInput extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (this._zenHandleUrlbarClose) {
|
||||
+ this._zenHandleUrlbarClose();
|
||||
+ }
|
||||
+
|
||||
+ // Arc like URLbar: Blur the input on exit
|
||||
+ const zenToolbox = this.document.getElementById("navigator-toolbox");
|
||||
+ this.window.document.documentElement.setAttribute("supress-primary-adjustment", !(
|
||||
+ zenToolbox.hasAttribute("zen-has-hover") ||
|
||||
+ zenToolbox.hasAttribute("zen-has-empty-tab") ||
|
||||
+ zenToolbox.hasAttribute("zen-user-show")
|
||||
+ ));
|
||||
+ this.window.gBrowser.selectedBrowser.focus();
|
||||
+ this.document.ownerGlobal.setTimeout(() => {
|
||||
+ this.window.document.documentElement.removeAttribute("supress-primary-adjustment");
|
||||
+ }, 100);
|
||||
+ this.window.gZenUIManager.onUrlbarClose();
|
||||
+ this.removeAttribute("zen-floating-urlbar");
|
||||
+
|
||||
this.removeAttribute("breakout-extend");
|
||||
this.#updateTextboxPosition();
|
||||
}
|
||||
@@ -2592,7 +2675,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
forceUnifiedSearchButtonAvailable = false
|
||||
) {
|
||||
let prevState = this.getAttribute("pageproxystate");
|
||||
-
|
||||
+ this.removeAttribute("had-proxystate");
|
||||
this.setAttribute("pageproxystate", state);
|
||||
this._inputContainer.setAttribute("pageproxystate", state);
|
||||
this._identityBox?.setAttribute("pageproxystate", state);
|
||||
@@ -2846,10 +2929,12 @@ export class UrlbarInput extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
this.style.top = px(
|
||||
+ this.window.gZenVerticalTabsManager._hasSetSingleToolbar ?
|
||||
this.parentNode.getBoxQuads({
|
||||
ignoreTransforms: true,
|
||||
flush: false,
|
||||
})[0].p1.y
|
||||
+ : (AppConstants.platform == "macosx" ? -2 : -5)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2908,9 +2993,10 @@ export class UrlbarInput extends HTMLElement {
|
||||
return;
|
||||
}
|
||||
|
||||
+ this.window.gZenVerticalTabsManager.recalculateURLBarHeight();
|
||||
this.parentNode.style.setProperty(
|
||||
"--urlbar-container-height",
|
||||
- px(getBoundsWithoutFlushing(this.parentNode).height)
|
||||
+ px(getBoundsWithoutFlushing(this.parentNode).height + 8)
|
||||
);
|
||||
this.style.setProperty(
|
||||
"--urlbar-height",
|
||||
@@ -3344,6 +3430,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
|
||||
_toggleActionOverride(event) {
|
||||
+ if (!Services.prefs.getBoolPref("zen.urlbar.enable-overrides")) return;
|
||||
if (
|
||||
event.keyCode == KeyEvent.DOM_VK_SHIFT ||
|
||||
event.keyCode == KeyEvent.DOM_VK_ALT ||
|
||||
@@ -3447,8 +3534,8 @@ export class UrlbarInput extends HTMLElement {
|
||||
if (!this.#isAddressbar) {
|
||||
return val;
|
||||
}
|
||||
- let trimmedValue = lazy.UrlbarPrefs.get("trimURLs")
|
||||
- ? lazy.BrowserUIUtils.trimURL(val)
|
||||
+ let trimmedValue = lazy.UrlbarPrefs.get("trimURLs") && this._zenTrimURL
|
||||
+ ? this._zenTrimURL(val)
|
||||
: val;
|
||||
// Only trim value if the directionality doesn't change to RTL and we're not
|
||||
// showing a strikeout https protocol.
|
||||
@@ -3754,6 +3841,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
resultDetails = null,
|
||||
browser = this.window.gBrowser.selectedBrowser
|
||||
) {
|
||||
+ openUILinkWhere = this.window.gZenUIManager.getOpenUILinkWhere(url, browser, openUILinkWhere);
|
||||
if (this.#isAddressbar) {
|
||||
this.#prepareAddressbarLoad(
|
||||
url,
|
||||
@@ -3861,6 +3949,10 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
reuseEmpty = true;
|
||||
}
|
||||
+ if (this.hasAttribute("zen-newtab")) {
|
||||
+ where = "tab";
|
||||
+ reuseEmpty = true;
|
||||
+ }
|
||||
if (
|
||||
where == "tab" &&
|
||||
reuseEmpty &&
|
||||
@@ -3868,6 +3960,9 @@ export class UrlbarInput extends HTMLElement {
|
||||
) {
|
||||
where = "current";
|
||||
}
|
||||
+ if (this.window.gBrowser.selectedTab.hasAttribute("zen-empty-tab")) {
|
||||
+ return "tab"; // Always open in a new tab if the current tab is "our empty tab".
|
||||
+ }
|
||||
return where;
|
||||
}
|
||||
|
||||
@@ -4122,6 +4217,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
this.setResultForCurrentValue(null);
|
||||
this.handleCommand();
|
||||
this.controller.clearLastQueryContextCache();
|
||||
+ this.view.close();
|
||||
|
||||
this._suppressStartQuery = false;
|
||||
});
|
||||
@@ -4129,7 +4225,6 @@ export class UrlbarInput extends HTMLElement {
|
||||
contextMenu.addEventListener("popupshowing", () => {
|
||||
// Close the results pane when the input field contextual menu is open,
|
||||
// because paste and go doesn't want a result selection.
|
||||
- this.view.close();
|
||||
|
||||
let controller =
|
||||
this.document.commandDispatcher.getControllerForCommand("cmd_paste");
|
||||
@@ -4239,7 +4334,11 @@ export class UrlbarInput extends HTMLElement {
|
||||
if (!engineName && !source && !this.hasAttribute("searchmode")) {
|
||||
return;
|
||||
}
|
||||
-
|
||||
+ this.window.dispatchEvent(
|
||||
+ new CustomEvent("Zen:UrlbarSearchModeChanged", {
|
||||
+ detail: { searchMode },
|
||||
+ })
|
||||
+ );
|
||||
if (this._searchModeIndicatorTitle) {
|
||||
this._searchModeIndicatorTitle.textContent = "";
|
||||
this._searchModeIndicatorTitle.removeAttribute("data-l10n-id");
|
||||
@@ -4549,6 +4648,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
|
||||
this.document.l10n.setAttributes(
|
||||
this.inputField,
|
||||
+ this.window.gZenVerticalTabsManager._hasSetSingleToolbar ? 'zen-singletoolbar-urlbar-placeholder-with-name' :
|
||||
l10nId,
|
||||
l10nId == "urlbar-placeholder-with-name"
|
||||
? { name: engineName }
|
||||
@@ -4662,6 +4762,11 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
|
||||
_on_click(event) {
|
||||
+ if (event.target == this.inputField) {
|
||||
+ event.zenOriginalTarget = this;
|
||||
+ this._on_mousedown(event);
|
||||
+ }
|
||||
+
|
||||
switch (event.target) {
|
||||
case this.inputField:
|
||||
case this._inputContainer:
|
||||
@@ -4740,7 +4845,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.focusedViaMousedown) {
|
||||
+ if (this.focusedViaMousedown || this.hasAttribute("zen-newtab")) {
|
||||
this.view.autoOpen({ event });
|
||||
} else {
|
||||
if (this._untrimOnFocusAfterKeydown) {
|
||||
@@ -4780,9 +4885,16 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
|
||||
_on_mousedown(event) {
|
||||
- switch (event.currentTarget) {
|
||||
+ switch (event.zenOriginalTarget || event.currentTarget) {
|
||||
case this: {
|
||||
this._mousedownOnUrlbarDescendant = true;
|
||||
+ const isProbablyFloating =
|
||||
+ (this.zenUrlbarBehavior == "floating-on-type" &&
|
||||
+ this.hasAttribute("breakout-extend") && !this.focusedViaMousedown) ||
|
||||
+ (this.zenUrlbarBehavior == "float") || this.window.gZenVerticalTabsManager._hasSetSingleToolbar;
|
||||
+ if (event.type != "click" && isProbablyFloating || event.type == "click" && !isProbablyFloating) {
|
||||
+ return true;
|
||||
+ }
|
||||
if (
|
||||
event.composedTarget != this.inputField &&
|
||||
event.composedTarget != this._inputContainer
|
||||
@@ -4792,6 +4904,10 @@ export class UrlbarInput extends HTMLElement {
|
||||
|
||||
this.focusedViaMousedown = !this.focused;
|
||||
this._preventClickSelectsAll = this.focused;
|
||||
+ if (isProbablyFloating) {
|
||||
+ this.focusedViaMousedown = !this.hasAttribute("breakout-extend");
|
||||
+ this._preventClickSelectsAll = this.hasAttribute("breakout-extend");
|
||||
+ }
|
||||
|
||||
// Keep the focus status, since the attribute may be changed
|
||||
// upon calling this.focus().
|
||||
@@ -4827,7 +4943,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
}
|
||||
// Don't close the view when clicking on a tab; we may want to keep the
|
||||
// view open on tab switch, and the TabSelect event arrived earlier.
|
||||
- if (event.target.closest("tab")) {
|
||||
+ if (event.target.closest("tab") || event.target.closest("#tabs-newtab-button")) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5155,7 +5271,7 @@ export class UrlbarInput extends HTMLElement {
|
||||
// When we are in actions search mode we can show more results so
|
||||
// increase the limit.
|
||||
let maxResults =
|
||||
- this.searchMode?.source != lazy.UrlbarUtils.RESULT_SOURCE.ACTIONS
|
||||
+ this.searchMode?.source != lazy.UrlbarUtils.RESULT_SOURCE.ZEN_ACTIONS
|
||||
? lazy.UrlbarPrefs.get("maxRichResults")
|
||||
: UNLIMITED_MAX_RESULTS;
|
||||
let options = {
|
||||
Reference in New Issue
Block a user