Skip to content

Commit 015cdad

Browse files
committed
feat: Made 'search test on <search engine>' open tabs in glance, b=(no-bug), c=common, glance, split-view, tests
1 parent ef6cf5f commit 015cdad

File tree

8 files changed

+77
-28
lines changed

8 files changed

+77
-28
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/browser/components/search/SearchUIUtils.sys.mjs b/browser/components/search/SearchUIUtils.sys.mjs
2+
index ecebaad93acfc9eb7dfd9d9f56fec2e1a4abe392..8bb1348b3258dbc518d23ec39181a81f87fc8c1e 100644
3+
--- a/browser/components/search/SearchUIUtils.sys.mjs
4+
+++ b/browser/components/search/SearchUIUtils.sys.mjs
5+
@@ -403,7 +403,7 @@ export var SearchUIUtils = {
6+
triggeringSearchEngine: engine.name,
7+
},
8+
});
9+
-
10+
+ window.gZenGlanceManager?.onSearchSelectCommand(where);
11+
return { engine, url: submission.uri };
12+
},
13+

src/zen/common/ZenSessionStore.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
await gZenGlanceManager.openGlance(
7676
{
7777
url: undefined,
78-
x: browserRect.width / 2,
79-
y: browserRect.height / 2,
78+
clientX: browserRect.width / 2,
79+
clientY: browserRect.height / 2,
8080
width: 0,
8181
height: 0,
8282
},

src/zen/common/ZenUIManager.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var gZenUIManager = {
77
_hasLoadedDOM: false,
88
testingEnabled: Services.prefs.getBoolPref('zen.testing.enabled', false),
99

10+
_lastClickPosition: null,
11+
1012
_toastTimeouts: [],
1113

1214
init() {
@@ -34,6 +36,8 @@ var gZenUIManager = {
3436

3537
gURLBar._zenTrimURL = this.urlbarTrim.bind(this);
3638

39+
document.addEventListener('mousedown', this.handleMouseDown.bind(this), true);
40+
3741
ChromeUtils.defineLazyGetter(this, 'motion', () => {
3842
return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', {
3943
global: 'current',
@@ -65,6 +69,13 @@ var gZenUIManager = {
6569
gZenMediaController.init();
6670
},
6771

72+
handleMouseDown(event) {
73+
this._lastClickPosition = {
74+
clientX: event.clientX,
75+
clientY: event.clientY,
76+
};
77+
},
78+
6879
updateTabsToolbar() {
6980
const kUrlbarHeight = 440;
7081
gURLBar.textbox.style.setProperty(

src/zen/downloads/ZenDownloadAnimation.mjs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,10 @@
1414
});
1515

1616
class ZenDownloadAnimation extends ZenDOMOperatedFeature {
17-
#lastClickPosition = null;
18-
1917
async init() {
20-
this.#setupClickListener();
2118
await this.#setupDownloadListeners();
2219
}
2320

24-
#setupClickListener() {
25-
document.addEventListener('mousedown', this.#handleClick.bind(this), true);
26-
}
27-
28-
#handleClick(event) {
29-
this.#lastClickPosition = {
30-
clientX: event.clientX,
31-
clientY: event.clientY,
32-
};
33-
}
34-
3521
async #setupDownloadListeners() {
3622
try {
3723
const list = await Downloads.getList(Downloads.ALL);
@@ -53,14 +39,14 @@
5339
return;
5440
}
5541

56-
if (!this.#lastClickPosition) {
42+
if (!gZenUIManager._lastClickPosition) {
5743
console.warn(
5844
`[${ZenDownloadAnimation.name}] No recent click position available for animation`
5945
);
6046
return;
6147
}
6248

63-
this.#animateDownload(this.#lastClickPosition);
49+
this.#animateDownload(gZenUIManager._lastClickPosition);
6450
}
6551

6652
#animateDownload(startPosition) {

src/zen/glance/ZenGlanceManager.mjs

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@
154154
this.animatingOpen = true;
155155
this._animating = true;
156156

157-
const initialX = data.x;
158-
const initialY = data.y;
157+
const initialX = data.clientX;
158+
const initialY = data.clientY;
159159
const initialWidth = data.width;
160160
const initialHeight = data.height;
161161

@@ -597,8 +597,10 @@
597597
this.openGlance(
598598
{
599599
url: undefined,
600-
x: browserRect.width / 2,
601-
y: browserRect.height / 2,
600+
...(gZenUIManager._lastClickPosition || {
601+
clientX: browserRect.width / 2,
602+
clientY: browserRect.height / 2,
603+
}),
602604
width: 0,
603605
height: 0,
604606
},
@@ -639,7 +641,12 @@
639641
.classList.remove('zen-glance-background');
640642
this.#currentParentTab._visuallySelected = false;
641643
this.hideSidebarButtons();
644+
if (forSplit) {
645+
this.finishOpeningGlance();
646+
return;
647+
}
642648
if (gReduceMotion || forSplit) {
649+
gZenViewSplitter.deactivateCurrentSplitView();
643650
this.finishOpeningGlance();
644651
return;
645652
}
@@ -654,6 +661,7 @@
654661
type: 'spring',
655662
}
656663
);
664+
gZenViewSplitter.deactivateCurrentSplitView();
657665
this.finishOpeningGlance();
658666
}
659667

@@ -678,8 +686,8 @@
678686
const rect = event.target.getBoundingClientRect();
679687
const data = {
680688
url: event.target._placesNode.uri,
681-
x: rect.left,
682-
y: rect.top,
689+
clientX: rect.left,
690+
clientY: rect.top,
683691
width: rect.width,
684692
height: rect.height,
685693
};
@@ -737,6 +745,32 @@
737745
}
738746
return false;
739747
}
748+
749+
onSearchSelectCommand(where) {
750+
if (where !== 'tab') {
751+
return;
752+
}
753+
const currentTab = gBrowser.selectedTab;
754+
const parentTab = currentTab.owner;
755+
if (!parentTab) {
756+
return;
757+
}
758+
// Open a new glance if the current tab is a glance tab
759+
const browserRect = gBrowser.tabbox.getBoundingClientRect();
760+
this.openGlance(
761+
{
762+
url: undefined,
763+
...(gZenUIManager._lastClickPosition || {
764+
clientX: browserRect.width / 2,
765+
clientY: browserRect.height / 2,
766+
}),
767+
width: 0,
768+
height: 0,
769+
},
770+
currentTab,
771+
parentTab
772+
);
773+
}
740774
}
741775

