fix and simplify

This commit is contained in:
siikamiika 2020-03-19 15:29:49 +02:00
parent 4814db8df1
commit b996d0b1e0
3 changed files with 7 additions and 13 deletions

View File

@ -77,6 +77,7 @@ class Frontend extends TextScanner {
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
this._updateContentScale(); this._updateContentScale();
this.popup.broadcastRootPopupInformation();
} catch (e) { } catch (e) {
this.onError(e); this.onError(e);
} }

View File

@ -61,6 +61,10 @@ class PopupProxy {
return true; return true;
} }
broadcastRootPopupInformation() {
// NOP
}
async setOptions(options) { async setOptions(options) {
const id = await this._getPopupId(); const id = await this._getPopupId();
return await this._invokeHostApi('setOptions', {id, options}); return await this._invokeHostApi('setOptions', {id, options});
@ -97,11 +101,11 @@ class PopupProxy {
async showContent(elementRect, writingMode, type=null, details=null) { async showContent(elementRect, writingMode, type=null, details=null) {
const id = await this._getPopupId(); const id = await this._getPopupId();
let {x, y, width, height} = PopupProxy._convertDOMRectToJson(elementRect); let {x, y, width, height} = elementRect;
if (this._depth === 0) { if (this._depth === 0) {
[x, y] = await PopupProxy._convertIframePointToRootPagePoint(x, y); [x, y] = await PopupProxy._convertIframePointToRootPagePoint(x, y);
elementRect = {x, y, width, height};
} }
elementRect = {x, y, width, height};
return await this._invokeHostApi('showContent', {id, elementRect, writingMode, type, details}); return await this._invokeHostApi('showContent', {id, elementRect, writingMode, type, details});
} }
@ -197,13 +201,4 @@ class PopupProxy {
return offset; return offset;
} }
static _convertDOMRectToJson(domRect) {
return {
x: domRect.x,
y: domRect.y,
width: domRect.width,
height: domRect.height
};
}
} }

View File

@ -199,8 +199,6 @@ class Popup {
} }
async _createInjectPromise() { async _createInjectPromise() {
this.broadcastRootPopupInformation();
if (this._messageToken === null) { if (this._messageToken === null) {
this._messageToken = await apiGetMessageToken(); this._messageToken = await apiGetMessageToken();
} }