Skip to content

Should we select an image source synchronously when updating the image data? #8207

Closed

Description

@BorisChiou

When updating the image data, per spec (https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data:select-an-image-source):

  1. Queue a microtask to perform the rest of this algorithm, allowing the task that invoked this algorithm to continue.
  2. ...
  3. Let selected source and selected pixel density be the URL and pixel density that results from selecting an image source, respectively.

Basically, this part is unclear to me now. The 9th step is in a microtask when updating the image data. However, right now if the <img> element is under <picture>, the width and height attributes of <source> elements affect the <img>'s style. That means, we have to make sure this <img> element chooses the correct source for any DOM mutations and for any updates on those <source> elements under the same <picture> element. So we can get the correct result (e.g. getComputedStyle() calls) after these DOM mutations.

After checking the implementation in Blink and WebKit, it seems both select the image URL synchronously. In Gecko, we would like to follow this so we can pass the wpt, picture-aspect-ratio.html.

Just wondering are there any concerns to make the update of image source run asynchronously in the spec? Otherwise, it may be great to address this in the spec. (Or maybe I missed something.) Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: img

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions