diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-15 21:59:37 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-10-15 21:59:37 +0900 |
commit | 45b3b0510fd0babe392ee46319fa345433af7736 (patch) | |
tree | dd6b02c82125bfabc9f2c2360a7993c99f7a053c /src/content/components/top-content/follow-controller.js | |
parent | ac5354020e5efdf6e284d4b36696b9f94d46bef9 (diff) |
follow links for multi-frames in viewport
Diffstat (limited to 'src/content/components/top-content/follow-controller.js')
-rw-r--r-- | src/content/components/top-content/follow-controller.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/content/components/top-content/follow-controller.js b/src/content/components/top-content/follow-controller.js index 0474690..29f40b3 100644 --- a/src/content/components/top-content/follow-controller.js +++ b/src/content/components/top-content/follow-controller.js @@ -87,8 +87,24 @@ export default class FollowController { count() { this.producer = new HintKeyProducer(DEFAULT_HINT_CHARSET); - broadcastMessage(this.win, { + let doc = this.win.document; + let viewWidth = this.win.innerWidth || doc.documentElement.clientWidth; + let viewHeight = this.win.innerHeight || doc.documentElement.clientHeight; + let frameElements = this.win.document.querySelectorAll('frame,iframe'); + + this.win.postMessage(JSON.stringify({ type: messages.FOLLOW_REQUEST_COUNT_TARGETS, + viewSize: { width: viewWidth, height: viewHeight }, + framePosition: { x: 0, y: 0 }, + }), '*'); + frameElements.forEach((element) => { + let { left: frameX, top: frameY } = element.getBoundingClientRect(); + let message = JSON.stringify({ + type: messages.FOLLOW_REQUEST_COUNT_TARGETS, + viewSize: { width: viewWidth, height: viewHeight }, + framePosition: { x: frameX, y: frameY }, + }); + element.contentWindow.postMessage(message, '*'); }); } |