Skip to content

Commit a742014

Browse files
committed
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.
1 parent e862d47 commit a742014

File tree

1 file changed

+40
-44
lines changed

1 file changed

+40
-44
lines changed

index.bs

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ table td, table th {
5050

5151
<pre class="link-defaults">
5252
spec:html; type:element; text:link
53+
spec:webidl; type:interface; text:object
5354
</pre>
5455

5556
<pre class="anchors">
@@ -1094,9 +1095,10 @@ dictionary MediaMetadataInit {
10941095
</p>
10951096

10961097
<p>
1097-
A {{MediaMetadata}} has an associated list of <dfn for="MediaMetadata">artwork
1098-
images</dfn>, which is a list of type <a idl>object</a> on the interface
1099-
but a list of type {{MediaImage}} internally.
1098+
A {{MediaMetadata}} has an associated sequence of <dfn for="MediaMetadata">artwork
1099+
images</dfn>, which is a sequence of type {{MediaImage}}.
1100+
A {{MediaMetadata}} also has has an associated <dfn for="MediaMetadata">
1101+
converted artwork images</dfn> which is initially <code>undefined</code>.
11001102
</p>
11011103

11021104
<p>
@@ -1140,10 +1142,9 @@ dictionary MediaMetadataInit {
11401142
</li>
11411143
<li>
11421144
Run the <a>convert artwork algorithm</a> with <var>init</var>'s
1143-
{{MediaMetadataInit/artwork}} as <var>input</var>,
1144-
where the <var>input</var> is a list of type {{MediaImage}},
1145-
and set <var>metadata</var>'s <a for="MediaMetadata">artwork images</a>
1146-
as the result if it succeeded.
1145+
{{MediaMetadataInit/artwork}} as <var>input</var> and set
1146+
<var>metadata</var>'s <a for="MediaMetadata">artwork images</a> as the
1147+
result if it succeeded.
11471148
</li>
11481149
<li>
11491150
Let <var>chapters</var> be an empty list of type {{ChapterInformation}}.
@@ -1166,7 +1167,7 @@ dictionary MediaMetadataInit {
11661167
</p>
11671168

11681169
When the <dfn>convert artwork algorithm</dfn> with <var>input</var> parameter is
1169-
invoked, where the <var>input</var> is a list of type {{MediaImage}},
1170+
invoked, where the <var>input</var> is a sequence of type {{MediaImage}},
11701171
the user agent MUST run the following steps:
11711172
<ol>
11721173
<li>
@@ -1230,62 +1231,56 @@ the user agent MUST run the following steps:
12301231
<p>
12311232
The <dfn attribute for="MediaMetadata">artwork</dfn>
12321233
attribute reflects the {{MediaMetadata}}'s <a for="MediaMetadata">artwork
1233-
images</a>. On getting, it MUST return the result of the following steps:
1234+
images</a>. On getting, it MUST run the following steps:
12341235
<ol>
12351236
<li>
1236-
Let <var>frozenArtwork</var> be an empty list of type <a idl>object</a>.
1237-
</li>
1238-
<li>
1239-
For each <var>entry</var> in the {{MediaMetadata}}'s <a
1240-
for="MediaMetadata">artwork images</a>, perform the following steps:
1237+
If the {{MediaMetadata}}'s <dfn>converted artwork images</dfn> is <code>undefined</code>,
1238+
run the following steps:
12411239
<ol>
12421240
<li>
1243-
Let <var>image</var> be a new {{MediaImage}}.
1241+
Let <var>frozenArtwork</var> be a Javascript Array value.
12441242
</li>
12451243
<li>
1246-
Set <var>image</var>'s {{MediaImage/src}} to <var>entry</var>'s
1247-
{{MediaImage/src}}.
1248-
</li>
1249-
<li>
1250-
Set <var>image</var>'s {{MediaImage/sizes}} to <var>entry</var>'s
1251-
{{MediaImage/sizes}}.
1252-
</li>
1253-
<li>
1254-
Set <var>image</var>'s {{MediaImage/type}} to <var>entry</var>'s
1255-
{{MediaImage/type}}.
1256-
</li>
1257-
<li>
1258-
Convert <var>image</var> into an <var>object</var>
1259-
whose type is <a idl>object</a>.
1244+
For each <var>entry</var> in the {{MediaMetadata}}'s <a
1245+
for="MediaMetadata">artwork images</a>, perform the following steps:
1246+
<ol>
1247+
<li>
1248+
Convert <var>entry</var> into a Javascript object named <var>image</var>.
1249+
</li>
1250+
<li>
1251+
Perform [=!=] <a abstract-op>SetIntegrityLevel</a>(<var>image</var>,
1252+
"<code>frozen</code>"), to prevent accidental mutation by scripts.
1253+
</li>
1254+
<li>
1255+
Push <var>image</var> to <var>frozenArtwork</var>.
1256+
</li>
1257+
</ol>
12601258
</li>
1261-
<!-- XXX IDL dictionaries are usually returned by value, so don't need
1262-
to be immutable. But FrozenArray reifies the dictionaries to mutable JS
1263-
objects accessed by reference, so we explicitly freeze them. It would be
1264-
better to do this with IDL primitives instead of JS - see
1265-
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004 -->
12661259
<li>
1267-
Call {{Object/freeze(O)}} on <var>image</var>, to prevent accidental
1268-
mutation by scripts.
1260+
Perform [=!=] <a abstract-op>SetIntegrityLevel</a>(<var>frozenArtwork</var>, "<code>frozen</code>").
12691261
</li>
12701262
<li>
1271-
Append the <var>object</var> to <var>frozenArtwork</var>.
1263+
Set the {{MediaMetadata}}'s <a>converted artwork images</a> to <var>frozenArtwork</var>.
12721264
</li>
12731265
</ol>
12741266
</li>
12751267
<li>
1276-
<a>Create a frozen array</a> from <var>frozenArtwork</var>.
1268+
Return the {{MediaMetadata}}'s <a>converted artwork images</a>.
12771269
</li>
12781270
</ol>
12791271
On setting, it MUST run the following steps:
12801272
<ol>
12811273
<li>
1282-
Convert the <var>frozenArtwork</var> from a list of type <a idl>object</a>
1283-
into a list of type {{MediaImage}}.
1274+
Let <var>convertedArtwork</var> be the result of converting
1275+
the new value <var>input</var> into a sequence of type {{MediaImage}}.
12841276
</li>
12851277
<li>
1286-
Run <a>convert artwork algorithm</a> with the converted list as
1278+
Run <a>convert artwork algorithm</a> with the converted sequence as
12871279
<var>input</var>, and set the {{MediaMetadata}}'s
1288-
<a for="MediaMetadata">artwork images</a> as the result if it succeeded.
1280+
<a for="MediaMetadata">artwork images</a> as the result if it succeeds.
1281+
</li>
1282+
<li>
1283+
Set the {{MediaMetadata}}'s <a>converted artwork images</a> to <code>undefined</code>.
12891284
</li>
12901285
</ol>
12911286
</p>
@@ -1384,11 +1379,12 @@ dictionary ChapterInformationInit {
13841379
</li>
13851380
<li>
13861381
Let {{ChapterInformationInit/artwork}} be the result of running the
1387-
<a>convert artwork algorithm</a>.
1382+
<a>convert artwork algorithm</a> with <var>init</var>'s
1383+
{{ChapterInformation/artwork}} as <var>input</var>.
13881384
</li>
13891385
<li>
13901386
Set <var>chapterInfo</var>'s <a for="ChapterInformation">artwork
1391-
images</a> to the result of [=Create a frozen array|creating a frozen
1387+
images</a> be the result of [=Create a frozen array|creating a frozen
13921388
array=] from {{ChapterInformationInit/artwork}}.
13931389
</li>
13941390
<li>

0 commit comments

Comments
 (0)