-
Notifications
You must be signed in to change notification settings - Fork 29
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
The "convert artwork algorithm" is somewhere between underdefined and nonsensical #176
Comments
Oh, and in the ES array object case, of course, what it contains are ES objects, not MediaImage dictionaries, so the rest of this algorithm is underdefined as well (e.g. what does "entry's src" mean? is that an ES |
That is a leftover from the time where |
@bzbarsky actually, looking more into this, regarding your second comment, how is it different from how notifications actions are handled in https://notifications.spec.whatwg.org/#dom-notification-actions ? It would help to understand how the prose from the notification is correct but not ours. |
@bzbarsky would this solution work for you:
When getting, it would run steps similar to:
When setting, it would do something similar to what we have today but this time, it would use a sequence as an entry which would solve your problem. Does that work is it completely wrong? |
That's a getter. We're talking about a setter here. The inputs are different...
Unfortunately, having a sequence-typed attribute is not valid IDL at the moment. The idea of FrozenArray was to address the use cases people had for sequence-typed attributes...
You don't have control over that if your type is "sequence". You could do this if your type were "object", or something.... |
@domenic @annevk, @bzbarsky says that you were involved with defining The core of the problem as I understand it is that https://heycam.github.io/webidl/#es-frozen-array defines "An ECMAScript value V is converted to an IDL FrozenArray value" in a way that converts the input ES array to an IDL sequence and back to another ES array which is frozen. This means that any algorithm that takes a To quote myself from a private email:
|
Are there any other cases where ES→IDL conversion actually results in an ES value like this? |
Thank you @foolip for explaining this in layman's terms. I finally understand what the problem is 😃 As a temporary measure, would it make sense to say that the ES array should be converted to a |
This seems basically like another ask for distinct getters and setters in IDL. |
@annevk, is it necessary to separate getters and setters for this? Instead saying that the IDL representation of a @mounirlamouri, yes, as a workaround it should work to have some prose that invokes the conversion to |
@foolip oh yes, we could probably do that for the setter case, although it'll get a little confusing. For methods we should probably not allow |
Some of this discussion should maybe move into an IDL spec issue, but....
No. Even Also in practice, the typed array types could be ES values. But they don't have to be. In Gecko's bindings, for example, the IDL representation of typed arrays is not just as the corresponding ES values. So technically, the current spec for FrozenArray should really convert it to an IDL
It would at least make the spec well-defined. It would produce behavior that is black-box different from the one Chrome implements and Gecko would like to implement if it were implementing this spec, of course. ;)
You mean distinct types, right? It sort of does, yes.
Not on its own, no. It would mess up the getter situation: if on the IDL side you have a sequence, then when does the ES Array get created (presumably during the IDL-to-ES conversion?) and where is it cached (this is the part that the current spec is intending to solve). That said, the current IDL spec is pretty annoying for any case where the setter or method wants to do any processing at all on its argument. Passing it in as a sequence would make that a lot saner. The current IDL spec really only has good support for a setter that takes the object and then returns that exact object... One thing that would work for a lot of cases is to define something like this:
That's all lovely, but it doesn't solve the use case of the mediasession spec, because that spec wants an algorithm different from https://heycam.github.io/webidl/#dfn-create-frozen-array for creating its return value: it wants to freeze all the array entries too. So I think my best shot at a useful proposal is this:
Or something like that. I guess the "official" stored value could be the sequence, with a separate slot for the cached object and the conversion done in the getter (basically manually implementing the thing I describe above as "that would work for a lot of cases", except with a different IDL-to-ES conversion algorithm). But one way or another, you need to store both the ES value and the sequence, as far as I can tell, to make this spec work right. |
I've been meaning to come back to this issue, but haven't yet. In the meantime, those on this issue may be interested in #183 too. |
Since the entries in the MediaMetadata's `artwork` are frozen in the current spec, the type of the attribute `artwork` must be `FrozenArray<object>` rather than `FrozenArray<MediaImage>`, otherwise the entries of artwork can not be frozen[1]. This change will address issue w3c#237 The `artwork` in `MediaMetadataInit` and `MediaMetadata` will be clearly different after changing the `artwork` in `MediaMetadata` to `FrozenArray<object>`, hence the _getter_, _setter_ of `artwork` and the _convert artwork algorithm_ should be updated to match the change. This change will address issue w3c#176 [1] https://tc39.es/ecma262/#sec-object.freeze
Since the entries in the MediaMetadata's `artwork` are frozen in the current spec [1], the type of the attribute `artwork` must be `FrozenArray<object>` rather than `FrozenArray<MediaImage>`, otherwise the entries of artwork can not be frozen [2]. This change will address issue w3c#237 The `artwork` in `MediaMetadataInit` and `MediaMetadata` will be clearly different after changing the `artwork` in `MediaMetadata` to `FrozenArray<object>`, hence the _getter_, _setter_ of `artwork` and the _convert artwork algorithm_ should be updated to match the change. This change will address issue w3c#176 [1] https://github.com/web-platform-tests/wpt/blob/801a2b3b5e1cd0192f31890ddf9ee7b4d0ad9e89/mediasession/mediametadata.html#L148 [2] https://tc39.es/ecma262/#sec-object.freeze
Since the entries in the MediaMetadata's `artwork` are frozen in the current spec [1], the type of the attribute `artwork` must be `FrozenArray<object>` rather than `FrozenArray<MediaImage>`. Otherwise the entries of artwork can not be frozen [2]. This change will address issue w3c#237 The `artwork` in `MediaMetadataInit` and `MediaMetadata` will be clearly different after changing the `artwork` in `MediaMetadata` to `FrozenArray<object>`, hence the _getter_, _setter_ of `artwork` and the _convert artwork algorithm_ should be updated to match the change. This change will address issue w3c#176 [1] https://github.com/web-platform-tests/wpt/blob/801a2b3b5e1cd0192f31890ddf9ee7b4d0ad9e89/mediasession/mediametadata.html#L148 [2] https://tc39.es/ecma262/#sec-object.freeze
@bzbarsky proposal to update the setter makes sense to me and fixes this issue. |
Since the entries in the MediaMetadata's `artwork` are frozen in the current spec [1], the type of the attribute `artwork` must be `FrozenArray<object>` rather than `FrozenArray<MediaImage>`. Otherwise the entries of artwork can not be frozen [2]. This change will address issue w3c#237 The `artwork` in `MediaMetadataInit` and `MediaMetadata` will be clearly different after changing the `artwork` in `MediaMetadata` to `FrozenArray<object>`, hence the _getter_, _setter_ of `artwork` and the _convert artwork algorithm_ should be updated to match the change. This change will address issue w3c#176 [1] https://github.com/web-platform-tests/wpt/blob/801a2b3b5e1cd0192f31890ddf9ee7b4d0ad9e89/mediasession/mediametadata.html#L148 [2] https://tc39.es/ecma262/#sec-object.freeze
PR available at #343 |
* Update type of MediaMetadata's artwork Since the entries in the MediaMetadata's `artwork` are frozen in the current spec [1], the type of the attribute `artwork` must be `FrozenArray<object>` rather than `FrozenArray<MediaImage>`. Otherwise the entries of artwork can not be frozen [2]. This change will address issue #237 The `artwork` in `MediaMetadataInit` and `MediaMetadata` will be clearly different after changing the `artwork` in `MediaMetadata` to `FrozenArray<object>`, hence the _getter_, _setter_ of `artwork` and the _convert artwork algorithm_ should be updated to match the change. This change will address issue #176 [1] https://github.com/web-platform-tests/wpt/blob/801a2b3b5e1cd0192f31890ddf9ee7b4d0ad9e89/mediasession/mediametadata.html#L148 [2] https://tc39.es/ecma262/#sec-object.freeze * Update index.bs Co-authored-by: Marcos Cáceres <[email protected]> * Update type of MediaMetadata's artwork Fixes #237 Introduce a slot where we store the FrozenArray so that the getter always returns the same object. Make sure the slot is reset when the setter is called. * cleanup * Add convert links --------- Co-authored-by: Chun-Min Chang <[email protected]> Co-authored-by: Chris Needham <[email protected]> Co-authored-by: Marcos Cáceres <[email protected]>
Fixed by #343 |
Step 2 says:
OK, but what's "input"? When called from the MediaMetadata constructor, it's a
sequence<MediaImage>
. When called from theartwork
attribute setter, it's an ES array object. In neither case does it possess an "artwork". If the intent is to actually iterate over "input", then in the ES array object case you need to define very precisely how the iteration happens, because the different ways of doing it are observably different in terms of their side-effects.I suspect it would just be best to have the "convert artwork algorithm" always take a sequence as input, and instead of having a writable FrozenArray attribute have a setter function that takes
sequence<MediaImage>
.The text was updated successfully, but these errors were encountered: