summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup-proxy-host.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/popup-proxy-host.js')
-rw-r--r--ext/fg/js/popup-proxy-host.js37
1 files changed, 15 insertions, 22 deletions
diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js
index bb323f64..d8dec4df 100644
--- a/ext/fg/js/popup-proxy-host.js
+++ b/ext/fg/js/popup-proxy-host.js
@@ -39,21 +39,22 @@ class PopupProxyHost {
this.apiReceiver = new FrontendApiReceiver(`popup-proxy-host#${frameId}`, {
createNestedPopup: ({parentId}) => this.createNestedPopup(parentId),
setOptions: ({id, options}) => this.setOptions(id, options),
- showOrphaned: ({id, elementRect}) => this.showOrphaned(id, elementRect),
hide: ({id, changeFocus}) => this.hide(id, changeFocus),
+ isVisibleAsync: ({id}) => this.isVisibleAsync(id),
setVisibleOverride: ({id, visible}) => this.setVisibleOverride(id, visible),
containsPoint: ({id, x, y}) => this.containsPoint(id, x, y),
- termsShow: ({id, elementRect, writingMode, definitions, context}) => this.termsShow(id, elementRect, writingMode, definitions, context),
- kanjiShow: ({id, elementRect, writingMode, definitions, context}) => this.kanjiShow(id, elementRect, writingMode, definitions, context),
+ showContent: ({id, elementRect, writingMode, type, details}) => this.showContent(id, elementRect, writingMode, type, details),
setCustomCss: ({id, css}) => this.setCustomCss(id, css),
clearAutoPlayTimer: ({id}) => this.clearAutoPlayTimer(id)
});
}
- createPopup(parentId) {
+ createPopup(parentId, depth) {
const parent = (typeof parentId === 'string' && this.popups.hasOwnProperty(parentId) ? this.popups[parentId] : null);
- const depth = (parent !== null ? parent.depth + 1 : 0);
const id = `${this.nextId}`;
+ if (parent !== null) {
+ depth = parent.depth + 1;
+ }
++this.nextId;
const popup = new Popup(id, depth, this.frameIdPromise);
if (parent !== null) {
@@ -65,7 +66,7 @@ class PopupProxyHost {
}
async createNestedPopup(parentId) {
- return this.createPopup(parentId).id;
+ return this.createPopup(parentId, 0).id;
}
getPopup(id) {
@@ -92,20 +93,19 @@ class PopupProxyHost {
return await popup.setOptions(options);
}
- async showOrphaned(id, elementRect) {
+ async hide(id, changeFocus) {
const popup = this.getPopup(id);
- elementRect = this.jsonRectToDOMRect(popup, elementRect);
- return await popup.showOrphaned(elementRect);
+ return popup.hide(changeFocus);
}
- async hide(id, changeFocus) {
+ async isVisibleAsync(id) {
const popup = this.getPopup(id);
- return popup.hide(changeFocus);
+ return await popup.isVisibleAsync();
}
async setVisibleOverride(id, visible) {
const popup = this.getPopup(id);
- return popup.setVisibleOverride(visible);
+ return await popup.setVisibleOverride(visible);
}
async containsPoint(id, x, y) {
@@ -113,18 +113,11 @@ class PopupProxyHost {
return await popup.containsPoint(x, y);
}
- async termsShow(id, elementRect, writingMode, definitions, context) {
- const popup = this.getPopup(id);
- elementRect = this.jsonRectToDOMRect(popup, elementRect);
- if (!PopupProxyHost.popupCanShow(popup)) { return false; }
- return await popup.termsShow(elementRect, writingMode, definitions, context);
- }
-
- async kanjiShow(id, elementRect, writingMode, definitions, context) {
+ async showContent(id, elementRect, writingMode, type, details) {
const popup = this.getPopup(id);
elementRect = this.jsonRectToDOMRect(popup, elementRect);
- if (!PopupProxyHost.popupCanShow(popup)) { return false; }
- return await popup.kanjiShow(elementRect, writingMode, definitions, context);
+ if (!PopupProxyHost.popupCanShow(popup)) { return Promise.resolve(false); }
+ return await popup.showContent(elementRect, writingMode, type, details);
}
async setCustomCss(id, css) {