Re: [csswg-drafts] [css-contain-2]: Should the first `contentvisibilityautostatechange` event be fired without knowing if the element is close to the viewport (#9803)

> > This could happen, because `inner.getBoundingClientRect().height` triggers layout, and layout could trigger `relevant to the user` checking.
> 
> I see. Am I correct in understanding that you mean if we force a layout before we had a change to determine proximity to the viewport, then we decide that the element is not relevant to the user (assuming no other conditions). Then, when we do check the proximity, we may determine that the element _is_ relevant, causing a second event?
> 
Yes, that's correct! Thanks for making it clear.

> If that's the case, then I agree we probably don't want the first event on forced layout. What do other browsers do in this case right now?

The behavior of Chromium and Gecko are similar, sometimes fire one event with skipped value `false`, sometimes fire two events with skipped value `true` then `false`.
WebKit seems also fire one event with skipped value `false`, but this is because `inner` does not have `RenderObject` yet when the first time to call `getBoundingClientRect`, so the `relevant to the user` checking does not happen.

And in [the Gecko Patch](https://phabricator.services.mozilla.com/D198602), I tried to back out for this scenario while checking `relevant to the user`. It works, but IDK might be too specific.


-- 
GitHub Notification of comment by cathiechen
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9803#issuecomment-1900600824 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 19 January 2024 15:12:32 UTC