feat: New urlbar actions, c=common, p=#10340

This commit is contained in:
mr. m
2025-09-13 01:35:38 +02:00
committed by GitHub
parent 0fcc3f7c0e
commit 9ce963f1cd
37 changed files with 541 additions and 21 deletions

View File

@@ -22,3 +22,8 @@
- name: zen.urlbar.enable-overrides
value: false
# Mark: Zen suggestions controls
- name: zen.urlbar.suggestions.quick-actions
value: true

View File

@@ -8,7 +8,6 @@
content/browser/zen-sets.js (../../zen/common/zen-sets.js)
content/browser/ZenUIManager.mjs (../../zen/common/ZenUIManager.mjs)
content/browser/zen-components/ZenActorsManager.mjs (../../zen/common/ZenActorsManager.mjs)
content/browser/zen-components/ZenUIMigration.mjs (../../zen/common/ZenUIMigration.mjs)
content/browser/zen-components/ZenCommonUtils.mjs (../../zen/common/ZenCommonUtils.mjs)
content/browser/zen-components/ZenSessionStore.mjs (../../zen/common/ZenSessionStore.mjs)
content/browser/zen-components/ZenEmojisData.min.mjs (../../zen/common/emojis/ZenEmojisData.min.mjs)

View File

@@ -1,12 +1,12 @@
diff --git a/browser/components/BrowserGlue.sys.mjs b/browser/components/BrowserGlue.sys.mjs
index eae3ed9518ad9ce2103bb912963465c1b10ac050..51859cd542bc69f524d891a67e725c30d4cf14bb 100644
index eae3ed9518ad9ce2103bb912963465c1b10ac050..ccbb04cd36fd8fd63fd8c9ebd0b51f0a5966829c 100644
--- a/browser/components/BrowserGlue.sys.mjs
+++ b/browser/components/BrowserGlue.sys.mjs
@@ -8,6 +8,7 @@ import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
+ gZenUIMigration: "chrome://browser/content/zen-components/ZenUIMigration.mjs",
+ gZenUIMigration: "resource:///modules/ZenUIMigration.sys.mjs",
AboutHomeStartupCache: "resource:///modules/AboutHomeStartupCache.sys.mjs",
AWToolbarButton: "resource:///modules/aboutwelcome/AWToolbarUtils.sys.mjs",
ASRouter: "resource:///modules/asrouter/ASRouter.sys.mjs",

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from source XPCOM .idl files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from source .webidl files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from glean .yaml files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from source XPCOM .idl files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated by running "mach ts paths".

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from xpc.msg and error_list.json.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from services.json.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* Gecko generic/specialized adjustments for xpcom and webidl types.
*/

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from source XPCOM .idl files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* NOTE: Do not modify this file by hand.
* Content was generated from source XPCOM .idl files.

View File

@@ -1,3 +1,6 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/**
* Gecko XPIDL base types.
*/

View File

