From 7e9f7e2616973418cc50f7706bd8f644cb9d5559 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 18 Feb 2024 07:58:59 -0500 Subject: 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 --- ext/js/app/frontend.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'ext/js/app/frontend.js') diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 84a8f1e6..1a3fbbe1 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -39,8 +39,6 @@ export class Frontend { pageType, popupFactory, depth, - tabId, - frameId, parentPopupId, parentFrameId, useProxyPopup, @@ -57,10 +55,6 @@ export class Frontend { this._popupFactory = popupFactory; /** @type {number} */ this._depth = depth; - /** @type {number|undefined} */ - this._tabId = tabId; - /** @type {number} */ - this._frameId = frameId; /** @type {?string} */ this._parentPopupId = parentPopupId; /** @type {?number} */ @@ -588,8 +582,13 @@ export class Frontend { return null; } + const {frameId} = this._application; + if (frameId === null) { + return null; + } + return await this._popupFactory.getOrCreatePopup({ - frameId: this._frameId, + frameId, depth: this._depth, childrenSupported: this._childrenSupported }); @@ -703,12 +702,10 @@ export class Frontend { }; if (sentence !== null) { detailsState.sentence = sentence; } if (documentTitle !== null) { detailsState.documentTitle = documentTitle; } + const {tabId, frameId} = this._application; /** @type {import('display').HistoryContent} */ const detailsContent = { - contentOrigin: { - tabId: this._tabId, - frameId: this._frameId - } + contentOrigin: {tabId, frameId} }; if (dictionaryEntries !== null) { detailsContent.dictionaryEntries = dictionaryEntries; @@ -819,7 +816,7 @@ export class Frontend { */ _signalFrontendReady(targetFrameId) { /** @type {import('application').ApiMessageNoFrameId<'frontendReady'>} */ - const message = {action: 'frontendReady', params: {frameId: this._frameId}}; + const message = {action: 'frontendReady', params: {frameId: this._application.frameId}}; if (targetFrameId === null) { this._application.api.broadcastTab(message); } else { @@ -867,7 +864,7 @@ export class Frontend { } chrome.runtime.onMessage.addListener(onMessage); - this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._frameId}}); + this._application.api.broadcastTab({action: 'frontendRequestReadyBroadcast', params: {frameId: this._application.frameId}}); }); } -- cgit v1.2.3