Re: [css-houdini-drafts] [css-animation-worklet] IDL for AnimationWorkletGlobalScope is invalid (#907)

Phew, I've had to reread the sections on Exposed and Global multiple times before I finally understood what was going on here.

So, `[Global]` has two independent purposes. First, it marks the interface as a global, which means that (in prose) an environment can say that is uses a singular instance of the interface as its global object (and some other weird mechanical stuff that's not relevant here).

Second, it advertises one or more names that other interfaces can use in `[Exposed]` to claim that they're exposed in that global. Multiple interfaces can advertise the same global name, which just means that interfaces that are `[Exposed]` to that name show up in all those globals. In this way, a shared `[Global]` name acts similar to a superclass in normal inheritance hierarchies.

So WorkletGlobalScope and its subclasses are mixing two different "inheritance" systems here. First, WGS itself is an "abstract" superclass of all the specific worklet globals, like AnimationWorkletGlobalScope or PaintWorkletGlobalScope, so we can define methods there that'll show up in all the worklet globals.

Then the specific subclasses actually mark themselves as globals, advertising both a specific name and the generic name "Worklet", so that interfaces/methods/etc can choose to expose themselves either to a specific worklet type, or to all worklets.

`WorkletGlobalScope`, then, is marked `[Exposed=Worklet]`, because obviously its methods want to show up in every worklet. It's not marked with any `[Global]`, because you can't have subclasses if you're a global.

----------

I feel like this example should really be illustrated in WebIDL; it's used by both Workers and Worklets, but is (to me, at least) a very non-obvious twisty sort of interaction of these features. Compare to the much simpler Window example, which is a global and exposed to itself immediately. I'll open an issue for this.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/907#issuecomment-506535616 using your GitHub account

Received on Thursday, 27 June 2019 22:35:21 UTC