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

Add [[PlatformBrand]] internal slot to all platform objects #97

Closed
annevk opened this issue Mar 11, 2016 · 6 comments
Closed

Add [[PlatformBrand]] internal slot to all platform objects #97

annevk opened this issue Mar 11, 2016 · 6 comments
Labels
☕☕☕ difficulty:hard Excruciating ⌛⌛ duration:medium Shouldn't be too long to fix

Comments

@annevk
Copy link
Member

annevk commented Mar 11, 2016

The [[PlatformBrand]] internal slot would be a List (in the ECMAScript sense) of strings. One string per interface on the interface chain of the object. So e.g., Text would have "Text, "CharacterData", "Node", "EventTarget".

This would allow us to be more specific what we mean with instances of something and would also clear up a lot of language in IDL I think.

annevk referenced this issue in whatwg/dom Mar 15, 2016
This is basically the introduction of ShadowRoot objects as a node in
the DOM Standard. The plan is to port over the features over time,
while trying to make sure the new features and terminology remain
consistent and coherent with the rest of the standard.

I’ll try to prefix ShadowRoot-object-related commits with “Shadow”.
@tobie tobie added enhancement ⌛⌛ duration:medium Shouldn't be too long to fix ☕☕☕ difficulty:hard Excruciating labels Jun 18, 2016
@dominiccooney
Copy link

Is the [[PlatfromBrand]] on the instance (for example a text node in the DOM, not the Text interface or Text interface prototype object?)

For what it is worth Blink implements the check for HTMLElement in custom elements as if the brand is on the instance; see CustomElementDefinition::checkConstructorResult. Sorry for the C++, but basically it checks the element instance is a HTMLElement; it doesn't consult JavaScript prototypes or anything.

@annevk
Copy link
Member Author

annevk commented Sep 1, 2016

Yes, on the instance. All internal slots are I think.

@annevk
Copy link
Member Author

annevk commented Mar 16, 2017

(Once we add this StructuredSerialize can be simplified a little bit as all platform objects will have this slot and therefore can be treated like promises or WeakMap objects.)

@annevk
Copy link
Member Author

annevk commented Aug 10, 2017

The other thing that would be useful here is some shorthands around it. When you check against the list of platform brands, there's a difference if the matched value is first in the list or somewhere else (or last and somewhere else, depending on order).

E.g., in DOM we sometimes want to match DocumentFragment, but not ShadowRoot (a subclass).

@littledan
Copy link
Collaborator

It sounds like we'd have two "entrypoints" to [[PlatformBrand]]:

  • In WebIDL, when evaluating the phrase, "is a platform object that implements"
  • In all the other specs, when they use the phrase, "a new XYZ object"

Is that what you were picturing, @annevk? The first one will be pretty easy to update, but the second would be a lot of work to go around fixing up. Would it be reasonable to add a "create a new platform object of interface |interface|" algorithm to WebIDL and update all the other specs to call into that?

littledan added a commit to littledan/webidl that referenced this issue Dec 9, 2018
- Define an imperative algorithm for instantiating a platform object,
  which everything theoretically calls into, and which sets the primary
  interface into a new internal slot [[PrimaryInterface]].
- Define the "implements" algorithm as checking the [[PrimaryInterface]]
  internal slot.

This PR procrastinates on defining an imperative algorithm for [Global]
interfaces, which would be a bit more text.

Fixes whatwg#97
littledan added a commit to littledan/webidl that referenced this issue Dec 9, 2018
- Define an imperative algorithm for instantiating a platform object,
  which everything theoretically calls into, and which sets the primary
  interface into a new internal slot [[PrimaryInterface]].
- Define the "implements" algorithm as checking the [[PrimaryInterface]]
  internal slot.

The algorithm here is roughly in correspondence with the V8 implementation,
where operation functions are allocated with a reference to a
FunctionTemplate object (which is in corresondence with WebIDL interfaces).
When checking the receiver of a method that came from WebIDL, the original
prototype chain is traversed by looking at the FunctionTemplate's parent.
The same FunctionTemplate is used in multiple JavaScript realms.

This PR procrastinates on defining an imperative algorithm for [Global]
interfaces, which would be a bit more text. It also doesn't define which
global object is associated with platform objects, or how this association
is represented.

Fixes whatwg#97
@annevk
Copy link
Member Author

annevk commented Dec 10, 2018

Yeah, I think that's reasonable. We also want "x is a XYZ" formalized as a shorthand for "is a platform object that implements" for use in other standards.

I'm not a 100% sure

E.g., in DOM we sometimes want to match DocumentFragment, but not ShadowRoot (a subclass).

is true anymore btw. I kinda hope it's not.

Ms2ger pushed a commit that referenced this issue Feb 25, 2019
- Update the steps for instantiating a platform object, which everything
  theoretically calls into, and which sets the primary interface into a new
  internal slot [[PrimaryInterface]].
- Define the "implements" algorithm as checking the [[PrimaryInterface]]
  internal slot.

The algorithm here is roughly in correspondence with the V8 implementation,
where operation functions are allocated with a reference to a
FunctionTemplate object (which is in corresondence with WebIDL interfaces).
When checking the receiver of a method that came from WebIDL, the original
prototype chain is traversed by looking at the FunctionTemplate's parent.
The same FunctionTemplate is used in multiple JavaScript realms.

Fixes #97.
Ms2ger pushed a commit that referenced this issue Feb 25, 2019
- Update the steps for instantiating a platform object, which everything
  theoretically calls into, and which sets the primary interface into a new
  internal slot [[PrimaryInterface]].
- Define the "implements" algorithm as checking the [[PrimaryInterface]]
  internal slot.

The algorithm here is roughly in correspondence with the V8 implementation,
where operation functions are allocated with a reference to a
FunctionTemplate object (which is in corresondence with WebIDL interfaces).
When checking the receiver of a method that came from WebIDL, the original
prototype chain is traversed by looking at the FunctionTemplate's parent.
The same FunctionTemplate is used in multiple JavaScript realms.

Fixes #97.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☕☕☕ difficulty:hard Excruciating ⌛⌛ duration:medium Shouldn't be too long to fix
Development

No branches or pull requests

4 participants