Skip to content

Test 2D sizes, srcset h descriptors, and normative 2D image source selection - #64025

Open
noamr wants to merge 23 commits into
masterfrom
noamr/untent-sizes-2d
Open

noamr wants to merge 23 commits into
masterfrom
noamr/untent-sizes-2d

Conversation

@noamr

@noamr noamr commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Tests for two-dimensional sizes (cover / contain), srcset h descriptors, and normative 2D image source selection, for whatwg/html#13053. Un-tentatives the tests from https://issues.chromium.org/issues/572724710 and folds in the normative selection tests that were previously in #64736.

sizes parsing and concrete width (html/semantics/embedded-content/the-img-element/sizes/):

  • Rename sizes-2d.tentative.html to sizes-2d.html and include the dimension attribute aspect ratio coverage from https://crrev.com/c/8563321.
  • Add sizes-auto-2d.html (un-tentatived from https://crrev.com/c/8563320 and https://crrev.com/c/8563321).
  • Expand coverage:
    • Case-insensitive COVER / Cover / Contain, zero lengths, min() / max() / clamp(), negative calc() clamped to 0px, and em units ignoring the element's font-size.
    • Invalid 2D <source-size-value>s (negative second length, unitless non-zero numbers, percentages, missing/duplicate/misplaced fit keywords, var()), and a non-first auto being ignored.
    • h before w (1h 50w), and candidates where only some specify h (aspect ratio computed per candidate).
    • Dimension attribute aspect ratio edge cases; <source> with only height not falling back to <img>; <link rel=preload> width/height ignored; <source> outside <picture> or after <img> ignored.
    • Dynamic width/height mutation and removal on <img> and <source> (without also mutating srcset), content-box changes on auto-sized <img> with object-fit, and retaining/resetting the 2D last auto-sizes size.
    • 2D cases have a 1D fallback (e.g. , 1px) where needed, so browsers without 2D support can't pass by falling back to 100vw.

Normative 2D source selection (srcset/select-an-image-source-2d.html):

  • Picking the smallest density >= devicePixelRatio (and the highest when all are below it) using 2D-normalized densities, for <img>, <picture><source>, and <link rel=preload imagesrcset imagesizes>.
  • Mixed aspect ratios where normalization inverts the w order; deduplicating candidates (including x vs. w+h) that normalize to the same density; zero concrete width giving Infinity density.
  • Dimension attribute aspect ratio: <img> and <source> width/height, inheritance and override, per-candidate h together with the fallback aspect ratio, <picture> falling back from <source> to <img>, removeAttribute('height') re-selection, and a null default aspect ratio for <link rel=preload>.
  • Cache and deduplication invariants, CSS zoom on elements vs. iframes (including fractional zoom), and sizes="auto" with object-fit.

Optional cache preference (srcset/select-an-image-source-2d-cached.optional.html): preferring already-loaded (or data: / preloaded) higher-density candidates, keeping a loaded candidate when cover changes to contain, sizes="auto" with object-fit: contain, and re-selection when iframe zoom changes. Fallback sizes and candidates are chosen so browsers that only do 1D selection can't pass.

Link headers (preload/link-header-preload-imagesrcset-2d.html + .headers): rel=preload; as=image with h descriptors and cover / contain / media-conditioned 2D imagesizes, plus a w-only group (null default aspect ratio).

@noamr
noamr force-pushed the noamr/untent-sizes-2d branch from 08a4a52 to 61669a0 Compare November 5, 2026 16:03
@noamr noamr changed the title Un-tentative 2D sizes and srcset h descriptor tests and expand coverage Test 2D sizes, srcset h descriptors, and normative 2D image source selection Nov 5, 2026

This branch has not been deployed

No deployments
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