Skip to content

Commit

Permalink
💄 Add support for showing browser frame tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
kierandrewett committed Jan 17, 2024
1 parent 41ec9c3 commit 7113cc8
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions base/content/browser-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ class nsIXULBrowserWindow {
return document.createElement("div");
}

/**
* The remote browser tooltip element
*/
get tooltipElement() {
return /** @type {import("third_party/dothq/gecko-types/lib").XULPopupElement} */ (
document.documentElement.querySelector("#remoteBrowserTooltip") ||
(() => {
const tooltip = document.createXULElement("tooltip");
tooltip.id = "remoteBrowserTooltip";
return tooltip;
})()
);
}

/**
* @param {string} status
*/
Expand Down Expand Up @@ -102,12 +116,12 @@ class nsIXULBrowserWindow {
* Opens a tooltip at a location for a browser
* @param {number} x
* @param {number} y
* @param {HTMLElement} tooltip
* @param {string} label
* @param {CSSStyleDeclaration["direction"]} direction
* @param {ChromeBrowser} browser
* @returns
*/
showTooltip(x, y, tooltip, direction, browser) {
showTooltip(x, y, label, direction, browser) {
if (
Cc["@mozilla.org/widget/dragservice;1"]
.getService(Ci.nsIDragService)
Expand All @@ -116,11 +130,22 @@ class nsIXULBrowserWindow {
return;
}

console.log(x, y, tooltip, direction, browser);
if (!document.hasFocus()) return;

document.documentElement.appendChild(this.tooltipElement);

this.tooltipElement.label = label;
this.tooltipElement.style.direction = direction;
this.tooltipElement.openPopupAtScreen(
x / window.devicePixelRatio,
y / window.devicePixelRatio,
false,
null
);
}

hideTooltip() {
console.log("XULBrowserWindow.hideTooltip: stub");
this.tooltipElement.hidePopup();
}

getTabCount() {
Expand Down

0 comments on commit 7113cc8

Please sign in to comment.