Skip to content

Commit

Permalink
Update type of MediaMetadata's artwork
Browse files Browse the repository at this point in the history
Fixes w3c#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.
  • Loading branch information
youennf committed Sep 26, 2024
1 parent e862d47 commit 58bbe73
Showing 1 changed file with 45 additions and 32 deletions.
77 changes: 45 additions & 32 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ table td, table th {

<pre class="link-defaults">
spec:html; type:element; text:link
spec:webidl; type:interface; text:object
</pre>

<pre class="anchors">
Expand Down Expand Up @@ -1230,54 +1231,66 @@ the user agent MUST run the following steps:
<p>
The <dfn attribute for="MediaMetadata">artwork</dfn>
attribute reflects the {{MediaMetadata}}'s <a for="MediaMetadata">artwork
images</a>. On getting, it MUST return the result of the following steps:
images</a>. On getting, it MUST run the following steps:
<ol>
<li>
Let <var>frozenArtwork</var> be an empty list of type <a idl>object</a>.
</li>
<li>
For each <var>entry</var> in the {{MediaMetadata}}'s <a
for="MediaMetadata">artwork images</a>, perform the following steps:
If the {{MediaMetadata}}'s <dfn>converted artwork images</dfn> is <code>undefined</code>,
run the following steps:
<ol>
<li>
Let <var>image</var> be a new {{MediaImage}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/src}} to <var>entry</var>'s
{{MediaImage/src}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/sizes}} to <var>entry</var>'s
{{MediaImage/sizes}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/type}} to <var>entry</var>'s
{{MediaImage/type}}.
</li>
<li>
Convert <var>image</var> into an <var>object</var>
whose type is <a idl>object</a>.
Let <var>frozenArtwork</var> be an empty list of type <a idl>object</a>.
</li>
<!-- XXX IDL dictionaries are usually returned by value, so don't need
to be immutable. But FrozenArray reifies the dictionaries to mutable JS
objects accessed by reference, so we explicitly freeze them. It would be
better to do this with IDL primitives instead of JS - see
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004 -->
<li>
Call {{Object/freeze(O)}} on <var>image</var>, to prevent accidental
mutation by scripts.
For each <var>entry</var> in the {{MediaMetadata}}'s <a
for="MediaMetadata">artwork images</a>, perform the following steps:
<ol>
<li>
Let <var>image</var> be a new {{MediaImage}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/src}} to <var>entry</var>'s
{{MediaImage/src}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/sizes}} to <var>entry</var>'s
{{MediaImage/sizes}}.
</li>
<li>
Set <var>image</var>'s {{MediaImage/type}} to <var>entry</var>'s
{{MediaImage/type}}.
</li>
<li>
Convert <var>image</var> into an <var>object</var>
whose type is <a idl>object</a>.
</li>
<!-- XXX IDL dictionaries are usually returned by value, so don't need
to be immutable. But FrozenArray reifies the dictionaries to mutable JS
objects accessed by reference, so we explicitly freeze them. It would be
better to do this with IDL primitives instead of JS - see
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004 -->
<li>
Call {{Object/freeze(O)}} on <var>image</var>, to prevent accidental
mutation by scripts.
</li>
<li>
Append the <var>object</var> to <var>frozenArtwork</var>.
</li>
</ol>
</li>
<li>
Append the <var>object</var> to <var>frozenArtwork</var>.
Set the {{MediaMetadata}}'s <a>converted artwork images</a> to <var>frozenArtwork</var>.
</li>
</ol>
</li>
<li>
<a>Create a frozen array</a> from <var>frozenArtwork</var>.
Return the {{MediaMetadata}}'s <a>converted artwork images</a>.
</li>
</ol>
On setting, it MUST run the following steps:
<ol>
<li>
Set the {{MediaMetadata}}'s <a>converted artwork images</a> to <code>undefined</code>.
</li>
<li>
Convert the <var>frozenArtwork</var> from a list of type <a idl>object</a>
into a list of type {{MediaImage}}.
Expand Down

0 comments on commit 58bbe73

Please sign in to comment.