summaryrefslogtreecommitdiff
path: root/ext/fg/js/popup-proxy.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/popup-proxy.js')
-rw-r--r--ext/fg/js/popup-proxy.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index 3387d941..14ddcafb 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -19,14 +19,14 @@
* api
*/
-class PopupProxy {
- constructor(id, depth, parentPopupId, parentFrameId, getFrameOffset=null, setDisabled=null) {
+class PopupProxy extends EventDispatcher {
+ constructor(id, depth, parentPopupId, parentFrameId, frameOffsetForwarder=null) {
+ super();
this._id = id;
this._depth = depth;
this._parentPopupId = parentPopupId;
this._parentFrameId = parentFrameId;
- this._getFrameOffset = getFrameOffset;
- this._setDisabled = setDisabled;
+ this._frameOffsetForwarder = frameOffsetForwarder;
this._frameOffset = null;
this._frameOffsetPromise = null;
@@ -75,7 +75,7 @@ class PopupProxy {
}
async containsPoint(x, y) {
- if (this._getFrameOffset !== null) {
+ if (this._frameOffsetForwarder !== null) {
await this._updateFrameOffset();
[x, y] = this._applyFrameOffset(x, y);
}
@@ -84,7 +84,7 @@ class PopupProxy {
async showContent(elementRect, writingMode, type, details, context) {
let {x, y, width, height} = elementRect;
- if (this._getFrameOffset !== null) {
+ if (this._frameOffsetForwarder !== null) {
await this._updateFrameOffset();
[x, y] = this._applyFrameOffset(x, y);
}
@@ -134,12 +134,12 @@ class PopupProxy {
}
async _updateFrameOffsetInner(now) {
- this._frameOffsetPromise = this._getFrameOffset();
+ this._frameOffsetPromise = this._frameOffsetForwarder.getOffset();
try {
const offset = await this._frameOffsetPromise;
this._frameOffset = offset !== null ? offset : [0, 0];
- if (offset === null && this._setDisabled !== null) {
- this._setDisabled();
+ if (offset === null) {
+ this.trigger('offsetNotFound');
return;
}
this._frameOffsetUpdatedAt = now;