742776
window.gZenGlanceManager = new ZenGlanceManager();

src/zen/glance/actors/ZenGlanceChild.sys.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export class ZenGlanceChild extends JSWindowActorChild {
7474
const rect = target.getBoundingClientRect();
7575
this.sendAsyncMessage('ZenGlance:OpenGlance', {
7676
url,
77-
x: rect.left,
78-
y: rect.top,
77+
clientX: rect.left,
78+
clientY: rect.top,
7979
width: rect.width,
8080
height: rect.height,
8181
});

src/zen/split-view/ZenViewSplitter.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
159159
const tab = event.target;
160160
if (tab.group?.hasAttribute('split-view-group')) {
161161
gBrowser.explicitUnloadTabs(tab.group.tabs);
162+
for (const t of tab.group.tabs) {
163+
if (t.glanceTab) {
164+
gBrowser.explicitUnloadTabs([t.glanceTab]);
165+
}
166+
}
162167
}
163168
}
164169

src/zen/tests/glance/head.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function openGlanceOnTab(callback, close = true) {
99
gZenGlanceManager
1010
.openGlance({
1111
url: 'https://example.com',
12-
x: 0,
13-
y: 0,
12+
clientX: 0,
13+
clientY: 0,
1414
width: 0,
1515
height: 0,
1616
})

0 commit comments

Comments
 (0)