diff options
-rw-r--r-- | ext/fg/js/float.js | 2 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 3 | ||||
-rw-r--r-- | ext/fg/js/popup-proxy-host.js | 8 | ||||
-rw-r--r-- | ext/fg/js/popup-proxy.js | 5 | ||||
-rw-r--r-- | ext/fg/js/popup.js | 18 |
5 files changed, 17 insertions, 19 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8871160f..b42ab8ee 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -46,7 +46,7 @@ class DisplayFloat extends Display { this.setContentScale(scale); - window.parent.postMessage('initialized', '*'); + apiForward('popupSetDisplayInitialized'); } onError(error) { diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 2286bf19..571bbf91 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -243,5 +243,6 @@ Frontend._windowMessageHandlers = new Map([ ]); Frontend._runtimeMessageHandlers = new Map([ - ['popupSetVisibleOverride', (self, {visible}) => { self.popup.setVisibleOverride(visible); }] + ['popupSetVisibleOverride', (self, {visible}) => { self.popup.setVisibleOverride(visible); }], + ['popupSetDisplayInitialized', (self) => { self.popup.setDisplayInitialized(); }] ]); diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 427172c6..8ea70857 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -42,7 +42,8 @@ class PopupProxyHost { ['showContent', ({id, elementRect, writingMode, type, details}) => this._onApiShowContent(id, elementRect, writingMode, type, details)], ['setCustomCss', ({id, css}) => this._onApiSetCustomCss(id, css)], ['clearAutoPlayTimer', ({id}) => this._onApiClearAutoPlayTimer(id)], - ['setContentScale', ({id, scale}) => this._onApiSetContentScale(id, scale)] + ['setContentScale', ({id, scale}) => this._onApiSetContentScale(id, scale)], + ['setDisplayInitialized', ({id}) => this._onApiSetDisplayInitialized(id)] ])); } @@ -103,6 +104,11 @@ class PopupProxyHost { return popup.setContentScale(scale); } + async _onApiSetDisplayInitialized(id) { + const popup = this._getPopup(id); + return popup.setDisplayInitialized(); + } + // Private functions _createPopupInternal(parentId, depth) { diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 63aa6bbe..f1743064 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -102,6 +102,11 @@ class PopupProxy { this._invokeHostApi('setContentScale', {id, scale}); } + async setDisplayInitialized() { + const id = await this._getPopupId(); + this._invokeHostApi('setDisplayInitialized', {id}); + } + // Private _getPopupId() { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index ad4e5181..b8233cc2 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -43,8 +43,6 @@ class Popup { this._container.style.height = '0px'; this._updateVisibility(); - - window.addEventListener('message', (e) => this.onMessage(e), false); } // Public properties @@ -125,15 +123,7 @@ class Popup { this._invokeApi('setContentScale', {scale}); } - onMessage(e) { - const action = e.data; - const handler = Popup._windowMessageHandlers.get(action); - if (typeof handler !== 'function') { return; } - - handler(this); - } - - setInitialized() { + setDisplayInitialized() { throw new Error('Override me'); } @@ -244,7 +234,7 @@ class Popup { childrenSupported: this._childrenSupported, scale: this._contentScale }); - this.setInitialized = resolve; + this.setDisplayInitialized = resolve; }); this._observeFullscreen(); this._onFullscreenChanged(); @@ -540,8 +530,4 @@ class Popup { } } -Popup._windowMessageHandlers = new Map([ - ['initialized', (self) => self.setInitialized()] -]); - Popup.outerStylesheet = null; |