* @return {!Promise}
()
| 589 | * @return {!Promise} |
| 590 | */ |
| 591 | enterFullOverlayMode() { |
| 592 | const ampAdParent = dev().assertElement(this.iframe.parentNode); |
| 593 | |
| 594 | // Security assertion. Otherwise any 3p frame could request lighbox mode. |
| 595 | userAssert( |
| 596 | ampAdParent.tagName.toLowerCase() == 'amp-ad', |
| 597 | 'Only <amp-ad> is allowed to enter lightbox mode.' |
| 598 | ); |
| 599 | |
| 600 | let bodyStyle; |
| 601 | |
| 602 | return this.measureMutate_({ |
| 603 | measure: () => { |
| 604 | const rect = this.host |
| 605 | ? this.host.getLayoutBox() |
| 606 | : this.iframe./*OK*/ getBoundingClientRect(); |
| 607 | |
| 608 | // Offset by scroll top as iframe will be position: fixed. |
| 609 | const dy = -Services.viewportForDoc(this.iframe).getScrollTop(); |
| 610 | const {height, left, top, width} = moveLayoutRect(rect, /* dx */ 0, dy); |
| 611 | |
| 612 | // Offset body by header height to prevent visual jump. |
| 613 | bodyStyle = { |
| 614 | top: px(top), |
| 615 | left: px(left), |
| 616 | width: px(width), |
| 617 | height: px(height), |
| 618 | }; |
| 619 | }, |
| 620 | mutate: () => { |
| 621 | // !important to prevent abuse e.g. box @ ltwh = 0, 0, 0, 0 |
| 622 | setImportantStyles(this.iframe, { |
| 623 | 'position': 'fixed', |
| 624 | 'left': 0, |
| 625 | 'right': 0, |
| 626 | 'bottom': 0, |
| 627 | 'width': '100vw', |
| 628 | 'top': 0, |
| 629 | 'height': '100vh', |
| 630 | }); |
| 631 | |
| 632 | // We need to override runtime-level !important rules |
| 633 | setImportantStyles(this.getBodyElement(), { |
| 634 | 'background': 'transparent', |
| 635 | 'position': 'absolute', |
| 636 | 'bottom': 'auto', |
| 637 | 'right': 'auto', |
| 638 | |
| 639 | // Read during vsync measure phase. |
| 640 | 'top': bodyStyle.top, |
| 641 | 'left': bodyStyle.left, |
| 642 | 'width': bodyStyle.width, |
| 643 | 'height': bodyStyle.height, |
| 644 | }); |
| 645 | }, |
| 646 | }); |
| 647 | } |
| 648 |
no test coverage detected