summaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/app/popup-proxy.js7
-rw-r--r--ext/js/comm/frame-offset-forwarder.js33
2 files changed, 20 insertions, 20 deletions
diff --git a/ext/js/app/popup-proxy.js b/ext/js/app/popup-proxy.js
index 85014c47..3e95ff2a 100644
--- a/ext/js/app/popup-proxy.js
+++ b/ext/js/app/popup-proxy.js
@@ -316,12 +316,7 @@ class PopupProxy extends EventDispatcher {
async _updateFrameOffsetInner(now) {
this._frameOffsetPromise = this._frameOffsetForwarder.getOffset();
try {
- let offset = null;
- try {
- offset = await this._frameOffsetPromise;
- } catch (e) {
- // NOP
- }
+ const offset = await this._frameOffsetPromise;
this._frameOffset = offset !== null ? offset : [0, 0];
if (offset === null) {
this.trigger('offsetNotFound');
diff --git a/ext/js/comm/frame-offset-forwarder.js b/ext/js/comm/frame-offset-forwarder.js
index dd064a64..d8e3fa4f 100644
--- a/ext/js/comm/frame-offset-forwarder.js
+++ b/ext/js/comm/frame-offset-forwarder.js
@@ -37,24 +37,29 @@ class FrameOffsetForwarder {
return [0, 0];
}
- const ancestorFrameIds = await this._frameAncestryHandler.getFrameAncestryInfo();
+ try {
+ const ancestorFrameIds = await this._frameAncestryHandler.getFrameAncestryInfo();
- let childFrameId = this._frameId;
- const promises = [];
- for (const frameId of ancestorFrameIds) {
- promises.push(yomichan.crossFrame.invoke(frameId, 'FrameOffsetForwarder.getChildFrameRect', {frameId: childFrameId}));
- childFrameId = frameId;
- }
+ let childFrameId = this._frameId;
+ const promises = [];
+ for (const frameId of ancestorFrameIds) {
+ promises.push(yomichan.crossFrame.invoke(frameId, 'FrameOffsetForwarder.getChildFrameRect', {frameId: childFrameId}));
+ childFrameId = frameId;
+ }
- const results = await Promise.all(promises);
+ const results = await Promise.all(promises);
- let xOffset = 0;
- let yOffset = 0;
- for (const {x, y} of results) {
- xOffset += x;
- yOffset += y;
+ let x = 0;
+ let y = 0;
+ for (const result of results) {
+ if (result === null) { return null; }
+ x += result.x;
+ y += result.y;
+ }
+ return [x, y];
+ } catch (e) {
+ return null;
}
- return [xOffset, yOffset];
}
// Private