diff options
Diffstat (limited to 'ext/fg/js')
-rw-r--r-- | ext/fg/js/float.js | 60 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 10 | ||||
-rw-r--r-- | ext/fg/js/popup.js | 9 |
3 files changed, 7 insertions, 72 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index bc555ffd..195861a3 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -23,8 +23,7 @@ class DisplayFloat extends Display { constructor() { - super(); - this._nestedPopupsPrepared = false; + super('popup'); this._frameEndpoint = new FrameEndpoint(); this._windowMessageHandlers = new Map([ ['extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}] @@ -48,10 +47,6 @@ class DisplayFloat extends Display { const {browser} = await api.getEnvironmentInfo(); this._browser = browser; - this.registerDirectMessageHandlers([ - ['configure', {async: true, handler: this._onMessageConfigure.bind(this)}], - ['setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}] - ]); window.addEventListener('message', this._onWindowMessage.bind(this), false); document.documentElement.addEventListener('mouseup', this._onMouseUp.bind(this), false); document.documentElement.addEventListener('click', this._onClick.bind(this), false); @@ -101,23 +96,6 @@ class DisplayFloat extends Display { yomichan.invokeMessageHandler(messageHandler, params, callback); } - async _onMessageConfigure({frameId, ownerFrameId, popupId, optionsContext, childrenSupported, scale}) { - this.ownerFrameId = ownerFrameId; - await this.setOptionsContext(optionsContext); - - if (childrenSupported && !this._nestedPopupsPrepared) { - const {depth} = optionsContext; - this._prepareNestedPopups(depth + 1, popupId, frameId); - this._nestedPopupsPrepared = true; - } - - this._setContentScale(scale); - } - - _onMessageSetContentScale({scale}) { - this._setContentScale(scale); - } - _onMessageExtensionUnloaded() { if (yomichan.isExtensionUnloaded) { return; } yomichan.triggerExtensionUnloaded(); @@ -200,42 +178,6 @@ class DisplayFloat extends Display { parent.removeChild(textarea); } - _setContentScale(scale) { - const body = document.body; - if (body === null) { return; } - body.style.fontSize = `${scale}em`; - } - - 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); - if (maxPopupDepthExceeded || complete) { return; } - - complete = true; - yomichan.off('optionsUpdated', onOptionsUpdated); - - try { - await this.setupNestedPopups({ - depth, - parentPopupId, - parentFrameId, - useProxyPopup: true, - pageType: 'popup' - }); - } catch (e) { - yomichan.logError(e); - } - }; - - yomichan.on('optionsUpdated', onOptionsUpdated); - - await onOptionsUpdated(); - } - _invokeOwner(action, params={}) { return api.crossFrame.invoke(this.ownerFrameId, action, params); } diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 2ee9b4a1..e4c6342e 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -379,10 +379,6 @@ class Frontend { } if (this._updatePopupToken !== token) { return; } - if (this._pageType === 'search') { - this.setDisabledOverride(!this._options.scanning.enableOnSearchPage); - } - this._clearSelection(true); this._popupEventListeners.removeAllEventListeners(); this._popup = popup; @@ -525,11 +521,7 @@ class Frontend { } _updateTextScannerEnabled() { - const enabled = ( - this._options.general.enable && - this._depth <= this._options.scanning.popupNestingMaxDepth && - !this._disabledOverride - ); + const enabled = (this._options.general.enable && !this._disabledOverride); this._textScanner.setEnabled(enabled); } diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 826457c1..2feb220d 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -255,12 +255,13 @@ class Popup extends EventDispatcher { // Configure await this._invokeSafe('configure', { - frameId: this._frameId, + depth: this._depth, + parentPopupId: this._id, + parentFrameId: this._frameId, ownerFrameId: this._ownerFrameId, - popupId: this._id, - optionsContext: this._optionsContext, childrenSupported: this._childrenSupported, - scale: this._contentScale + scale: this._contentScale, + optionsContext: this._optionsContext }); } |