@@ -75,6 +75,14 @@ var gZenUIManager = {
this._initCreateNewPopup();
this._debloatContextMenus();
this._initOmniboxCommands();
},
_initOmniboxCommands() {
const { registerZenUrlbarProviders } = ChromeUtils.importESModule(
'resource:///modules/ZenUBProvider.sys.mjs'
);
registerZenUrlbarProviders();
},
_debloatContextMenus() {

View File

@@ -4,4 +4,5 @@
EXTRA_JS_MODULES += [
"ZenCustomizableUI.sys.mjs",
"ZenUIMigration.sys.mjs",
]

View File

@@ -61,8 +61,11 @@
}
#urlbar:not([breakout-extend='true']) {
:root:not([supress-primary-adjustment]) & .urlbar-background {
& .urlbar-background {
transition: background-color 0.15s ease;
:root[supress-primary-adjustment] & {
transition: none !important;
}
}
&:hover .urlbar-background {
@@ -559,6 +562,22 @@ button.popup-notification-dropmarker {
border-top: none !important;
}
.urlbarView-shortcutContent {
border-radius: 4px;
padding: 6px 8px;
font-size: 10px;
font-weight: 600;
text-transform: uppercase;
margin-left: auto;
margin-top: auto;
margin-bottom: auto;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
&:empty {
display: none !important;
}
}
.urlbarView-row[has-action]:is([type='switchtab'], [type='remotetab'], [type='clipboard']) {
& .urlbarView-action:last-child {
margin-left: auto !important;
@@ -616,15 +635,14 @@ button.popup-notification-dropmarker {
--urlbarView-item-inline-padding: 8px;
--urlbarView-item-block-padding: 10px;
&:hover {
.urlbarView-favicon,
& {
background-color: color-mix(
in srgb,
var(--zen-branding-bg-reverse) 5%,
transparent 95%
) !important;
}
&:hover.urlbarView-favicon,
&:hover,
& .urlbarView-shortcutContent {
background-color: color-mix(
in srgb,
var(--zen-branding-bg-reverse) 5%,
transparent 95%
) !important;
}
&[selected] {
@@ -643,7 +661,12 @@ button.popup-notification-dropmarker {
fill: black !important;
}
& .urlbarView-favicon {
& .urlbarView-shortcutContent {
color: black !important;
}
& .urlbarView-favicon,
& .urlbarView-shortcutContent {
background-color: rgba(255, 255, 255, 0.9) !important;
}
}

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.4212 7.5791H7.5791V24.4212H24.4212V7.5791Z" fill="white"/>
<path d="M24.4212 31.9999L32.0001 24.421L28.2106 23.7744L24.4212 24.421L23.7295 27.8872L24.4212 31.9999Z" fill="#EA4335"/>

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16Z" fill="#5765F2"/>
<path d="M18.5844 9C18.4039 9.32044 18.2418 9.65193 18.0945 9.99079C16.6949 9.78085 15.2695 9.78085 13.8661 9.99079C13.7225 9.65193 13.5567 9.32044 13.3763 9C12.0614 9.22469 10.7796 9.61879 9.56412 10.1749C7.15527 13.744 6.50334 17.221 6.82747 20.6501C8.23814 21.6924 9.81826 22.488 11.5015 22.9963C11.8809 22.488 12.2161 21.9466 12.5033 21.3831C11.9582 21.1805 11.4315 20.9263 10.9269 20.6317C11.0595 20.5359 11.1884 20.4365 11.3137 20.3407C14.2713 21.733 17.6967 21.733 20.658 20.3407C20.7833 20.4438 20.9122 20.5433 21.0448 20.6317C20.5402 20.93 20.0135 21.1805 19.4647 21.3867C19.752 21.9503 20.0871 22.4917 20.4665 23C22.1497 22.4917 23.7298 21.6998 25.1406 20.6575C25.5236 16.6796 24.4849 13.232 22.3965 10.1786C21.1847 9.62247 19.903 9.22836 18.5881 9.00736L18.5844 9ZM12.9159 18.5396C12.0061 18.5396 11.251 17.7145 11.251 16.6943C11.251 15.674 11.9766 14.8453 12.9122 14.8453C13.8477 14.8453 14.5917 15.6777 14.577 16.6943C14.5623 17.7109 13.844 18.5396 12.9159 18.5396ZM19.0522 18.5396C18.1387 18.5396 17.391 17.7145 17.391 16.6943C17.391 15.674 18.1166 14.8453 19.0522 14.8453C19.9877 14.8453 20.728 15.6777 20.7133 16.6943C20.6986 17.7109 19.9803 18.5396 19.0522 18.5396Z" fill="white"/>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.5 32.0002C13.536 32.0002 16 29.6108 16 26.6668V21.3335H10.5C7.464 21.3335 5 23.7228 5 26.6668C5 29.6108 7.464 32.0002 10.5 32.0002Z" fill="#0ACF83"/>
<path d="M5 15.9998C5 13.0558 7.464 10.6665 10.5 10.6665H16V21.3332H10.5C7.464 21.3332 5 18.9438 5 15.9998Z" fill="#A259FF"/>

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1 +1,6 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><style>path { fill: black; } @media (prefers-color-scheme: dark) { path { fill: white; }}</style><path d="M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg>

Before

Width:  |  Height:  |  Size: 919 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.9092 0.570312C20.9252 0.483425 21.6372 0.459533 22.2676 0.602539C22.9145 0.749343 23.4327 1.06038 24.0859 1.53418L29.3965 5.26758L29.4043 5.27246C29.8125 5.57126 30.1701 5.81942 30.4004 6.08594C30.6783 6.40761 30.7783 6.75136 30.7783 7.19238V27.665C30.7783 28.3532 30.6552 29.0129 30.2148 29.5127C29.7704 30.0169 29.0911 30.2598 28.2109 30.3223H28.2061L8.88672 31.4893H8.88086C8.2502 31.519 7.71523 31.495 7.23926 31.3213C6.74601 31.1412 6.36848 30.821 6.00977 30.3652L6.00684 30.3613L2.09668 25.2871L2.09375 25.2832C1.35529 24.3021 1.00001 23.4985 1 22.5322V4.33398C1.00003 3.74262 1.13121 3.13817 1.50781 2.65625C1.8945 2.16152 2.4867 1.86338 3.2666 1.7959H3.27344L19.9092 0.569336V0.570312Z" fill="white" stroke="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.947 1.0682L3.308 2.2942C1.968 2.4102 1.5 3.2852 1.5 4.3342V22.5322C1.5 23.3492 1.791 24.0482 2.492 24.9822L6.403 30.0562C7.046 30.8732 7.629 31.0482 8.856 30.9902L28.177 29.8232C29.811 29.7072 30.279 28.9482 30.279 27.6652V7.1922C30.279 6.5292 30.016 6.3382 29.242 5.7722L29.11 5.6762L23.8 1.9432C22.515 1.0112 21.99 0.893201 19.946 1.0682H19.947ZM9.293 6.8572C7.716 6.9632 7.357 6.9872 6.462 6.2602L4.185 4.4522C3.952 4.2182 4.069 3.9262 4.652 3.8682L20.647 2.7022C21.989 2.5852 22.69 3.0522 23.215 3.4602L25.959 5.4432C26.076 5.5022 26.367 5.8512 26.017 5.8512L9.497 6.8432L9.293 6.8572ZM7.454 27.4902V10.1102C7.454 9.3512 7.688 9.0012 8.388 8.9422L27.359 7.8342C28.002 7.7762 28.294 8.1842 28.294 8.9422V26.2062C28.294 26.9652 28.177 27.6072 27.126 27.6652L8.972 28.7152C7.922 28.7732 7.454 28.4242 7.454 27.4902ZM25.376 11.0422C25.492 11.5672 25.376 12.0922 24.849 12.1522L23.975 12.3252V25.1572C23.215 25.5652 22.515 25.7982 21.931 25.7982C20.997 25.7982 20.763 25.5062 20.063 24.6322L14.342 15.6502V24.3402L16.152 24.7492C16.152 24.7492 16.152 25.7992 14.692 25.7992L10.665 26.0322C10.548 25.7982 10.665 25.2152 11.073 25.0992L12.124 24.8082V13.3182L10.665 13.2002C10.548 12.6752 10.839 11.9172 11.657 11.8592L15.977 11.5672L21.931 20.6672V12.6172L20.413 12.4432C20.297 11.8002 20.763 11.3342 21.347 11.2762L25.376 11.0422Z" fill="black"/>

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.8525 18.68C12.6687 18.4375 13.9937 18.0675 15.51 17.9663C14.7007 16.039 14.3729 13.9436 14.555 11.8613C14.7587 9.79752 15.4975 8.06377 16.2112 6.59877L16.645 5.70627L17.205 4.55877C17.4987 3.93377 17.715 3.38627 17.8175 2.86377C17.9187 2.35502 17.9187 1.90877 17.7925 1.47502C17.6637 1.04127 17.4087 0.582519 16.8987 0.073769C16.5564 -0.0184991 16.1963 -0.0237195 15.8514 0.0585822C15.5065 0.140884 15.1876 0.308097 14.9237 0.545019L8.3225 6.48252C7.95209 6.81468 7.70898 7.26552 7.635 7.75752L7.0725 11.53C9.20091 13.5086 10.8377 15.957 11.8525 18.68ZM6.80625 13.25L6.67875 13.6325L3.18625 21.4075C3.01261 21.7987 2.95877 22.2327 3.03152 22.6545C3.10427 23.0763 3.30034 23.4671 3.595 23.7775L9.0875 29.4225C10.2319 27.8406 10.9382 25.9845 11.1351 24.042C11.332 22.0995 11.0124 20.1394 10.2087 18.36C9.38578 16.4688 8.23375 14.7387 6.80625 13.25Z" fill="#A88BFA"/>
<path d="M10.3624 30.0988L10.6549 30.1238C11.6874 30.1488 13.4461 30.2513 14.8599 30.5063C16.0199 30.7226 18.3261 31.3601 20.2124 31.9076C21.6524 32.3413 23.1436 31.1826 23.3474 29.6913C23.5011 28.6076 23.7936 27.3838 24.3161 26.2501C23.6993 24.2904 22.5837 22.5248 21.0786 21.1263C20.0366 20.2208 18.752 19.6406 17.3836 19.4576C15.6525 19.2856 13.9047 19.4898 12.2599 20.0563C12.676 21.7697 12.7207 23.5523 12.391 25.2844C12.0614 27.0165 11.365 28.6581 10.3486 30.0988H10.3611H10.3624Z" fill="#A88BFA"/>

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_187_41)">
<path d="M16 0C7.16296 0 0 7.16296 0 16C0 20.4178 1.79111 24.4178 4.68593 27.3141L1.63852 30.3615C1.03407 30.9659 1.46222 32 2.31704 32H16C24.837 32 32 24.837 32 16C32 7.16296 24.837 0 16 0Z" fill="#FF4500"/>

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.73015 20.1649C6.73015 22.0188 5.23174 23.5173 3.37777 23.5173C1.5238 23.5173 0.0253906 22.0188 0.0253906 20.1649C0.0253906 18.3109 1.5238 16.8125 3.37777 16.8125H6.73015V20.1649ZM8.40634 20.1649C8.40634 18.3109 9.90475 16.8125 11.7587 16.8125C13.6127 16.8125 15.1111 18.3109 15.1111 20.1649V28.5458C15.1111 30.3998 13.6127 31.8982 11.7587 31.8982C9.90475 31.8982 8.40634 30.3998 8.40634 28.5458V20.1649Z" fill="#E01E5A"/>
<path d="M11.7587 6.70476C9.90476 6.70476 8.40635 5.20635 8.40635 3.35238C8.40635 1.49841 9.90476 0 11.7587 0C13.6127 0 15.1111 1.49841 15.1111 3.35238V6.70476H11.7587ZM11.7587 8.40635C13.6127 8.40635 15.1111 9.90476 15.1111 11.7587C15.1111 13.6127 13.6127 15.1111 11.7587 15.1111H3.35238C1.49841 15.1111 0 13.6127 0 11.7587C0 9.90476 1.49841 8.40635 3.35238 8.40635H11.7587Z" fill="#36C5F0"/>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M28.875 0H3.125C1.39911 0 0 1.39911 0 3.125V28.875C0 30.6009 1.39911 32 3.125 32H28.875C30.6009 32 32 30.6009 32 28.875V3.125C32 1.39911 30.6009 0 28.875 0Z" fill="url(#paint0_linear_187_69)"/>
<path d="M26.3401 4.16016H19.5801C18.7517 4.16016 18.0801 4.83173 18.0801 5.66016V16.6602C18.0801 17.4886 18.7517 18.1602 19.5801 18.1602H26.3401C27.1685 18.1602 27.8401 17.4886 27.8401 16.6602V5.66016C27.8401 4.83173 27.1685 4.16016 26.3401 4.16016Z" fill="white"/>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1,3 +1,8 @@
<!--
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0H32V32H0V0Z" fill="black"/>
<path d="M18.2856 14.1635L27.2216 4H25.1048L17.3424 12.823L11.1472 4H4L13.3704 17.3433L4 28H6.1168L14.3088 18.6806L20.8528 28H28M6.8808 5.5619H10.1328L25.1032 26.5148H21.8504" fill="white"/>

Before

Width:  |  Height:  |  Size: 335 B

After

Width:  |  Height:  |  Size: 555 B

View File

@@ -194,20 +194,26 @@ class nsKeyShortcutModifiers {
toUserString() {
let str = '';
const separation = AppConstants.platform == 'macosx' ? ' ' : '+';
if (this.#control && !this.#accel) {
str += 'Ctrl+';
str += AppConstants.platform == 'macosx' ? '⌃' : 'Ctrl';
str += separation;
}
if (this.#alt) {
str += AppConstants.platform == 'macosx' ? 'Option+' : 'Alt+';
str += AppConstants.platform == 'macosx' ? '' : 'Alt';
str += separation;
}
if (this.#shift) {
str += 'Shift+';
str += '';
str += separation;
}
if (this.#meta) {
str += AppConstants.platform == 'macosx' ? 'Cmd+' : 'Win+';
str += AppConstants.platform == 'macosx' ? '' : 'Win';
str += separation;
}
if (this.#accel) {
str += AppConstants.platform == 'macosx' ? 'Cmd+' : 'Ctrl+';
str += AppConstants.platform == 'macosx' ? '' : 'Ctrl';
str += separation;
}
return str;
}
@@ -546,7 +552,32 @@ class KeyShortcut {
// Get the key from the value
for (let [key, value] of Object.entries(KEYCODE_MAP)) {
if (value == this.#keycode) {
str += key.toLowerCase();
const normalizedKey = key.toLowerCase();
switch (normalizedKey) {
case 'arrowleft':
str += '←';
break;
case 'arrowright':
str += '→';
break;
case 'arrowup':
str += '↑';
break;
case 'arrowdown':
str += '↓';
break;
case 'escape':
str += AppConstants.platform == 'macosx' ? '⎋' : 'Esc';
break;
case 'enter':
str += AppConstants.platform == 'macosx' ? '↩' : 'Enter';
break;
case 'space':
str += AppConstants.platform == 'macosx' ? '␣' : 'Space';
break;
default:
str += normalizedKey;
}
break;
}
}
@@ -1315,6 +1346,28 @@ var gZenKeyboardShortcutsManager = {
return false;
},
getShortcutFromCommand(command) {
for (let targetShortcut of this._currentShortcutList) {
if (targetShortcut.getAction() == command) {
return targetShortcut;
}
}
return null;
},
/**
* Get the shortcut as a display format for a given action/command.
* @param {string} command The action/command to search for
* @returns {string|null} The shortcut as a string or null if not found
*/
getShortcutDisplayFromCommand(command) {
const shortcut = this.getShortcutFromCommand(command);
if (shortcut) {
return shortcut.toUserString();
}
return null;
},
};
document.addEventListener(

View File

@@ -1,4 +1,3 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -8,5 +7,6 @@ DIRS += [
"glance",
"mods",
"tests",
"urlbar",
"toolkit",
]

View File

@@ -10,6 +10,7 @@ BROWSER_CHROME_MANIFESTS += [
"pinned/browser.toml",
"split_view/browser.toml",
"tabs/browser.toml",
"ub-actions/browser.toml",
"urlbar/browser.toml",
"welcome/browser.toml",
"workspaces/browser.toml",

View File

@@ -0,0 +1,5 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
["browser_ub_actions_search.js"]

View File

@@ -0,0 +1,23 @@
/* Any copyright is dedicated to the Public Domain.
https://creativecommons.org/publicdomain/zero/1.0/ */
'use strict';
ChromeUtils.defineESModuleGetters(this, {
globalActions: 'resource:///modules/ZenUBGlobalActions.sys.mjs',
UrlbarTestUtils: 'resource://testing-common/UrlbarTestUtils.sys.mjs',
});
add_task(async function test_Ub_Actions_Search() {
for (const action of globalActions) {
const label = action.label;
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
waitForFocus,
value: label,
});
let { result } = await UrlbarTestUtils.getRowAt(window, 1);
Assert.equal(result.providerName, 'ZenUrlbarProviderGlobalActions');
Assert.equal(result.payload.title, label);
}
});

View File

@@ -0,0 +1,277 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { XPCOMUtils } from 'resource://gre/modules/XPCOMUtils.sys.mjs';
import { UrlbarProvider, UrlbarUtils } from 'resource:///modules/UrlbarUtils.sys.mjs';
import { globalActions } from 'resource:///modules/ZenUBGlobalActions.sys.mjs';
const lazy = {};
const DYNAMIC_TYPE_NAME = 'zen-actions';
// The suggestion index of the actions row within the urlbar results.
const MAX_RECENT_ACTIONS = 5;
const MINIMUM_QUERY_SCORE = 93;
const EN_LOCALE_MATCH = /^en(-.*)$/;
ChromeUtils.defineESModuleGetters(lazy, {
UrlbarResult: 'resource:///modules/UrlbarResult.sys.mjs',
UrlbarTokenizer: 'resource:///modules/UrlbarTokenizer.sys.mjs',
QueryScorer: 'resource:///modules/UrlbarProviderInterventions.sys.mjs',
BrowserWindowTracker: 'resource:///modules/BrowserWindowTracker.sys.mjs',
});
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
'enabledPref',
'zen.urlbar.suggestions.quick-actions',
true
);
/**
* A provider that lets the user view all available global actions for a query.
*/
export class ZenUrlbarProviderGlobalActions extends UrlbarProvider {
get name() {
return 'ZenUrlbarProviderGlobalActions';
}
/**
* @returns {Values<typeof UrlbarUtils.PROVIDER_TYPE>}
*/
get type() {
return UrlbarUtils.PROVIDER_TYPE.PROFILE;
}
/**
* Whether this provider should be invoked for the given context.
* If this method returns false, the providers manager won't start a query
* with this provider, to save on resources.
*
* @param {UrlbarQueryContext} queryContext The query context object
*/
async isActive(queryContext) {
return (
lazy.enabledPref &&
queryContext.searchString &&
queryContext.searchString.length < UrlbarUtils.MAX_TEXT_LENGTH &&
queryContext.searchString.length > 2 &&
!lazy.UrlbarTokenizer.REGEXP_LIKE_PROTOCOL.test(queryContext.searchString) &&
EN_LOCALE_MATCH.test(Services.locale.appLocaleAsBCP47)
);
}
/**
* @returns All the available global actions.
*/
get #availableActions() {
return globalActions.filter((a) =>
typeof a.isAvailable === 'function' ? a.isAvailable() : true
);
}
/**
* Starts a search query amongst the available global actions.
*
* @param {string} queryContext The query context object
*/
#findMatchingActions(query) {
const actions = this.#availableActions;
let results = [];
for (let action of actions) {
const label = action.label;
const score = this.#calculateFuzzyScore(label, query);
if (score > MINIMUM_QUERY_SCORE) {
results.push({
score,
action,
});
}
}
results.sort((a, b) => b.score - a.score);
return results.slice(0, MAX_RECENT_ACTIONS).map((r) => r.action);
}
/**
* A VS Code-style fuzzy scoring algorithm.
* @param {string} target The string to score against.
* @param {string} query The user's search query.
* @returns {number} A score representing the match quality.
*
* @credits Thanks a lot @BibekBhusal0 on GitHub for this implementation!
*/
#calculateFuzzyScore(target, query) {
if (!target || !query) return 0;
const targetLower = target.toLowerCase();
const queryLower = query.toLowerCase();
const targetLen = target.length;
const queryLen = query.length;
if (queryLen > targetLen) return 0;
if (queryLen === 0) return 0;
// 1. Exact match gets the highest score.
if (targetLower === queryLower) {
return 200;
}
// 2. Exact prefix matches are heavily prioritized.
if (targetLower.startsWith(queryLower)) {
return 100 + queryLen;
}
// 3. Exact abbreviation (e.g., 'tcm' for 'Toggle Compact Mode')
const initials = targetLower
.split(/[\s-_]+/)
.map((word) => word[0])
.join('');
if (initials === queryLower) {
return 90 + queryLen;
}
let score = 0;
let queryIndex = 0;
let lastMatchIndex = -1;
let consecutiveMatches = 0;
for (let targetIndex = 0; targetIndex < targetLen; targetIndex++) {
if (queryIndex < queryLen && targetLower[targetIndex] === queryLower[queryIndex]) {
let bonus = 10;
// Bonus for matching at the beginning of a word
if (targetIndex === 0 || [' ', '-', '_'].includes(targetLower[targetIndex - 1])) {
bonus += 15;
}
// Bonus for consecutive matches
if (lastMatchIndex === targetIndex - 1) {
consecutiveMatches++;
bonus += 20 * consecutiveMatches;
} else {
consecutiveMatches = 0;
}
// Penalty for distance from the last match
if (lastMatchIndex !== -1) {
const distance = targetIndex - lastMatchIndex;
bonus -= Math.min(distance - 1, 10); // Cap penalty
}
score += bonus;
lastMatchIndex = targetIndex;
queryIndex++;
}
}
return queryIndex === queryLen ? score : 0;
}
async startQuery(queryContext, addCallback) {
const query = queryContext.searchString.trim().toLowerCase();
if (!query) {
return;
}
const actionsResults = this.#findMatchingActions(query);
if (!actionsResults.length) {
return;
}
const ownerGlobal = lazy.BrowserWindowTracker.getTopWindow();
for (const action of actionsResults) {
const [payload, payloadHighlights] = lazy.UrlbarResult.payloadAndSimpleHighlights([], {
suggestion: action.label,
title: action.label,
query: queryContext.searchString,
zenCommand: action.command,
dynamicType: DYNAMIC_TYPE_NAME,
icon: action.icon || 'chrome://browser/skin/trending.svg',
shortcutContent: ownerGlobal.gZenKeyboardShortcutsManager.getShortcutDisplayFromCommand(
action.command
),
});
let result = new lazy.UrlbarResult(
UrlbarUtils.RESULT_TYPE.DYNAMIC,
UrlbarUtils.RESULT_SOURCE.OTHER_LOCAL,
payload,
payloadHighlights
);
if (action.suggestedIndex) {
result.suggestedIndex = action.suggestedIndex;
}
addCallback(this, result);
}
}
/**
* Gets the provider's priority.
*
* @returns {number} The provider's priority for the given query.
*/
getPriority() {
return 0;
}
/**
* This is called only for dynamic result types, when the urlbar view updates
* the view of one of the results of the provider. It should return an object
* describing the view update.
*
* @param {UrlbarResult} result The result whose view will be updated.
* @returns {object} An object describing the view update.
*/
getViewUpdate(result) {
return {
icon: {
attributes: {
src: result.payload.icon || 'chrome://browser/skin/trending.svg',
},
},
titleStrong: {
textContent: result.payload.title,
attributes: { dir: 'ltr' },
},
shortcutContent: {
textContent: result.payload.shortcutContent || '',
},
};
}
getViewTemplate() {
return {
attributes: {
selectable: true,
},
children: [
{
name: 'icon',
tag: 'img',
classList: ['urlbarView-favicon'],
},
{
name: 'title',
tag: 'span',
classList: ['urlbarView-title'],
children: [
{
name: 'titleStrong',
tag: 'strong',
},
],
},
{
name: 'shortcutContent',
tag: 'span',
classList: ['urlbarView-shortcutContent'],
},
],
};
}
onEngagement(queryContext, controller, details) {
const result = details.result;
const payload = result.payload;
const command = payload.zenCommand;
if (!command) {
return;
}
const ownerGlobal = details.element.ownerGlobal;
const commandToRun = ownerGlobal.document.getElementById(command);
if (commandToRun) {
ownerGlobal.gBrowser.selectedBrowser.focus();
commandToRun.doCommand();
}
}
}

View File

@@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
export const globalActions = [
{
label: 'Toggle Compact Mode',
command: 'cmd_zenCompactModeToggle',
icon: 'chrome://browser/skin/zen-icons/sidebar.svg',
},
{
label: 'Open Theme Picker',
command: 'cmd_zenOpenZenThemePicker',
icon: 'chrome://browser/skin/zen-icons/edit-theme.svg',
suggestedIndex: 4,
},
];

View File

@@ -0,0 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { UrlbarProvidersManager } from 'resource:///modules/UrlbarProvidersManager.sys.mjs';
const providers = {};
ChromeUtils.defineESModuleGetters(providers, {
ZenUrlbarProviderGlobalActions: 'resource:///modules/ZenUBActionsProvider.sys.mjs',
});
export function registerZenUrlbarProviders() {
for (let provider of Object.values(providers)) {
UrlbarProvidersManager.registerProvider(new provider());
}
}

9
src/zen/urlbar/moz.build Normal file
View File

@@ -0,0 +1,9 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
"ZenUBActionsProvider.sys.mjs",
"ZenUBGlobalActions.sys.mjs",
"ZenUBProvider.sys.mjs",
]