csswg-drafts icon indicating copy to clipboard operation
csswg-drafts copied to clipboard

It is unclear which Document object https://drafts.csswg.org/resize-observer/#ref-for-resizeobserver is talking about

Open smaug---- opened this issue 1 year ago • 3 comments

"Add this to Document.[[resizeObservers]] slot."

What is that Document? I assume the idea is to get that from a global, but which global?

smaug---- avatar Jul 01 '24 16:07 smaug----

Gecko at least uses the current global's document at the point of construction of the observer.

I think that's also what WebKit does given the CurrentDocument here.

Not quite sure what Blink does / what the ScriptState corresponds to there... @chrishtr do you know?

In any case, it seems current on construction is probably the most straight-forward answer here.

This is observable via callback order, cc @Loirooriol

emilio avatar Jul 01 '24 16:07 emilio

Blink uses current global's document also.

chrishtr avatar Jul 02 '24 20:07 chrishtr

The CSS Working Group just discussed It is unclear which Document object https://drafts.csswg.org/resize-observer/#ref-for-resizeobserver is talking about, and agreed to the following:

  • RESOLVED: ResizeObserver uses the "current" global document
The full IRC log of that discussion <TabAtkins> emilio: resizeObserver spec doesn't define, when you create an observer, what Document you add it to.
<TabAtkins> emilio: that can be different if you do something like iframe.contentWindow.ResizeObserver
<chrishtr> +1
<TabAtkins> emilio: I think from code comments blink and gecko both use "current" global; I think webkit too. We shoudl spec that.
<TabAtkins> TabAtkins: remind me which is "current"?
<TabAtkins> emilio: in this case, the iframe
<TabAtkins> emilio: the "relevant global" from the ResizeObserver object
<astearns> https://html.spec.whatwg.org/multipage/webappapis.html#concept-current-everything
<TabAtkins> astearns: you linked to "current" in your comment
<TabAtkins> astearns: so i assume you mean *that* current, not "relevant" that follows it
<smfr> q+
<TabAtkins> emilio: so "relevant" you need an object already. i think it needs to be "current", which would be the iframe document in this case, even if the script is from the outer page
<astearns> ack smfr
<TabAtkins> smfr: is thsi different from IntersectionObserver? can thtey be specced the same way?
<TabAtkins> emilio: they shoudl definitely be consistent, I think IO already uses current
<TabAtkins> emilio: I'll check
<TabAtkins> astearns: we could resolve to spec what current engines do, and make it consistent with IO
<TabAtkins> emilio: ah, i have an issue on IO spec, because it depends on what you observe, per spec, which isn't great
<TabAtkins> emilio: I'll crosslink in the issue
<TabAtkins> emilio: but wekbit and gecko do use the same concept
<TabAtkins> astearns: and you're sure what the concept is?
<TabAtkins> emilio: i'm 90% it's "current"
<TabAtkins> emilio: the realm that the function you're calling lives in
<TabAtkins> astearns: so we can resolve to define that both RO and IO use "current" global document, as long as that reflects reality
<TabAtkins> emilio: sounds good
<TabAtkins> might not match blink's IO bheavior
<TabAtkins> chrishtr: I"ll follow up with Stephan about IO
<TabAtkins> astearns: objections?
<TabAtkins> RESOLVED: ResizeObserver uses the "current" global document
<TabAtkins> (I should raise an issue about fixing these terrible names)
<emilio> https://github.com/w3c/IntersectionObserver/issues/525 is IntersectionObserver behavior
<emilio> s/behavior/issue

css-meeting-bot avatar Oct 23 '24 16:10 css-meeting-bot