Skip to content

[css-images] Define what happens when all image-set options are invalid #8266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
emilio opened this issue Dec 29, 2022 · 7 comments
Open

Comments

@emilio
Copy link
Collaborator

emilio commented Dec 29, 2022

https://drafts.csswg.org/css-images-4/#image-set-notation says:

First, remove any <image-set-option>s from the list that specify an unknown or unsupported MIME type in their type() value.
[...]
Finally, among the remaining <image-set-option>s, make a UA-specific choice of which to load, based on whatever criteria deemed relevant (such as the resolution of the display, connection speed, etc).

What if there are no remaining options? Firefox chooses just the first here but that's fairly arbitrary as well.

@SebastianZ
Copy link
Contributor

I guess, the options in that case are:

  1. Let the UA choose an arbitrary one (like Firefox does).
  2. Specify which one to choose.
  3. Don't choose any option. I.e. no image is displayed.

Sebastian

moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 5, 2023
The test is wrong. The spec is very clear that the image-set() function
shouldn't become invalid due to the type() argument.

The spec doesn't explicitly define what happens when none of the items
are valid, so for now use our behavior (just first image), but
w3c/csswg-drafts#8266 is on file to possibly
change this behavior.

In any case the tests before this patch should never render green.

Differential Revision: https://phabricator.services.mozilla.com/D165695

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1806025
gecko-commit: 6cc8cc1231f4fb7272e1b9cf82d9cac6cdf7d516
gecko-reviewers: dholbert
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Feb 5, 2023
The test is wrong. The spec is very clear that the image-set() function
shouldn't become invalid due to the type() argument.

The spec doesn't explicitly define what happens when none of the items
are valid, so for now use our behavior (just first image), but
w3c/csswg-drafts#8266 is on file to possibly
change this behavior.

In any case the tests before this patch should never render green.

Differential Revision: https://phabricator.services.mozilla.com/D165695
moz-wptsync-bot pushed a commit to web-platform-tests/wpt that referenced this issue Feb 6, 2023
The test is wrong. The spec is very clear that the image-set() function
shouldn't become invalid due to the type() argument.

The spec doesn't explicitly define what happens when none of the items
are valid, so for now use our behavior (just first image), but
w3c/csswg-drafts#8266 is on file to possibly
change this behavior.

In any case the tests before this patch should never render green.

Differential Revision: https://phabricator.services.mozilla.com/D165695

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1806025
gecko-commit: 6cc8cc1231f4fb7272e1b9cf82d9cac6cdf7d516
gecko-reviewers: dholbert
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Feb 7, 2023
The test is wrong. The spec is very clear that the image-set() function
shouldn't become invalid due to the type() argument.

The spec doesn't explicitly define what happens when none of the items
are valid, so for now use our behavior (just first image), but
w3c/csswg-drafts#8266 is on file to possibly
change this behavior.

In any case the tests before this patch should never render green.

Differential Revision: https://phabricator.services.mozilla.com/D165695
@rreno
Copy link

rreno commented Feb 17, 2023

I think we should choose not to load any image if there are no options remaining after filtering by type.

If the [<string>], when parsed as a valid MIME type string, is either not valid, or is valid but doesn’t specify a supported image format, the [<image-set-option>] does not define a valid option. (This has no effect on the validity of the image-set() function.)

Since the MIME type string doesn't determine whether or not the image-set function itself is valid we shouldn't fall back to a previous value for the property.

@rreno
Copy link

rreno commented Feb 22, 2023

I made a PR to change the tests in WPT web-platform-tests/wpt#38662

Please have a look! I can't add reviewers manually.

@emilio
Copy link
Collaborator Author

emilio commented Feb 23, 2023

I'd prefer to have a resolution or a quick ack from the spec editors before changing the test again, but sure, looks good if we decide to go that route, and it seems sensible.

I don't think it matters much in practice between choosing first or choosing not to render an image because the only way to get an empty set but still render something is to lie in the type() function.

Still explicitly choosing nothing seems less confusing, so I'd support that.

@tabatkins @fantasai @LeaVerou can you confirm? Thanks!

rreno added a commit to web-platform-tests/wpt that referenced this issue Feb 23, 2023
… no (#38662)

supported types in the image-set

If the image-set does not contain any images with a supported MIME type
the image set is valid but empty. In that case we shouldn't expect any
image to render.

See w3c/csswg-drafts#8266 for discussion.
@tabatkins
Copy link
Member

Yeah if we discard all the options I'd expect it to be an "invalid image".

tabatkins added a commit that referenced this issue Feb 24, 2023
@tabatkins
Copy link
Member

Happy to get a resolution on this, but for now I've gone ahead and edited that into the spec - if you remove all the options, it's an invalid image (and thus renders as a transparent black image with no dimensions).

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Mar 7, 2023
…der if there are no supported types in the image-set, a=testonly

Automatic update from web-platform-tests
[css-images] [image-set] Don't expect an image to render if there are no (#38662)

supported types in the image-set

If the image-set does not contain any images with a supported MIME type
the image set is valid but empty. In that case we shouldn't expect any
image to render.

See w3c/csswg-drafts#8266 for discussion.
--

wpt-commits: 1ba5cfed0836d1f7ea78b115ef6d9c7ed767b8b9
wpt-pr: 38662
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Mar 28, 2023
The test is wrong. The spec is very clear that the image-set() function
shouldn't become invalid due to the type() argument.

The spec doesn't explicitly define what happens when none of the items
are valid, so for now use our behavior (just first image), but
w3c/csswg-drafts#8266 is on file to possibly
change this behavior.

In any case the tests before this patch should never render green.

Differential Revision: https://phabricator.services.mozilla.com/D165695

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1806025
gecko-commit: 6cc8cc1231f4fb7272e1b9cf82d9cac6cdf7d516
gecko-reviewers: dholbert
marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Mar 28, 2023
… no (#38662)

supported types in the image-set

If the image-set does not contain any images with a supported MIME type
the image set is valid but empty. In that case we shouldn't expect any
image to render.

See w3c/csswg-drafts#8266 for discussion.
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-images] Define what happens when all image-set options are invalid, and agreed to the following:

  • RESOLVED: if there are no valid options, render as an invalid image
The full IRC log of that discussion <emeyer> emilio: If you specify an invalid type that the UA doesn’t understand, we don’t have a good answer for what happens
<emeyer> …Does the UA try to load and then discard?
<emeyer> …Tab put in the spec we render an invalid image
<emeyer> …The difference is that if the type function ends up invalid, like say it’s PNG in the CSS but then serve a JPEG, it’s a problem
<emeyer> …I think what Tab put in the spec is fine
<emeyer> astearns: Proposed resolution is to accept what’s been added to the spec?
<emeyer> TabAtkins: More specifically, if there are no valid options, it rendered as an invalid image
<fantasai> +1
<emeyer> astearns: Objections?
<emeyer> RESOLVED: if there are no valid options, render as an invalid image

aosmond pushed a commit to aosmond/gecko that referenced this issue May 18, 2023
…der if there are no supported types in the image-set, a=testonly

Automatic update from web-platform-tests
[css-images] [image-set] Don't expect an image to render if there are no (#38662)

supported types in the image-set

If the image-set does not contain any images with a supported MIME type
the image set is valid but empty. In that case we shouldn't expect any
image to render.

See w3c/csswg-drafts#8266 for discussion.
--

wpt-commits: 1ba5cfed0836d1f7ea78b115ef6d9c7ed767b8b9
wpt-pr: 38662
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants