-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Calculate correct documentHeight for short AMP docs #12229
Conversation
bd4561f
to
8583b43
Compare
8583b43
to
167e5b2
Compare
// Body is overflow: hidden so that the scrollHeight include the margins of | ||
// body's first and last child. | ||
const rect = this.win.document.body./*OK*/getBoundingClientRect(); | ||
return rect.height + rect.top + this.getScrollTop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm what this does? Why would scroll top be needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment to clarify.
I couldn't think of a better way to get the scrollTop back out of the DOM - offsetTop for the body is zero, and reading paddingTop out of the html element's style is messy. Alternatively could store paddingTop when setPaddingTop() is called and add it on here? This method is more generic though - would work with e.g. marginTop on body instead of paddingTop on html.
fd20ae0
to
98276f9
Compare
Handles the edge case of AMP documents which are shorter than their containing viewport, which causes documentHeight to be scrollHeight, which is the height of the viewport. Should be a no-op for docs which are already taller than the viewport. Re-implements changes made in ampproject@ac741f6, which were reverted before merging.
Non-HTML5 doctype has different behaviour for html/body element heights in Safari.
98276f9
to
fbd0cf8
Compare
* Use contentHeight for documentHeight messages Handles the edge case of AMP documents which are shorter than their containing viewport, which causes documentHeight to be scrollHeight, which is the height of the viewport. Should be a no-op for docs which are already taller than the viewport. Re-implements changes made in ac741f6, which were reverted before merging. * Use HTML5 doctype for RealWinFixture Non-HTML5 doctype has different behaviour for html/body element heights in Safari.
* Use contentHeight for documentHeight messages Handles the edge case of AMP documents which are shorter than their containing viewport, which causes documentHeight to be scrollHeight, which is the height of the viewport. Should be a no-op for docs which are already taller than the viewport. Re-implements changes made in ampproject@ac741f6, which were reverted before merging. * Use HTML5 doctype for RealWinFixture Non-HTML5 doctype has different behaviour for html/body element heights in Safari.
Handles the edge case of AMP documents which are shorter than their
containing viewport, which causes documentHeight to be scrollHeight,
which is the height of the viewport. Should be a no-op for docs which
are already taller than the viewport.
Re-implements changes made in ac741f6, which were reverted before merging.
Fixes #12172