aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/content-script-main.js11
-rw-r--r--ext/fg/js/float.js13
-rw-r--r--ext/fg/js/frontend.js25
3 files changed, 26 insertions, 23 deletions
diff --git a/ext/fg/js/content-script-main.js b/ext/fg/js/content-script-main.js
index 4db41cb9..84e78392 100644
--- a/ext/fg/js/content-script-main.js
+++ b/ext/fg/js/content-script-main.js
@@ -34,11 +34,16 @@
const popupFactory = new PopupFactory(frameId);
popupFactory.prepare();
- const frontend = new Frontend(
+ const frontend = new Frontend({
frameId,
popupFactory,
- {}
- );
+ depth: 0,
+ parentPopupId: null,
+ parentFrameId: null,
+ useProxyPopup: false,
+ isSearchPage: false,
+ allowRootFramePopupProxy: true
+ });
await frontend.prepare();
yomichan.ready();
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 8a17a437..8526c9c1 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -105,8 +105,8 @@ class DisplayFloat extends Display {
await this.updateOptions();
if (childrenSupported && !this._nestedPopupsPrepared) {
- const {depth, url} = optionsContext;
- this._prepareNestedPopups(popupId, depth, frameId, url);
+ const {depth} = optionsContext;
+ this._prepareNestedPopups(depth + 1, popupId, frameId);
this._nestedPopupsPrepared = true;
}
@@ -168,13 +168,13 @@ class DisplayFloat extends Display {
body.style.fontSize = `${scale}em`;
}
- async _prepareNestedPopups(id, depth, parentFrameId, url) {
+ async _prepareNestedPopups(depth, parentPopupId, parentFrameId) {
let complete = false;
const onOptionsUpdated = async () => {
const optionsContext = this.getOptionsContext();
const options = await api.optionsGet(optionsContext);
- const maxPopupDepthExceeded = !(typeof depth === 'number' && depth < options.scanning.popupNestingMaxDepth);
+ const maxPopupDepthExceeded = !(typeof depth === 'number' && depth <= options.scanning.popupNestingMaxDepth);
if (maxPopupDepthExceeded || complete) { return; }
complete = true;
@@ -182,11 +182,10 @@ class DisplayFloat extends Display {
try {
await this.setupNestedPopups({
- id,
depth,
+ parentPopupId,
parentFrameId,
- url,
- proxy: true
+ useProxyPopup: true
});
} catch (e) {
yomichan.logError(e);
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 21fbc718..36b1898b 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -25,7 +25,16 @@
*/
class Frontend {
- constructor(frameId, popupFactory, frontendInitializationData) {
+ constructor({
+ frameId,
+ popupFactory,
+ depth,
+ parentPopupId,
+ parentFrameId,
+ useProxyPopup,
+ isSearchPage,
+ allowRootFramePopupProxy
+ }) {
this._id = yomichan.generateId(16);
this._popup = null;
this._disabledOverride = false;
@@ -43,16 +52,7 @@ class Frontend {
search: this._search.bind(this),
documentUtil: this._documentUtil
});
-
- const {
- depth=0,
- id: proxyPopupId,
- parentFrameId,
- proxy: useProxyPopup=false,
- isSearchPage=false,
- allowRootFramePopupProxy=true
- } = frontendInitializationData;
- this._proxyPopupId = proxyPopupId;
+ this._parentPopupId = parentPopupId;
this._parentFrameId = parentFrameId;
this._useProxyPopup = useProxyPopup;
this._isSearchPage = isSearchPage;
@@ -320,7 +320,6 @@ class Frontend {
this._textScanner.clearSelection(true);
this._popup = popup;
- this._depth = popup.depth;
}
async _getDefaultPopup() {
@@ -328,7 +327,7 @@ class Frontend {
}
async _getProxyPopup() {
- const popup = new PopupProxy(null, this._depth + 1, this._proxyPopupId, this._parentFrameId, this._frameId);
+ const popup = new PopupProxy(null, this._depth, this._parentPopupId, this._parentFrameId, this._frameId);
await popup.prepare();
return popup;
}