feat: Made 'search test on <search engine>' open tabs in glance, b=(no-bug), c=common, glance, split-view, tests

This commit is contained in:
Mr. M 2025-05-27 12:49:12 +02:00
parent ef6cf5fae1
commit 015cdad2df
No known key found for this signature in database
GPG key ID: 6292C4C8F8652B18
8 changed files with 77 additions and 28 deletions

View file

@ -0,0 +1,13 @@
diff --git a/browser/components/search/SearchUIUtils.sys.mjs b/browser/components/search/SearchUIUtils.sys.mjs
index ecebaad93acfc9eb7dfd9d9f56fec2e1a4abe392..8bb1348b3258dbc518d23ec39181a81f87fc8c1e 100644
--- a/browser/components/search/SearchUIUtils.sys.mjs
+++ b/browser/components/search/SearchUIUtils.sys.mjs
@@ -403,7 +403,7 @@ export var SearchUIUtils = {
triggeringSearchEngine: engine.name,
},
});
-
+ window.gZenGlanceManager?.onSearchSelectCommand(where);
return { engine, url: submission.uri };
},

View file

@ -75,8 +75,8 @@
await gZenGlanceManager.openGlance( await gZenGlanceManager.openGlance(
{ {
url: undefined, url: undefined,
x: browserRect.width / 2, clientX: browserRect.width / 2,
y: browserRect.height / 2, clientY: browserRect.height / 2,
width: 0, width: 0,
height: 0, height: 0,
}, },

View file

@ -7,6 +7,8 @@ var gZenUIManager = {
_hasLoadedDOM: false, _hasLoadedDOM: false,
testingEnabled: Services.prefs.getBoolPref('zen.testing.enabled', false), testingEnabled: Services.prefs.getBoolPref('zen.testing.enabled', false),
_lastClickPosition: null,
_toastTimeouts: [], _toastTimeouts: [],
init() { init() {
@ -34,6 +36,8 @@ var gZenUIManager = {
gURLBar._zenTrimURL = this.urlbarTrim.bind(this); gURLBar._zenTrimURL = this.urlbarTrim.bind(this);
document.addEventListener('mousedown', this.handleMouseDown.bind(this), true);
ChromeUtils.defineLazyGetter(this, 'motion', () => { ChromeUtils.defineLazyGetter(this, 'motion', () => {
return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', { return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', {
global: 'current', global: 'current',
@ -65,6 +69,13 @@ var gZenUIManager = {
gZenMediaController.init(); gZenMediaController.init();
}, },
handleMouseDown(event) {
this._lastClickPosition = {
clientX: event.clientX,
clientY: event.clientY,
};
},
updateTabsToolbar() { updateTabsToolbar() {
const kUrlbarHeight = 440; const kUrlbarHeight = 440;
gURLBar.textbox.style.setProperty( gURLBar.textbox.style.setProperty(

View file

@ -14,24 +14,10 @@
}); });
class ZenDownloadAnimation extends ZenDOMOperatedFeature { class ZenDownloadAnimation extends ZenDOMOperatedFeature {
#lastClickPosition = null;
async init() { async init() {
this.#setupClickListener();
await this.#setupDownloadListeners(); await this.#setupDownloadListeners();
} }
#setupClickListener() {
document.addEventListener('mousedown', this.#handleClick.bind(this), true);
}
#handleClick(event) {
this.#lastClickPosition = {
clientX: event.clientX,
clientY: event.clientY,
};
}
async #setupDownloadListeners() { async #setupDownloadListeners() {
try { try {
const list = await Downloads.getList(Downloads.ALL); const list = await Downloads.getList(Downloads.ALL);
@ -53,14 +39,14 @@
return; return;
} }
if (!this.#lastClickPosition) { if (!gZenUIManager._lastClickPosition) {
console.warn( console.warn(
`[${ZenDownloadAnimation.name}] No recent click position available for animation` `[${ZenDownloadAnimation.name}] No recent click position available for animation`
); );
return; return;
} }
this.#animateDownload(this.#lastClickPosition); this.#animateDownload(gZenUIManager._lastClickPosition);
} }
#animateDownload(startPosition) { #animateDownload(startPosition) {

View file

@ -154,8 +154,8 @@
this.animatingOpen = true; this.animatingOpen = true;
this._animating = true; this._animating = true;
const initialX = data.x; const initialX = data.clientX;
const initialY = data.y; const initialY = data.clientY;
const initialWidth = data.width; const initialWidth = data.width;
const initialHeight = data.height; const initialHeight = data.height;
@ -597,8 +597,10 @@
this.openGlance( this.openGlance(
{ {
url: undefined, url: undefined,
x: browserRect.width / 2, ...(gZenUIManager._lastClickPosition || {
y: browserRect.height / 2, clientX: browserRect.width / 2,
clientY: browserRect.height / 2,
}),
width: 0, width: 0,
height: 0, height: 0,
}, },
@ -639,7 +641,12 @@
.classList.remove('zen-glance-background'); .classList.remove('zen-glance-background');
this.#currentParentTab._visuallySelected = false; this.#currentParentTab._visuallySelected = false;
this.hideSidebarButtons(); this.hideSidebarButtons();
if (forSplit) {
this.finishOpeningGlance();
return;
}
if (gReduceMotion || forSplit) { if (gReduceMotion || forSplit) {
gZenViewSplitter.deactivateCurrentSplitView();
this.finishOpeningGlance(); this.finishOpeningGlance();
return; return;
} }
@ -654,6 +661,7 @@
type: 'spring', type: 'spring',
} }
); );
gZenViewSplitter.deactivateCurrentSplitView();
this.finishOpeningGlance(); this.finishOpeningGlance();
} }
@ -678,8 +686,8 @@
const rect = event.target.getBoundingClientRect(); const rect = event.target.getBoundingClientRect();
const data = { const data = {
url: event.target._placesNode.uri, url: event.target._placesNode.uri,
x: rect.left, clientX: rect.left,
y: rect.top, clientY: rect.top,
width: rect.width, width: rect.width,
height: rect.height, height: rect.height,
}; };
@ -737,6 +745,32 @@
} }
return false; return false;
} }
onSearchSelectCommand(where) {
if (where !== 'tab') {
return;
}
const currentTab = gBrowser.selectedTab;
const parentTab = currentTab.owner;
if (!parentTab) {
return;
}
// Open a new glance if the current tab is a glance tab
const browserRect = gBrowser.tabbox.getBoundingClientRect();
this.openGlance(
{
url: undefined,
...(gZenUIManager._lastClickPosition || {
clientX: browserRect.width / 2,
clientY: browserRect.height / 2,
}),
width: 0,
height: 0,
},
currentTab,
parentTab
);
}
} }
window.gZenGlanceManager = new ZenGlanceManager(); window.gZenGlanceManager = new ZenGlanceManager();

