aboutsummaryrefslogtreecommitdiff
path: root/ext/js/app/popup-factory.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-18 07:58:59 -0500
committerGitHub <noreply@github.com>2024-02-18 12:58:59 +0000
commit7e9f7e2616973418cc50f7706bd8f644cb9d5559 (patch)
tree8f8bec7a777a2df33a0a26ef53022c50d2327ef8 /ext/js/app/popup-factory.js
parent4aaa9f15d97668203741c1731f15e710ae8b8294 (diff)
Application data refactor (#699)
* Pass tabId and frameId to Application * Remove casts * Remove redundant frameInformationGet calls * Expose tabId and frameId * Remove unsed * Simplify * Update FrameAncestryHandler to not need a direct frameId * Remove frameId from FrameOffsetForwarder * Remove frameId from PopupFactory * Remove frameId from Frontend * Remove frameId from PopupPreviewFrame * Fix PopupFactory and Frontend constructor * Remove frameId from Display * Remove frameId from SearchDisplayController * Restore if check
Diffstat (limited to 'ext/js/app/popup-factory.js')
-rw-r--r--ext/js/app/popup-factory.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/js/app/popup-factory.js b/ext/js/app/popup-factory.js
index c5187291..4338bb3a 100644
--- a/ext/js/app/popup-factory.js
+++ b/ext/js/app/popup-factory.js
@@ -29,15 +29,12 @@ export class PopupFactory {
/**
* Creates a new instance.
* @param {import('../application.js').Application} application
- * @param {number} frameId The frame ID of the host frame.
*/
- constructor(application, frameId) {
+ constructor(application) {
/** @type {import('../application.js').Application} */
this._application = application;
- /** @type {number} */
- this._frameId = frameId;
/** @type {FrameOffsetForwarder} */
- this._frameOffsetForwarder = new FrameOffsetForwarder(application.crossFrame, frameId);
+ this._frameOffsetForwarder = new FrameOffsetForwarder(application.crossFrame);
/** @type {Map<string, import('popup').PopupAny>} */
this._popups = new Map();
/** @type {Map<string, {popup: import('popup').PopupAny, token: string}[]>} */
@@ -115,6 +112,9 @@ export class PopupFactory {
depth = 0;
}
+ const currentFrameId = this._application.frameId;
+ if (currentFrameId === null) { throw new Error('Cannot create popup: no frameId'); }
+
if (popupWindow) {
// New unique id
if (id === null) {
@@ -124,11 +124,11 @@ export class PopupFactory {
application: this._application,
id,
depth,
- frameId: this._frameId
+ frameId: currentFrameId
});
this._popups.set(id, popup);
return popup;
- } else if (frameId === this._frameId) {
+ } else if (frameId === currentFrameId) {
// New unique id
if (id === null) {
id = generateId(16);
@@ -137,7 +137,7 @@ export class PopupFactory {
application: this._application,
id,
depth,
- frameId: this._frameId,
+ frameId: currentFrameId,
childrenSupported
});
if (parent !== null) {
@@ -155,13 +155,12 @@ export class PopupFactory {
throw new Error('Invalid frameId');
}
const useFrameOffsetForwarder = (parentPopupId === null);
- /** @type {{id: string, depth: number, frameId: number}} */
- const info = await this._application.crossFrame.invoke(frameId, 'popupFactoryGetOrCreatePopup', /** @type {import('popup-factory').GetOrCreatePopupDetails} */ ({
+ const info = await this._application.crossFrame.invoke(frameId, 'popupFactoryGetOrCreatePopup', {
id,
parentPopupId,
frameId,
childrenSupported
- }));
+ });
id = info.id;
const popup = new PopupProxy({
application: this._application,