* Get the element's layout rect relative to the viewport. Attempt to walk up * the DOM and add the offset of all nested parent iframes since * getBoundingClientRect() is only relative to the immediate window. Assumes * that all parent frames are friendly and can be inspected (because the
(element)
| 115 | * @return {!LayoutRectDef} |
| 116 | */ |
| 117 | getTargetRect(element) { |
| 118 | let targetRect = layoutRectFromDomRect( |
| 119 | element./*OK*/ getBoundingClientRect() |
| 120 | ); |
| 121 | const parentWin = element.ownerDocument.defaultView; |
| 122 | for ( |
| 123 | let j = 0, tempWin = parentWin; |
| 124 | j < 10 && |
| 125 | // win can be null if the ad iframe is already destroyed |
| 126 | tempWin && |
| 127 | tempWin != this.win_ && |
| 128 | tempWin != this.win_.top; |
| 129 | j++, tempWin = tempWin.parent |
| 130 | ) { |
| 131 | const parentFrameRect = layoutRectFromDomRect( |
| 132 | tempWin.frameElement./*OK*/ getBoundingClientRect() |
| 133 | ); |
| 134 | targetRect = moveLayoutRect( |
| 135 | targetRect, |
| 136 | parentFrameRect.left, |
| 137 | parentFrameRect.top |
| 138 | ); |
| 139 | } |
| 140 | return targetRect; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | /** |
no test coverage detected