From 94700d3490d62b33b84bb25010e802b90e22026d Mon Sep 17 00:00:00 2001 From: youenn Date: Thu, 26 Sep 2024 11:54:38 -0700 Subject: [PATCH] Update type of MediaMetadata's artwork Fixes https://github.com/w3c/mediasession/issues/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. --- index.bs | 84 +++++++++++++++++++++++++++----------------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/index.bs b/index.bs index c61e491..16bec3d 100644 --- a/index.bs +++ b/index.bs @@ -50,6 +50,7 @@ table td, table th {
@@ -1094,9 +1095,10 @@ dictionary MediaMetadataInit {
 

- A {{MediaMetadata}} has an associated list of artwork - images, which is a list of type object on the interface - but a list of type {{MediaImage}} internally. + A {{MediaMetadata}} has an associated sequence of artwork + images, which is a sequence of type {{MediaImage}}. + A {{MediaMetadata}} also has has an associated + converted artwork images which is initially undefined.

@@ -1140,10 +1142,9 @@ dictionary MediaMetadataInit {

  • Run the convert artwork algorithm with init's - {{MediaMetadataInit/artwork}} as input, - where the input is a list of type {{MediaImage}}, - and set metadata's artwork images - as the result if it succeeded. + {{MediaMetadataInit/artwork}} as input and set + metadata's artwork images as the + result if it succeeded.
  • Let chapters be an empty list of type {{ChapterInformation}}. @@ -1166,7 +1167,7 @@ dictionary MediaMetadataInit {

    When the convert artwork algorithm with input parameter is -invoked, where the input is a list of type {{MediaImage}}, +invoked, where the input is a sequence of type {{MediaImage}}, the user agent MUST run the following steps:
    1. @@ -1230,62 +1231,56 @@ the user agent MUST run the following steps:

      The artwork attribute reflects the {{MediaMetadata}}'s artwork - images. On getting, it MUST return the result of the following steps: + images. On getting, it MUST run the following steps:

      1. - Let frozenArtwork be an empty list of type object. -
      2. -
      3. - For each entry in the {{MediaMetadata}}'s artwork images, perform the following steps: + If the {{MediaMetadata}}'s converted artwork images is undefined, + run the following steps:
        1. - Let image be a new {{MediaImage}}. + Let frozenArtwork be a Javascript Array value.
        2. - Set image's {{MediaImage/src}} to entry's - {{MediaImage/src}}. -
        3. -
        4. - Set image's {{MediaImage/sizes}} to entry's - {{MediaImage/sizes}}. -
        5. -
        6. - Set image's {{MediaImage/type}} to entry's - {{MediaImage/type}}. -
        7. -
        8. - Convert image into an object - whose type is object. + For each entry in the {{MediaMetadata}}'s artwork images, perform the following steps: +
            +
          1. + Convert entry into a Javascript object named image. +
          2. +
          3. + Perform [=!=] SetIntegrityLevel(image, + "frozen"), to prevent accidental mutation by scripts. +
          4. +
          5. + Push image to frozenArtwork. +
          6. +
        9. -
        10. - Call {{Object/freeze(O)}} on image, to prevent accidental - mutation by scripts. + Perform [=!=] SetIntegrityLevel(frozenArtwork, "frozen").
        11. - Append the object to frozenArtwork. + Set the {{MediaMetadata}}'s converted artwork images to frozenArtwork.
      4. - Create a frozen array from frozenArtwork. + Return the {{MediaMetadata}}'s converted artwork images.
      On setting, it MUST run the following steps:
      1. - Convert the frozenArtwork from a list of type object - into a list of type {{MediaImage}}. + Let convertedArtwork be the result of converting + frozenArtwork into a sequence of type {{MediaImage}}.
      2. - Run convert artwork algorithm with the converted list as + Run convert artwork algorithm with the converted sequence as input, and set the {{MediaMetadata}}'s - artwork images as the result if it succeeded. + artwork images as the result if it succeeds. +
      3. +
      4. + Set the {{MediaMetadata}}'s converted artwork images to undefined.

      @@ -1384,11 +1379,12 @@ dictionary ChapterInformationInit {
    2. Let {{ChapterInformationInit/artwork}} be the result of running the - convert artwork algorithm. + convert artwork algorithm with init's + {{ChapterInformation/artwork}} as input.
    3. Set chapterInfo's artwork - images to the result of [=Create a frozen array|creating a frozen + images be the result of [=Create a frozen array|creating a frozen array=] from {{ChapterInformationInit/artwork}}.