Skip to content

Force size containment for auto-sizes - #9493

Merged
zcorpan merged 4 commits into
mainfrom
zcorpan/auto-sizes-implementable
Nov 30, 2023
Merged

zcorpan merged 4 commits into
mainfrom
zcorpan/auto-sizes-implementable

Conversation

@zcorpan

@zcorpan zcorpan commented Jul 6, 2023 •

Copy link
Copy Markdown
Member

The 'concrete object size ignoring natural dimensions' concept was not implementable. This change makes sizes=auto required on img to use auto-sizes (still optional on source) and forces size containment so that the image size is the same before and after an image has loaded, to prevent double downloads.

Fixes #9448.

(See WHATWG Working Mode: Changes for more details.)


/embedded-content.html ( diff )
/images.html ( diff )
/rendering.html ( diff )

Comment thread source Resolved
@joemcgill

Copy link
Copy Markdown

This may be somewhat off-topic (please feel free to redirect me, if so) but one aspect of the parsing algorithm is still unclear to me. If a platform (e.g. WordPress) generated image markup that looks like this (note the omission of a loading="lazy" attribute):

<img src="200.jpg" width="200" height="200" srcset="200.jpg 200w, 400.jpg 400w, 600.jpg 600w" sizes="auto, 200px" />

Would the omission of the loading attribute cause sizes to be calculates as the default 100vw value, would the 200px value be respected, or would size containment come into play? I would hope that the the "200px" value would be respected in this case so that platforms could add auto to the beginning of a sizes and dynamically decide whether to add a loading attribute while constructing the markup. In other words, if auto can't be applied because the image is not being lazy loaded, then the browser should respect the next items in the media condition.

@zcorpan

zcorpan commented Aug 29, 2023

Copy link
Copy Markdown
Member Author

@joemcgill right now, the intent is that auto would be returned by the "parse a sizes attribute" algorithm, and evaluate to 100vw. But I can see that falling back to the next value can be useful. I'll file a new issue.

The 'concrete object size ignoring natural dimensions' concept was not implementable. This change makes `sizes=auto` required on `img` to use auto-sizes (still optional on `source`)
and forces size containment so that the image size is the same before and after an image has loaded, to prevent double downloads.

Fixes #9448.
@zcorpan
zcorpan force-pushed the zcorpan/auto-sizes-implementable branch from bdf7972 to e90b823 Compare September 5, 2023 09:35
@zcorpan

zcorpan commented Sep 5, 2023

Copy link
Copy Markdown
Member Author

I wrote tests for the UA stylesheet in web-platform-tests/wpt#41817

I pushed 1b6f84a to fix #9648 and #9649. Still need to write tests for the sizes parser changes.

@foolip

foolip commented Sep 8, 2023

Copy link
Copy Markdown
Member

@zcorpan any idea why PR preview is failing here? What's the best way to retry it?

@foolip foolip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've done an editorial review and tried to ensure this PR does what it claims, but I have not gone through the history of #9448 to understand this deeply. I trust that prospective implementers will evaluate the implementability when reviewing this.

Comment thread source Resolved
Comment thread source Resolved
Comment thread source Resolved
Comment thread source Resolved
Comment thread source Resolved
Comment thread source Resolved
@zcorpan
zcorpan force-pushed the zcorpan/auto-sizes-implementable branch from 1b6f84a to 5ee976b Compare October 3, 2023 14:44
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 28, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Comment thread source Resolved
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 28, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 29, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413

@tcaptan-cr tcaptan-cr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 29, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
@zcorpan

zcorpan commented Nov 30, 2023

Copy link
Copy Markdown
Member Author

@tcaptan-cr has implemented this in Chromium and created remaining tests, see https://bugs.chromium.org/p/chromium/issues/detail?id=1359051

I believe this is ready to merge!

@foolip foolip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've reviewed the changes since #9493 (review)

@zcorpan
zcorpan merged commit 193c67d into main Nov 30, 2023
@zcorpan
zcorpan deleted the zcorpan/auto-sizes-implementable branch November 30, 2023 12:59
zcorpan added a commit to web-platform-tests/wpt that referenced this pull request Nov 30, 2023
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 30, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
aarongable pushed a commit to chromium/chromium that referenced this pull request Nov 30, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 30, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 30, 2023
Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 4, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 4, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Dec 5, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Dec 5, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 7, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: fdb4314a7244387e3eab803734be403fd4d82471
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 7, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 5a6d84b529aebea9ea7277cc8a9aed89a7d2e349
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 7, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: fdb4314a7244387e3eab803734be403fd4d82471
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 7, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 5a6d84b529aebea9ea7277cc8a9aed89a7d2e349
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 7, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: fdb4314a7244387e3eab803734be403fd4d82471
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 7, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 5a6d84b529aebea9ea7277cc8a9aed89a7d2e349
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 13, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 13, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptan@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 16, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: 5e6766903b9d6ff31473311f3e87774095251eda
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Dec 16, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 4b7ff7848d33231d5746355ea34056b07ac6ed1d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 16, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: 5e6766903b9d6ff31473311f3e87774095251eda
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Dec 16, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 4b7ff7848d33231d5746355ea34056b07ac6ed1d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 16, 2023
…>, a=testonly

Automatic update from web-platform-tests
HTML: test UA styles for <img sizes=auto>

See whatwg/html#9493

--

wpt-commits: 0f673999acbd28c5584e03f61da96a30e38ac092
wpt-pr: 41817

UltraBlame original commit: 5e6766903b9d6ff31473311f3e87774095251eda
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Dec 16, 2023
…stonly

Automatic update from web-platform-tests
Add auto sizes wpt rendering tests

Also update tests in size-auto to match spec update:
whatwg/html#9493

Spec:
https://html.spec.whatwg.org/#parsing-a-sizes-attribute
https://whatpr.org/html/9493/images.html#parsing-a-sizes-attribute

R=pdr
Bug: 1359051

Change-Id: I77ecbfef3a5a63101929f67025699550cc7f6413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5064461
Commit-Queue: Traian Captan <tcaptanchromium.org>
Reviewed-by: Philip Rogers <pdrchromium.org>
Cr-Commit-Position: refs/heads/main{#1231380}

--

wpt-commits: 5904d197e1d4318c4fefb12bf406c921fbd123f3
wpt-pr: 43385

UltraBlame original commit: 4b7ff7848d33231d5746355ea34056b07ac6ed1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

auto-sizes concrete object size ignoring natural dimensions is not implementable

5 participants