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

Consider removing settings object's responsible document #4335

Closed
annevk opened this issue Feb 4, 2019 · 4 comments · Fixed by #7694
Closed

Consider removing settings object's responsible document #4335

annevk opened this issue Feb 4, 2019 · 4 comments · Fixed by #7694
Assignees
Labels
clarification Standard could be clearer

Comments

@annevk
Copy link
Member

annevk commented Feb 4, 2019

It's seems you could always get the associated Document from the settings object's global object instead.

An alternative might be defining "relevant document" and using that throughout.

This came up in https://github.com/whatwg/html/pull/4214/files#r253238258.

This seems worthwhile as currently one of the requirements on BroadcastChannel's settings object reads "a global object that is a Window object and a responsible document that is fully active" which might make one think the Window object's associated Document is something else.

(This is a rather good issue if you're already somewhat familiar with the HTML Standard and are interested in streamlining language and potentially introducing new concepts that can be used across all the various standards that build upon HTML.)

@annevk annevk added the clarification Standard could be clearer label Feb 4, 2019
@annevk
Copy link
Member Author

annevk commented Feb 6, 2019

As a follow-up or as part of this it might also be nice to tackle "responsible event loop" which should always be accessible from the encompassing agent, so it's not clear we need a separate point of access here.

@annevk
Copy link
Member Author

annevk commented Feb 26, 2019

Working on #4394 two things jumped out at me:

  • MessageChannel is the source of a lot of issues here.
  • What exactly do we prefer between settings objects and global objects? They often have equivalent pointers with different names. Doesn't seem super helpful?

@domenic
Copy link
Member

domenic commented Feb 26, 2019

  • What exactly do we prefer between settings objects and global objects? They often have equivalent pointers with different names. Doesn't seem super helpful?

Whatever's shorter or more convenient. Settings objects have some useful fields; if you need to access those, go for the settings object. Globals have a few others. Probably for this issue we'll mostly want globals since they have associated Documents.

This issue is indeed about removing one of the redundant pointers ("responsible document") mostly by replacing it with the equivalent one ("associated Document").

annevk added a commit that referenced this issue Feb 26, 2019
@domenic
Copy link
Member

domenic commented Jul 31, 2019

This issue is indeed about removing one of the redundant pointers ("responsible document") mostly by replacing it with the equivalent one ("associated Document").

In particular, the reason why I think removing this is important is because intuitively you might think of "responsible document" for worker settings objects as being their owner document. But that's not the case; the spec notes that

If the responsible event loop is not a window event loop, then the environment settings object has no responsible document.


In general, the environment settings object concept can be viewed like a polymorphic class hierarchy. There's an abstract base class/interface, "environment settings object", which defines the contract but no specifics. And there are several concrete subclasses, like window ESO and worker ESO and service worker ESO, which define concrete algorithms for how to get things like "module map" or "HTTP state" or "origin".

With this view, "responsible document" is a violation of the Liskov Substitution Principle. The expectation is that when given an ESO, you can generically call its algorithms and get something useful out of them, without caring about what subtype of ESO you're using. But for the "responsible document" algorithm, that's not true; it's meaningless in the general case, and only works for window ESOs.

@domenic domenic self-assigned this Apr 6, 2020
domenic added a commit to whatwg/fetch that referenced this issue Feb 24, 2021
domenic added a commit to whatwg/fetch that referenced this issue Feb 24, 2021
domenic added a commit to domenic/screen-wake-lock that referenced this issue Feb 24, 2021
* Removes uses of "responsible document". This term is on its way out, per whatwg/html#4335.

* The straightforward substitution of using the associated Document didn't always make sense, because in many cases there was no sensible settings object (e.g., the algorithms were consulting the "current settings object" but were in parallel, where there is no current settings object). So, this restructures the algorithms to be more clear about what work is done in parallel vs. what work is done in queued tasks.

* Similarly, a lot of work was done on main-thread data structures and objects while in parallel, e.g. creating WakeLockSentinel objects or consulting internal slots. That was moved to be done either up front, before the algorithms go in parallel, or in queued tasks. This includes user activation checking, which allows us to eliminate the wrapper "obtain permission" algorithm.
domenic added a commit to domenic/screen-wake-lock that referenced this issue Mar 24, 2021
domenic added a commit to domenic/screen-wake-lock that referenced this issue Mar 24, 2021
This term is on its way out, per whatwg/html#4335.
rakuco pushed a commit to w3c/screen-wake-lock that referenced this issue Mar 25, 2021
* Remove uses of "responsible document"

This term is on its way out, per whatwg/html#4335.
domenic added a commit that referenced this issue Mar 9, 2022
It was confusing to have this as a generic on environment settings objects, since it only applied to window environment settings objects. Instead, specifications should get the Window object's associated Document directly, if necessary by looking at the settings object's global object (which will, in some cases, be a Window object).

Closes #4335.
domenic added a commit that referenced this issue Mar 16, 2022
It was confusing to have this as a generic on environment settings objects, since it only applied to window environment settings objects. Instead, specifications should get the Window object's associated Document directly, if necessary by looking at the settings object's global object (which will, in some cases, be a Window object).

Closes #4335.
mfreed7 pushed a commit to mfreed7/html that referenced this issue Jun 3, 2022
It was confusing to have this as a generic on environment settings objects, since it only applied to window environment settings objects. Instead, specifications should get the Window object's associated Document directly, if necessary by looking at the settings object's global object (which will, in some cases, be a Window object).

Closes whatwg#4335.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

Successfully merging a pull request may close this issue.

2 participants