forked from ZenBrowserMirrors/zen-desktop
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:
parent
ef6cf5fae1
commit
015cdad2df
8 changed files with 77 additions and 28 deletions
13
src/browser/components/search/SearchUIUtils-sys-mjs.patch
Normal file
13
src/browser/components/search/SearchUIUtils-sys-mjs.patch
Normal 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 };
|
||||
},
|
||||
|
|
@ -75,8 +75,8 @@
|
|||
await gZenGlanceManager.openGlance(
|
||||
{
|
||||
url: undefined,
|
||||
x: browserRect.width / 2,
|
||||
y: browserRect.height / 2,
|
||||
clientX: browserRect.width / 2,
|
||||
clientY: browserRect.height / 2,
|
||||
width: 0,
|
||||
height: 0,
|
||||
},
|
||||
|
|
|
@ -7,6 +7,8 @@ var gZenUIManager = {
|
|||
_hasLoadedDOM: false,
|
||||
testingEnabled: Services.prefs.getBoolPref('zen.testing.enabled', false),
|
||||
|
||||
_lastClickPosition: null,
|
||||
|
||||
_toastTimeouts: [],
|
||||
|
||||
init() {
|
||||
|
@ -34,6 +36,8 @@ var gZenUIManager = {
|
|||
|
||||
gURLBar._zenTrimURL = this.urlbarTrim.bind(this);
|
||||
|
||||
document.addEventListener('mousedown', this.handleMouseDown.bind(this), true);
|
||||
|
||||
ChromeUtils.defineLazyGetter(this, 'motion', () => {
|
||||
return ChromeUtils.importESModule('chrome://browser/content/zen-vendor/motion.min.mjs', {
|
||||
global: 'current',
|
||||
|
@ -65,6 +69,13 @@ var gZenUIManager = {
|
|||
gZenMediaController.init();
|
||||
},
|
||||
|
||||
handleMouseDown(event) {
|
||||
this._lastClickPosition = {
|
||||
clientX: event.clientX,
|
||||
clientY: event.clientY,
|
||||
};
|
||||
},
|
||||
|
||||
updateTabsToolbar() {
|
||||
const kUrlbarHeight = 440;
|
||||
gURLBar.textbox.style.setProperty(
|
||||
|
|
|
@ -14,24 +14,10 @@
|
|||
});
|
||||
|
||||
class ZenDownloadAnimation extends ZenDOMOperatedFeature {
|
||||
#lastClickPosition = null;
|
||||
|
||||
async init() {
|
||||
this.#setupClickListener();
|
||||
await this.#setupDownloadListeners();
|
||||
}
|
||||
|
||||
#setupClickListener() {
|
||||
document.addEventListener('mousedown', this.#handleClick.bind(this), true);
|
||||
}
|
||||
|
||||
#handleClick(event) {
|
||||
this.#lastClickPosition = {
|
||||
clientX: event.clientX,
|
||||
clientY: event.clientY,
|
||||
};
|
||||
}
|
||||
|
||||
async #setupDownloadListeners() {
|
||||
try {
|
||||
const list = await Downloads.getList(Downloads.ALL);
|
||||
|
@ -53,14 +39,14 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this.#lastClickPosition) {
|
||||
if (!gZenUIManager._lastClickPosition) {
|
||||
console.warn(
|
||||
`[${ZenDownloadAnimation.name}] No recent click position available for animation`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.#animateDownload(this.#lastClickPosition);
|
||||
this.#animateDownload(gZenUIManager._lastClickPosition);
|
||||
}
|
||||
|
||||
#animateDownload(startPosition) {
|
||||
|
|
|
@ -154,8 +154,8 @@
|
|||
this.animatingOpen = true;
|
||||
this._animating = true;
|
||||
|
||||
const initialX = data.x;
|
||||
const initialY = data.y;
|
||||
const initialX = data.clientX;
|
||||
const initialY = data.clientY;
|
||||
const initialWidth = data.width;
|
||||
const initialHeight = data.height;
|
||||
|
||||
|
@ -597,8 +597,10 @@
|
|||
this.openGlance(
|
||||
{
|
||||
url: undefined,
|
||||
x: browserRect.width / 2,
|
||||
y: browserRect.height / 2,
|
||||
...(gZenUIManager._lastClickPosition || {
|
||||
clientX: browserRect.width / 2,
|
||||
clientY: browserRect.height / 2,
|
||||
}),
|
||||
width: 0,
|
||||
height: 0,
|
||||
},
|
||||
|
@ -639,7 +641,12 @@
|
|||
.classList.remove('zen-glance-background');
|
||||
this.#currentParentTab._visuallySelected = false;
|
||||
this.hideSidebarButtons();
|
||||
if (forSplit) {
|
||||
this.finishOpeningGlance();
|
||||
return;
|
||||
}
|
||||
if (gReduceMotion || forSplit) {
|
||||
gZenViewSplitter.deactivateCurrentSplitView();
|
||||
this.finishOpeningGlance();
|
||||
return;
|
||||
}
|
||||
|
@ -654,6 +661,7 @@
|
|||
type: 'spring',
|
||||
}
|
||||
);
|
||||
gZenViewSplitter.deactivateCurrentSplitView();
|
||||
this.finishOpeningGlance();
|
||||
}
|
||||
|
||||
|
@ -678,8 +686,8 @@
|
|||
const rect = event.target.getBoundingClientRect();
|
||||
const data = {
|
||||
url: event.target._placesNode.uri,
|
||||
x: rect.left,
|
||||
y: rect.top,
|
||||
clientX: rect.left,
|
||||
clientY: rect.top,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
};
|
||||
|
@ -737,6 +745,32 @@
|
|||
}
|
||||
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();
|
||||
|
|
|
@ -74,8 +74,8 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
|||
const rect = target.getBoundingClientRect();
|
||||
this.sendAsyncMessage('ZenGlance:OpenGlance', {
|
||||
url,
|
||||
x: rect.left,
|
||||
y: rect.top,
|
||||
clientX: rect.left,
|
||||
clientY: rect.top,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
});
|
||||
|
|
|
@ -159,6 +159,11 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
|
|||
const tab = event.target;
|
||||
if (tab.group?.hasAttribute('split-view-group')) {
|
||||
gBrowser.explicitUnloadTabs(tab.group.tabs);
|
||||
for (const t of tab.group.tabs) {
|
||||
if (t.glanceTab) {
|
||||
gBrowser.explicitUnloadTabs([t.glanceTab]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ function openGlanceOnTab(callback, close = true) {
|
|||
gZenGlanceManager
|
||||
.openGlance({
|
||||
url: 'https://example.com',
|
||||
x: 0,
|
||||
y: 0,
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue