This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10337 - add [Supplemental] support
Summary: add [Supplemental] support
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-09 22:31 UTC by Ian 'Hixie' Hickson
Modified: 2011-06-22 00:29 UTC (History)
3 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2010-08-09 22:31:30 UTC
For specification process reasons, some interface  definitions don't get organised the same way as we want from implementations. I've assumed that [Supplemental] will exist, and used it as follows:

 - Setting [Supplemental, NoInterfaceObject] on an interface X with no 
   ancestor and then saying:
     Y implements X;
   ...implies that the members in X are imported into Y as if the 
   definition of Y always had X in it.

 - Setting [Supplemental, NoInterfaceObject] on an interface X that 
   inherits from Y implies that there are objects called Y that have all 
   the members of X and Y with X not appearing on the prototype chain.

 - Setting [Supplemental] on an interface that has the same name as an 
   interface definition without [Supplemental].

The distinction between these cases is that I have three different cases 
where I need to do this. One is where I have some objects, e.g. Window, 
that are made up of APIs defined in other specs, and those APIs are also 
used by other interfaces. So I define Window, and then other specs slide 
stuff into Window, and slide stuff into other interfaces (like Worker- 
related ones). Another is WorkerGlobalScope, which I want to be the name 
of the interface implementing the global scope for workers, but there are 
two types of workers, and they have slightly different interfaces. And the 
third is the deprecated interfaces, where one interface, e.g. 
HTMLAnchorElement, is defined in two places.
Comment 1 Cameron McCormack 2011-06-20 08:13:08 UTC
The first case doesn't need [Supplemental] any more.

For the second case, I'd like a more descriptive name than [Supplemental].  I've used [CopyInheritedPrototype], but let me know if you think of something better.

For the third case, I think using extended attributes for this isn't right; we need something in the core IDL syntax.  I've added this syntax:

  interface HTMLAnchorElement : HTMLElement {
    // ...
  };

  partial interface HTMLAnchorElement {
    // the attributes not fit for polite company
  };
Comment 2 Jonas Sicking (Not reading bugmail) 2011-06-20 08:43:47 UTC
Could someone give an example of when the second case is desired? I.e. when it would be appropriate to use [CopyInheritedPrototype]?
Comment 3 Cameron McCormack 2011-06-21 04:25:59 UTC
(In reply to comment #2)
> Could someone give an example of when the second case is desired? I.e. when it
> would be appropriate to use [CopyInheritedPrototype]?

The case brought up in comment #0 is DedicatedWorkerGlobalScope/SharedWorkerGlobalScope.  Maybe Ian can explain why regular inheritance doesn't work in that case.
Comment 4 Jonas Sicking (Not reading bugmail) 2011-06-21 06:21:54 UTC
It seems to me that for worker global scopes you want different interface objects for DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. That way people can test what type of object they have and use it appropriately.
Comment 5 Cameron McCormack 2011-06-21 23:26:56 UTC
(In reply to comment #4)
> It seems to me that for worker global scopes you want different interface
> objects for DedicatedWorkerGlobalScope and SharedWorkerGlobalScope. That way
> people can test what type of object they have and use it appropriately.

If HTML says

  [CopyInheritedPrototype]
  interface DedicatedWorkerGlobalScope : Window {
    ...
  };

then you do get an interface object "DedicatedWorkerGlobalScope" that you can test on.  It's just that Object.getPrototypeOf(<global>) == Object.prototype, and there will be properties like DedicatedWorkerGlobalScope.prototype.open, etc.

`<global> instanceof Window` will be false, though.
Comment 6 Jonas Sicking (Not reading bugmail) 2011-06-22 00:29:55 UTC
With "test on" I mean being able to do |foo instanceof DedicatedWorkerGlobalScope| which appears wouldn't be possible.

I still don't understand why you would want to use CopyInheritedPrototype? Can you give any concrete use cases?

And worst case, couldn't you just use "DedicatedWorkerGlobalScope implements Window" to accomplish the same API? Given that mixins is something that should be avoided if possible (since they fit poorly with JavaScript's single inheritance prototype chain), having multiple syntaxes to express them seems backwards.