prevent spawning multiple FrameOffsetForwarders
This commit is contained in:
parent
e627ab2537
commit
362ac84e6c
@ -24,7 +24,7 @@
|
|||||||
* apiOptionsGet
|
* apiOptionsGet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async function createIframePopupProxy(url) {
|
async function createIframePopupProxy(url, frameOffsetForwarder) {
|
||||||
const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
|
const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
|
||||||
chrome.runtime.onMessage,
|
chrome.runtime.onMessage,
|
||||||
({action, params}, {resolve}) => {
|
({action, params}, {resolve}) => {
|
||||||
@ -36,8 +36,6 @@ async function createIframePopupProxy(url) {
|
|||||||
apiBroadcastTab('rootPopupRequestInformationBroadcast');
|
apiBroadcastTab('rootPopupRequestInformationBroadcast');
|
||||||
const {popupId, frameId} = await rootPopupInformationPromise;
|
const {popupId, frameId} = await rootPopupInformationPromise;
|
||||||
|
|
||||||
const frameOffsetForwarder = new FrameOffsetForwarder();
|
|
||||||
frameOffsetForwarder.start();
|
|
||||||
const getFrameOffset = frameOffsetForwarder.getOffset.bind(frameOffsetForwarder);
|
const getFrameOffset = frameOffsetForwarder.getOffset.bind(frameOffsetForwarder);
|
||||||
|
|
||||||
const popup = new PopupProxy(popupId, 0, null, frameId, url, getFrameOffset);
|
const popup = new PopupProxy(popupId, 0, null, frameId, url, getFrameOffset);
|
||||||
@ -47,9 +45,6 @@ async function createIframePopupProxy(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getOrCreatePopup(depth) {
|
async function getOrCreatePopup(depth) {
|
||||||
const frameOffsetForwarder = new FrameOffsetForwarder();
|
|
||||||
frameOffsetForwarder.start();
|
|
||||||
|
|
||||||
const popupHost = new PopupProxyHost();
|
const popupHost = new PopupProxyHost();
|
||||||
await popupHost.prepare();
|
await popupHost.prepare();
|
||||||
|
|
||||||
@ -81,14 +76,20 @@ async function main() {
|
|||||||
|
|
||||||
let frontend = null;
|
let frontend = null;
|
||||||
let frontendPreparePromise = null;
|
let frontendPreparePromise = null;
|
||||||
|
let frameOffsetForwarder = null;
|
||||||
|
|
||||||
const applyOptions = async () => {
|
const applyOptions = async () => {
|
||||||
const optionsContext = {depth: isSearchPage ? 0 : depth, url};
|
const optionsContext = {depth: isSearchPage ? 0 : depth, url};
|
||||||
const options = await apiOptionsGet(optionsContext);
|
const options = await apiOptionsGet(optionsContext);
|
||||||
|
|
||||||
|
if (!proxy && frameOffsetForwarder === null) {
|
||||||
|
frameOffsetForwarder = new FrameOffsetForwarder();
|
||||||
|
frameOffsetForwarder.start();
|
||||||
|
}
|
||||||
|
|
||||||
let popup;
|
let popup;
|
||||||
if (isIframe && options.general.showIframePopupsInRootFrame) {
|
if (isIframe && options.general.showIframePopupsInRootFrame) {
|
||||||
popup = popups.iframe || await createIframePopupProxy(url);
|
popup = popups.iframe || await createIframePopupProxy(url, frameOffsetForwarder);
|
||||||
popups.iframe = popup;
|
popups.iframe = popup;
|
||||||
} else if (proxy) {
|
} else if (proxy) {
|
||||||
popup = popups.proxy || await createPopupProxy(depth, id, parentFrameId, url);
|
popup = popups.proxy || await createPopupProxy(depth, id, parentFrameId, url);
|
||||||
|
Loading…
Reference in New Issue
Block a user