* Get the relative position of a specific element in the page (iframes included) * * @param {StackingContext} context * @return {Object} The relative position of the context frame
(context)
| 66 | * @return {Object} The relative position of the context frame |
| 67 | */ |
| 68 | function getRelativePosition(context) { |
| 69 | let relativePosition = { top: 0, left: 0 }; |
| 70 | let current = context; |
| 71 | |
| 72 | while (current) { |
| 73 | if (current.frame == null) break; |
| 74 | |
| 75 | if (current.type === "container") { |
| 76 | let frameBCR = current.frame.getBoundingClientRect(); |
| 77 | relativePosition.top += frameBCR.top; |
| 78 | relativePosition.left += frameBCR.left; |
| 79 | } |
| 80 | |
| 81 | current = current.parent; |
| 82 | } |
| 83 | |
| 84 | return relativePosition; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Remove the highlight element from the page. |