-
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
intersect-resources: Fix incorrect pre-layout assumption #27684
intersect-resources: Fix incorrect pre-layout assumption #27684
Conversation
// With IntersectionObserver, peek at the premeasured rect to see | ||
// if the resource is still displayed (has a non-zero size). | ||
// The premeasured rect is most analogous to an immediate measure. | ||
if (resource.hasBeenPremeasured()) { |
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.
Am I right in thinking this is to catch the case where the IO has fired and inserted the premeasuredRect but the discoverWork
block of the pass hasn't happened yet? Therefore we are trying to catch cases that have hidden themselves in the meantime
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.
Precisely!
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.
had a couple small questions, mostly for my own learning
test/unit/test-resources.js
Outdated
/* usePremeasuredRect */ true | ||
); | ||
expect(resource1.layoutCanceled).to.be.calledOnce; | ||
expect(resource1.getState()).to.equal(ResourceState.LAYOUT_SCHEDULED); |
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.
doesn't resource.layoutCancelled()
set the resource state to either READY_FOR_LAYOUT or NOT_LAID_OUT?
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.
It does, but I stubbed it so the function becomes a no-op.
Changed to spy and updated this state. Good eye.
Related to #25428.
More closely mimic the classical behavior of "explicit measure before layout" by checking if there's an unprocessed, "premeasured rect" from a more recent intersection callback.
Noticed this potential issue in examples/everything.amp.html in an
amp-ad > amp-analytics
element that starts with size 1x1 and then gets hidden.