View file

@ -74,8 +74,8 @@ export class ZenGlanceChild extends JSWindowActorChild {
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
this.sendAsyncMessage('ZenGlance:OpenGlance', { this.sendAsyncMessage('ZenGlance:OpenGlance', {
url, url,
x: rect.left, clientX: rect.left,
y: rect.top, clientY: rect.top,
width: rect.width, width: rect.width,
height: rect.height, height: rect.height,
}); });

View file

@ -159,6 +159,11 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
const tab = event.target; const tab = event.target;
if (tab.group?.hasAttribute('split-view-group')) { if (tab.group?.hasAttribute('split-view-group')) {
gBrowser.explicitUnloadTabs(tab.group.tabs); gBrowser.explicitUnloadTabs(tab.group.tabs);
for (const t of tab.group.tabs) {
if (t.glanceTab) {
gBrowser.explicitUnloadTabs([t.glanceTab]);
}
}
} }
} }

View file

@ -9,8 +9,8 @@ function openGlanceOnTab(callback, close = true) {
gZenGlanceManager gZenGlanceManager
.openGlance({ .openGlance({
url: 'https://example.com', url: 'https://example.com',
x: 0, clientX: 0,
y: 0, clientY: 0,
width: 0, width: 0,
height: 0, height: 0,
}) })