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

Conversation

jridgewell
Copy link
Contributor

Imagine the iframe's box is smaller. If we moved the AMP Element's
box, we would have the wrong width/height, because the iframe is
smaller. So avoiding the allocation is the exact wrong thing to do.

Imagine the iframe's box is smaller. If we moved the AMP Element's
`box`, we would have the wrong `width`/`height`, because the iframe is
smaller. So avoiding the allocation is the exact wrong thing to do.
@@ -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

These will both pass, since we're measuring the box just before.
@jridgewell jridgewell merged commit 87207c2 into ampproject:master Nov 30, 2016
@jridgewell jridgewell deleted the fix-iframe-measurement-inob branch November 30, 2016 22:52
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* Move the iframe's box, not the wrapping AMP Element's

Imagine the iframe's box is smaller. If we moved the AMP Element's
`box`, we would have the wrong `width`/`height`, because the iframe is
smaller. So avoiding the allocation is the exact wrong thing to do.

* Use CustomElement#getLayoutBox

#getIntersectionElementLayoutBox isn’t appropriate to get the bounding
box.

* Add test cases

* Assert that the intersection is not the amp-iframe's size, but the iframe's

* Comments

* Fix assertion

* Assert truthiness to pass type check

These will both pass, since we're measuring the box just before.

* Fix presubmit error

* Move Ad3p test into 3p tests
Lith pushed a commit to Lith/amphtml that referenced this pull request Dec 22, 2016
* Move the iframe's box, not the wrapping AMP Element's

Imagine the iframe's box is smaller. If we moved the AMP Element's
`box`, we would have the wrong `width`/`height`, because the iframe is
smaller. So avoiding the allocation is the exact wrong thing to do.

* Use CustomElement#getLayoutBox

#getIntersectionElementLayoutBox isn’t appropriate to get the bounding
box.

* Add test cases

* Assert that the intersection is not the amp-iframe's size, but the iframe's

* Comments

* Fix assertion

* Assert truthiness to pass type check

These will both pass, since we're measuring the box just before.

* Fix presubmit error

* Move Ad3p test into 3p tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants