Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the iframe's box, not the wrapping AMP Element's #6248

Merged
merged 9 commits into from
Nov 30, 2016
4 changes: 1 addition & 3 deletions extensions/amp-ad/0.1/amp-ad-3p-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ export class AmpAd3PImpl extends AMP.BaseElement {
if (!this.iframeLayoutBox_) {
this.measureIframeLayoutBox_();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

measureIframeLayoutBox_() returns iframe layoutRect relative to the amp-ad or amp-iframe element. However I searched our code and it seems to me the this.iframeLayoutBox_ is only used here. So instead of applying box offset and apply it back here. Why don't we just return layoutRect relative to doc in #measureIframeLayoutBox

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#5271. I should really add a test so someone doesn't "optimize" this away.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Please add a comment though. or a link to #5271.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
// If the iframe is full size, we avoid an object allocation by moving box.
return moveLayoutRect(box, this.iframeLayoutBox_.left,
this.iframeLayoutBox_.top);
return moveLayoutRect(this.iframeLayoutBox_, box.left, box.top);
}

/** @override */
Expand Down
4 changes: 1 addition & 3 deletions extensions/amp-iframe/0.1/amp-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ export class AmpIframe extends AMP.BaseElement {
if (!this.iframeLayoutBox_) {
this.measureIframeLayoutBox_();
}
// If the iframe is full size, we avoid an object allocation by moving box.
return moveLayoutRect(box, this.iframeLayoutBox_.left,
this.iframeLayoutBox_.top);
return moveLayoutRect(this.iframeLayoutBox_, box.left, box.top);
}

/** @override */
Expand Down