mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-02 10:04:37 +00:00
feat: First urlbar action must be selected, b=no-bug, c=common, tests, workspaces
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
diff --git a/browser/components/urlbar/UrlbarProvidersManager.sys.mjs b/browser/components/urlbar/UrlbarProvidersManager.sys.mjs
|
||||
index 555273f6ea1efd77aa3062b9910bbfe28568775d..c8aae86e1233d256e538970d58fd0febed745893 100644
|
||||
--- a/browser/components/urlbar/UrlbarProvidersManager.sys.mjs
|
||||
+++ b/browser/components/urlbar/UrlbarProvidersManager.sys.mjs
|
||||
@@ -138,7 +138,7 @@ class ProvidersManager {
|
||||
// To improve dataflow and reduce UI work, when a result is added we may notify
|
||||
// it to the controller after a delay, so that we can chunk results in that
|
||||
// timeframe into a single call. See _notifyResultsFromProvider for details.
|
||||
- this.CHUNK_RESULTS_DELAY_MS = 16;
|
||||
+ this.CHUNK_RESULTS_DELAY_MS = 20;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/urlbar/UrlbarView.sys.mjs b/browser/components/urlbar/UrlbarView.sys.mjs
|
||||
index fdbab8806fd320f4aacec46a42c8ef953580d00c..a1be83735cd2b69d335cd36d3287cd3b3e3f2a5b 100644
|
||||
index fdbab8806fd320f4aacec46a42c8ef953580d00c..40568280c3ba2f0a36f4443a5116430d3c502ec1 100644
|
||||
--- a/browser/components/urlbar/UrlbarView.sys.mjs
|
||||
+++ b/browser/components/urlbar/UrlbarView.sys.mjs
|
||||
@@ -613,7 +613,7 @@ export class UrlbarView {
|
||||
@@ -11,7 +11,27 @@ index fdbab8806fd320f4aacec46a42c8ef953580d00c..a1be83735cd2b69d335cd36d3287cd3b
|
||||
// Try to reuse the cached top-sites context. If it's not cached, then
|
||||
// there will be a gap of time between when the input is focused and
|
||||
// when the view opens that can be perceived as flicker.
|
||||
@@ -1341,7 +1341,7 @@ export class UrlbarView {
|
||||
@@ -823,6 +823,19 @@ export class UrlbarView {
|
||||
// them, resembling tab-to-search. In that case, the input value is
|
||||
// still associated with the first result.
|
||||
this.input.setResultForCurrentValue(firstResult);
|
||||
+ } else if (firstResult.payload.zenAction) {
|
||||
+ this.#selectElement(this.getFirstSelectableElement(), {
|
||||
+ updateInput: false,
|
||||
+ setAccessibleFocus:
|
||||
+ this.controller._userSelectionBehavior == "arrow",
|
||||
+ });
|
||||
+ this.window.setTimeout(() => {
|
||||
+ this.#selectElement(this.getFirstSelectableElement(), {
|
||||
+ updateInput: false,
|
||||
+ setAccessibleFocus:
|
||||
+ this.controller._userSelectionBehavior == "arrow",
|
||||
+ });
|
||||
+ }, 150);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1341,7 +1354,7 @@ export class UrlbarView {
|
||||
includeHiddenExposures: true,
|
||||
});
|
||||
let canBeVisible =
|
||||
@@ -20,7 +40,7 @@ index fdbab8806fd320f4aacec46a42c8ef953580d00c..a1be83735cd2b69d335cd36d3287cd3b
|
||||
if (result.isHiddenExposure) {
|
||||
if (canBeVisible) {
|
||||
this.controller.engagementEvent.addExposure(
|
||||
@@ -3189,7 +3189,7 @@ export class UrlbarView {
|
||||
@@ -3189,7 +3202,7 @@ export class UrlbarView {
|
||||
}
|
||||
|
||||
#enableOrDisableRowWrap() {
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
--tab-close-button-padding: 5px !important;
|
||||
|
||||
--input-border-color: var(--zen-input-border-color) !important;
|
||||
--zen-themed-toolbar-bg-transparent: light-dark(var(--zen-branding-bg), #171717);
|
||||
--zen-themed-toolbar-bg-transparent: transparent;
|
||||
|
||||
--zen-workspace-indicator-height: 46px;
|
||||
|
||||
@@ -265,13 +265,9 @@
|
||||
#main-window:not([chromehidden~='toolbar']) {
|
||||
min-height: 495px !important;
|
||||
|
||||
@media (-moz-windows-mica) or (-moz-platform: macos) or ((-moz-platform: linux) and -moz-pref('zen.widget.linux.transparency')) {
|
||||
background: transparent;
|
||||
--zen-themed-toolbar-bg-transparent: transparent;
|
||||
|
||||
@media (-moz-windows-mica) and (not (-moz-pref('widget.windows.mica.toplevel-backdrop', 1))) and (not (-moz-pref('widget.windows.mica.toplevel-backdrop', 2))) {
|
||||
--zen-themed-toolbar-bg-transparent: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
background: transparent;
|
||||
@media (-moz-windows-mica) and (not (-moz-pref('widget.windows.mica.toplevel-backdrop', 1))) and (not (-moz-pref('widget.windows.mica.toplevel-backdrop', 2))) {
|
||||
--zen-themed-toolbar-bg-transparent: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
&,
|
||||
|
||||
@@ -16,7 +16,7 @@ add_task(async function test_Ub_Actions_Search() {
|
||||
waitForFocus,
|
||||
value: label,
|
||||
});
|
||||
let { result } = await UrlbarTestUtils.getRowAt(window, 1);
|
||||
let { result } = await UrlbarTestUtils.getRowAt(window, Math.min(action.suggestedIndex, 1));
|
||||
Assert.equal(result.providerName, 'ZenUrlbarProviderGlobalActions');
|
||||
Assert.equal(result.payload.title, label);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ 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 MINIMUM_QUERY_SCORE = 92;
|
||||
|
||||
const EN_LOCALE_MATCH = /^en(-.*)$/;
|
||||
|
||||
@@ -42,7 +42,7 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider {
|
||||
* @returns {Values<typeof UrlbarUtils.PROVIDER_TYPE>}
|
||||
*/
|
||||
get type() {
|
||||
return UrlbarUtils.PROVIDER_TYPE.PROFILE;
|
||||
return UrlbarUtils.PROVIDER_TYPE.HEURISTIC;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,14 +118,6 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider {
|
||||
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;
|
||||
@@ -176,6 +168,7 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider {
|
||||
query: queryContext.searchString,
|
||||
zenCommand: action.command,
|
||||
dynamicType: DYNAMIC_TYPE_NAME,
|
||||
zenAction: true,
|
||||
icon: action.icon || 'chrome://browser/skin/trending.svg',
|
||||
shortcutContent: ownerGlobal.gZenKeyboardShortcutsManager.getShortcutDisplayFromCommand(
|
||||
action.command
|
||||
@@ -188,7 +181,7 @@ export class ZenUrlbarProviderGlobalActions extends UrlbarProvider {
|
||||
payload,
|
||||
payloadHighlights
|
||||
);
|
||||
if (action.suggestedIndex) {
|
||||
if (typeof action.suggestedIndex === 'number') {
|
||||
result.suggestedIndex = action.suggestedIndex;
|
||||
}
|
||||
addCallback(this, result);
|
||||
|
||||
@@ -7,6 +7,7 @@ export const globalActions = [
|
||||
label: 'Toggle Compact Mode',
|
||||
command: 'cmd_zenCompactModeToggle',
|
||||
icon: 'chrome://browser/skin/zen-icons/sidebar.svg',
|
||||
suggestedIndex: 0,
|
||||
},
|
||||
{
|
||||
label: 'Open Theme Picker',
|
||||
|
||||
@@ -10,7 +10,11 @@ ChromeUtils.defineESModuleGetters(providers, {
|
||||
});
|
||||
|
||||
export function registerZenUrlbarProviders() {
|
||||
for (let provider of Object.values(providers)) {
|
||||
UrlbarProvidersManager.registerProvider(new provider());
|
||||
for (let i = 0; i < Object.keys(providers).length; i++) {
|
||||
const provider = Object.values(providers)[i];
|
||||
const name = Object.keys(providers)[i];
|
||||
if (!UrlbarProvidersManager.getProvider(name)) {
|
||||
UrlbarProvidersManager.registerProvider(new provider());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1089,7 +1089,10 @@
|
||||
return color.c;
|
||||
}
|
||||
let opacity = this.currentOpacity;
|
||||
if (forToolbar && !this.#allowTransparencyOnSidebar) {
|
||||
if (
|
||||
(forToolbar && !this.#allowTransparencyOnSidebar) ||
|
||||
(!forToolbar && !this.canBeTransparent)
|
||||
) {
|
||||
color = this.blendColors(
|
||||
color.c,
|
||||
this.getToolbarModifiedBaseRaw().slice(0, 3),
|
||||
@@ -1140,11 +1143,13 @@
|
||||
|
||||
const rotation = -45; // TODO: Detect rotation based on the accent color
|
||||
if (themedColors.length === 0) {
|
||||
return forToolbar
|
||||
? this.getToolbarModifiedBase()
|
||||
: this.isDarkMode
|
||||
? 'rgba(0, 0, 0, 0.4)'
|
||||
: 'transparent';
|
||||
const getBrowserBg = () => {
|
||||
if (this.canBeTransparent) {
|
||||
return this.isDarkMode ? 'rgba(0, 0, 0, 0.4)' : 'transparent';
|
||||
}
|
||||
return this.isDarkMode ? '#131313' : '#e9e9e9';
|
||||
};
|
||||
return forToolbar ? this.getToolbarModifiedBase() : getBrowserBg();
|
||||
} else if (themedColors.length === 1) {
|
||||
return this.getSingleRGBColor(themedColors[0], forToolbar);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user