Skip to content
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

background-blend-mode test probably needs to be extended and fixed #42496

Closed
karlcow opened this issue Oct 12, 2023 · 7 comments · Fixed by #42497 or #42518
Closed

background-blend-mode test probably needs to be extended and fixed #42496

karlcow opened this issue Oct 12, 2023 · 7 comments · Fixed by #42497 or #42518

Comments

@karlcow
Copy link
Contributor

karlcow commented Oct 12, 2023

test_computed_value("background-blend-mode", "normal, luminosity");
test_computed_value("background-blend-mode", "screen, overlay");
test_computed_value("background-blend-mode", "color, saturation");

Followup of discussions in https://bugs.webkit.org/show_bug.cgi?id=261552#c10

In https://drafts.fxtf.org/compositing-1/#background-blend-mode

Defines the blending mode of each background layer.

Each background layer must blend with the element’s background layer
that is below it and the element’s background color. Background layers
must not blend with the content that is behind the element, instead
they must act as if they are rendered into an isolated group.

and

The background-blend-mode list must be applied in the same order
as background-image [CSS3BG]. This means that the first element
in the list will apply to the layer that is on top. If a property
doesn’t have enough comma-separated values to match the number
of layers, the UA must calculate its used value by repeating the
list of values until there are enough.

The layering seems to be defined in
https://drafts.csswg.org/css-backgrounds-3/#layering

It says:

Each of the images is sized, positioned, and tiled according
to the corresponding value in the other background properties.

Then (my emphasis)

The lists are matched up from the first value: excess values at the end are not used.

Then

If a property doesn’t have enough comma-separated values
to match the number of layers, the UA must calculate its used value
by repeating the list of values until there are enough.

The example in this section

background-image: url(flower.png), url(ball.png), url(grass.png);
background-position: center center, 20% 80%, top left, bottom right;
background-origin: border-box, content-box;
background-repeat: no-repeat;

has exactly the same effect as this set with the extra position dropped and the missing values for background-origin and background-repeat filled in (emphasized for clarity):

background-image: url(flower.png), url(ball.png), url(grass.png);
background-position: center center, 20% 80%, top left;
background-origin: border-box, content-box, border-box;
background-repeat: no-repeat, no-repeat, no-repeat;

And we can see that for background-position where there is 4 values list with an extra bottom right, it drops it to make it a 3 values list.

So from this I would say the test as currently defined on WPT is wrong and probably the implementation of Gecko too. ( @emilio )

the background-blend-mode-computed.htm

could be fixed for multiple images for the last 3 tests
Or maybe better add a new series of tests for specific case of multiple images and their relations to properties. dropping and repeating the values.

@karlcow
Copy link
Contributor Author

karlcow commented Oct 12, 2023

karlcow added a commit to karlcow/wpt that referenced this issue Oct 12, 2023
see https://drafts.fxtf.org/compositing-1/#background-blend-mode
and https://drafts.csswg.org/css-backgrounds-3/#layering
> The lists are matched up from the first value: excess values at the end are not used.

> If a property doesn't have enough comma-separated values
> to match the number of layers, the UA must calculate its used value
> by repeating the list of values until there are enough.
annevk pushed a commit that referenced this issue Oct 12, 2023
The current test for the computed values of backgroundBlendMode were partially incorrect.

The spec says:

1. To drop the excess values depending on the number of images
2. To add the initial defined values if not enough.

This fixes the current test and add another test for multiple images.

Fixes #42496.
@emilio
Copy link
Contributor

emilio commented Oct 12, 2023

"are not used" doesn't imply "are not part of the computed value". @karlcow can you revert your patch? Would've been nice to at least wait for comments from other engines before modifying the tests? There's existing discussion in the CSS working group about this and my recollection is that gecko was right.

@emilio emilio reopened this Oct 12, 2023
@emilio
Copy link
Contributor

emilio commented Oct 12, 2023

w3c/csswg-drafts#7164 has the latest discussion on these things. I forget the exact resolutions and today is a bank holiday for me, but I'm pretty sure dropping specified stuff from the computed value is not it.

@karlcow
Copy link
Contributor Author

karlcow commented Oct 12, 2023

Ah! This sentence in
w3c/csswg-drafts#7164 (comment)

fantasai: Don't specifically say the computed value is same as specified value, it's implied. can be louder in the spec so it's obvious

So yup. I probably need to change again this patch. I think we should still add more tests to cover the different cases.

@karlcow
Copy link
Contributor Author

karlcow commented Oct 12, 2023

And the update by @fantasai
w3c/csswg-drafts@dce5c9d
aka https://drafts.csswg.org/css-values-4/#linked-properties

It says:

The computed values of the coordinating list properties are not affected by such truncation or repetition.

@annevk
Copy link
Member

annevk commented Oct 12, 2023

It's been reverted: #42503.

karlcow added a commit to karlcow/wpt that referenced this issue Oct 13, 2023
This was discussed in
w3c/csswg-drafts#7164 (comment)

> Don't specifically say the computed value is same as specified value,
> it's implied. can be louder in the spec so it's obvious

The specification for CSS values 4 makes it more explicit
https://drafts.csswg.org/css-values-4/#linked-properties

> The computed values of the coordinating list properties are
> not affected by such truncation or repetition.

So this patch add comments in the code to make sure this is understood
and add a test to cover the case of multiple images.
karlcow added a commit to karlcow/wpt that referenced this issue Oct 13, 2023
This was discussed in
w3c/csswg-drafts#7164 (comment)

> Don't specifically say the computed value is same as specified value,
> it's implied. can be louder in the spec so it's obvious

The specification for CSS values 4 makes it more explicit
https://drafts.csswg.org/css-values-4/#linked-properties

> The computed values of the coordinating list properties are
> not affected by such truncation or repetition.

So this patch add comments in the code to make sure this is understood
and add a test to cover the case of multiple images.
@karlcow
Copy link
Contributor Author

karlcow commented Oct 13, 2023

Created a new PR. Addressing @emilio comments and giving context so the same mistakes are not not done in the future.

#42518

karlcow added a commit to karlcow/wpt that referenced this issue Oct 13, 2023
This was discussed in
w3c/csswg-drafts#7164 (comment)

> Don't specifically say the computed value is same as specified value,
> it's implied. can be louder in the spec so it's obvious

The specification for CSS values 4 makes it more explicit
https://drafts.csswg.org/css-values-4/#linked-properties

> The computed values of the coordinating list properties are
> not affected by such truncation or repetition.

So this patch add comments in the code to make sure this is understood
and add a test to cover the case of multiple images.
karlcow added a commit to karlcow/wpt that referenced this issue Oct 13, 2023
This was discussed in
w3c/csswg-drafts#7164 (comment)

> Don't specifically say the computed value is same as specified value,
> it's implied. can be louder in the spec so it's obvious

The specification for CSS values 4 makes it more explicit
https://drafts.csswg.org/css-values-4/#linked-properties

> The computed values of the coordinating list properties are
> not affected by such truncation or repetition.

So this patch add comments in the code to make sure this is understood
and add a test to cover the case of multiple images.
annevk pushed a commit that referenced this issue Oct 13, 2023
This was discussed in w3c/csswg-drafts#7164 (comment).

> Don't specifically say the computed value is same as specified value,
> it's implied. can be louder in the spec so it's obvious

The specification for CSS values 4 makes it more explicit
https://drafts.csswg.org/css-values-4/#linked-properties

> The computed values of the coordinating list properties are
> not affected by such truncation or repetition.

So this patch add comments in the code to make sure this is understood
and add a test to cover the case of multiple images.

Fixes #42496.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants