Skip to content

Implement srcset 'h' descriptor and two-dimensional sizes - #63737

Merged
chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-8559899
Oct 16, 2026
Merged

chromium-wpt-export-bot merged 1 commit into
masterfrom
chromium-export-cl-8559899

Conversation

@chromium-wpt-export-bot

@chromium-wpt-export-bot chromium-wpt-export-bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Implements the parsing parts of
whatwg/html#13053 behind the
SrcsetTwoDimensionalSizes runtime flag:

  • Represent a resolved source size as a TargetBoxSize (width,
    optional height, and object_fit), and thread it through
    SizesAttributeParser, HTMLImageElement::SourceSize(), the preload
    scanner and BestFitSource*.
    One-dimensional sizes populate only width, so this is a no-op
    refactor for existing behavior.
  • Parse the \<positive-integer>h height descriptor in srcset when
    paired with a w descriptor, and compute each candidate's source
    concrete width from the TargetBoxSize and the candidate's aspect
    ratio when fitting with contain or cover.
  • Parse the explicit [contain | cover] \<length> \<length> source size
    syntax in sizes.

Making sizes="auto" two-dimensional (using the box height and computed
object-fit), and using the width/height attributes as a default
aspect ratio for candidates without an h descriptor, are implemented
in follow-up CLs.

Bug: 572724710
Change-Id: I17fd93318d0955fbb3d6ce8aed7d085174671ddd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8559899
Reviewed-by: Stefan Zager <szager@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@google.com>
Cr-Commit-Position: refs/heads/main@{#1720204}

Implements the parsing parts of
whatwg/html#13053 behind the
`SrcsetTwoDimensionalSizes` runtime flag:

- Represent a resolved source size as a `TargetBoxSize` (`width`,
  optional `height`, and `object_fit`), and thread it through
  `SizesAttributeParser`, `HTMLImageElement::SourceSize()`, the preload
  scanner and `BestFitSource*`.
  One-dimensional sizes populate only `width`, so this is a no-op
  refactor for existing behavior.
- Parse the `<positive-integer>h` height descriptor in `srcset` when
  paired with a `w` descriptor, and compute each candidate's source
  concrete width from the `TargetBoxSize` and the candidate's aspect
  ratio when fitting with `contain` or `cover`.
- Parse the explicit `[contain | cover] <length> <length>` source size
  syntax in `sizes`.

Making `sizes="auto"` two-dimensional (using the box height and computed
`object-fit`), and using the `width`/`height` attributes as a default
aspect ratio for candidates without an `h` descriptor, are implemented
in follow-up CLs.

Bug: 572724710
Change-Id: I17fd93318d0955fbb3d6ce8aed7d085174671ddd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8559899
Reviewed-by: Stefan Zager <szager@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@google.com>
Cr-Commit-Position: refs/heads/main@{#1720204}

@wpt-pr-bot wpt-pr-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot
chromium-wpt-export-bot merged commit d2727a5 into master Oct 16, 2026
28 checks passed
@chromium-wpt-export-bot
chromium-wpt-export-bot deleted the chromium-export-cl-8559899 branch October 16, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants