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

intersect-resources: Fix incorrect pre-layout assumption #27684

Merged
merged 8 commits into from
Apr 13, 2020

Conversation

dreamofabear
Copy link

@dreamofabear dreamofabear commented Apr 9, 2020

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.

@dreamofabear dreamofabear requested a review from samouri April 10, 2020 03:18
// 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()) {
Copy link
Member

@samouri samouri Apr 10, 2020

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

Copy link
Author

Choose a reason for hiding this comment

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

Precisely!

Copy link
Member

@samouri samouri left a 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

/* usePremeasuredRect */ true
);
expect(resource1.layoutCanceled).to.be.calledOnce;
expect(resource1.getState()).to.equal(ResourceState.LAYOUT_SCHEDULED);
Copy link
Member

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?

Copy link
Author

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.

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.

4 participants