diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/urlbar/UrlbarView.sys.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/urlbar/UrlbarView.sys.mjs')
-rw-r--r-- | browser/components/urlbar/UrlbarView.sys.mjs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/components/urlbar/UrlbarView.sys.mjs b/browser/components/urlbar/UrlbarView.sys.mjs index 3d6ea46781..c5ea040f1f 100644 --- a/browser/components/urlbar/UrlbarView.sys.mjs +++ b/browser/components/urlbar/UrlbarView.sys.mjs @@ -1635,6 +1635,38 @@ export class UrlbarView { item.appendChild(button); } + #createSecondaryAction(action, global = false) { + let actionContainer = this.#createElement("div"); + actionContainer.classList.add("urlbarView-actions-container"); + + let button = this.#createElement("span"); + button.classList.add("urlbarView-action-btn"); + if (global) { + button.classList.add("urlbarView-global-action-btn"); + } + button.setAttribute("role", "button"); + if (action.icon) { + let icon = this.#createElement("img"); + icon.src = action.icon; + button.appendChild(icon); + } + for (let key in action.dataset ?? {}) { + button.dataset[key] = action.dataset[key]; + } + button.dataset.action = action.key; + button.dataset.providerName = action.providerName; + + let label = this.#createElement("span"); + if (action.l10nId) { + this.#setElementL10n(label, { id: action.l10nId, args: action.l10nArgs }); + } else { + this.document.l10n.setAttributes(label, action.label, action.l10nArgs); + } + button.appendChild(label); + actionContainer.appendChild(button); + return actionContainer; + } + // eslint-disable-next-line complexity #updateRow(item, result) { let oldResult = item.result; @@ -1707,6 +1739,26 @@ export class UrlbarView { } item._content.id = item.id + "-inner"; + let isFirstChild = item === this.#rows.children[0]; + let secAction = + result.heuristic || isFirstChild + ? lazy.UrlbarProvidersManager.getGlobalAction() + : result.payload.action; + let container = item.querySelector(".urlbarView-actions-container"); + if (secAction && !container) { + item.appendChild(this.#createSecondaryAction(secAction, isFirstChild)); + } else if ( + secAction && + secAction.key != container.firstChild.dataset.action + ) { + item.replaceChild( + this.#createSecondaryAction(secAction, isFirstChild), + container + ); + } else if (!secAction && container) { + item.removeChild(container); + } + item.removeAttribute("feedback-acknowledgment"); if ( @@ -1800,6 +1852,10 @@ export class UrlbarView { let isRowSelectable = true; switch (result.type) { case lazy.UrlbarUtils.RESULT_TYPE.TAB_SWITCH: + // Hide chichlet when showing secondaryActions. + if (lazy.UrlbarPrefs.get("secondaryActions.featureGate")) { + break; + } actionSetter = () => { this.#setSwitchTabActionChiclet(result, action); }; |