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

Update 2D canvas color serialization #10481

Merged
merged 3 commits into from
Sep 19, 2024
Merged

Update 2D canvas color serialization #10481

merged 3 commits into from
Sep 19, 2024

Conversation

annevk
Copy link
Member

@annevk annevk commented Jul 15, 2024

Although fillStyle, strokeStyle, and shadowColor setters accepted all kinds of CSS color values, those could not be serialized. Update that by relying on CSS Color for serialization instead, which now has a HTMLCompatible named parameter to preserve compatibility with 2D canvas and for certain colors.

While here, also link the algorithm to be used for color space conversion and correct the reference for 'relative-colorimetric'.

Fixes #8917.


@Kaiido do you happen to know if we already have test coverage for this?

@weinig this might be of interest to you.

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


/canvas.html ( diff )
/infrastructure.html ( diff )

@annevk
Copy link
Member Author

annevk commented Jul 15, 2024

@whatwg/canvas @whatwg/css please review.

@Kaiido
Copy link
Member

Kaiido commented Jul 16, 2024

@Kaiido do you happen to know if we already have test coverage for this?

I think @mysteryDate did add tests for the serialization of color-mix() recently, but other serialization tests all seem to be about "HTMLCompatible" cases, so I guess new tests are needed, but Aaron will know better than me.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
annevk added a commit to web-platform-tests/wpt that referenced this pull request Jul 16, 2024
@annevk annevk requested review from domenic, svgeesus, kdashg and mysteryDate and removed request for svgeesus August 15, 2024 10:10
@annevk annevk added agenda+ To be discussed at a triage meeting and removed agenda+ To be discussed at a triage meeting labels Aug 15, 2024
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Let's get w3c/csswg-drafts#10550 (comment) resolved.

source Outdated
@@ -67772,8 +67773,9 @@ try {

<ol>
<li><p>If <span>this</span>'s <span data-x="concept-CanvasFillStrokeStyles-fill-style">fill
style</span> is a CSS color, then return the <span data-x="serialization of a
color">serialization</span> of that color.</p></li>
style</span> is a CSS color, then return the <span data-x="serialize a CSS &lt;color>
Copy link
Member

Choose a reason for hiding this comment

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

Preexisting issue, not necessary to fix: it'd be nice if "CSS color" linked to some definition, in all its usage sites.

Copy link

Choose a reason for hiding this comment

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

it'd be nice if "CSS color" linked to some definition, in all its usage sites.

Agreed, I suggest https://drafts.csswg.org/css-color-4/#typedef-color

which says

Colors in CSS are represented by the <color> type:

Choose a reason for hiding this comment

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

@annevk what do you think, does that link work for you?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've decided to not address this for now. I think what we want in HTML is mostly some kind of abstract concept and not a syntax construct. We want to reference what that gets parsed into in a number of places.

@mysteryDate
Copy link
Contributor

@Kaiido do you happen to know if we already have test coverage for this?

I think @mysteryDate did add tests for the serialization of color-mix() recently, but other serialization tests all seem to be about "HTMLCompatible" cases, so I guess new tests are needed, but Aaron will know better than me.

I don't believe we have any tests for this for canvas specifically, those would go in the .yaml files in /html/canvas/. Quick search turns up nothing:

https://source.chromium.org/search?q=f:wpt%20f:canvas%20oklab&sq=package:chromium

I think that I didn't add any because I was waiting for the spec to update.

Copy link
Contributor

@mysteryDate mysteryDate left a comment

Choose a reason for hiding this comment

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

This all looks good to me! Thanks for doing this @annevk !

annevk added a commit to web-platform-tests/wpt that referenced this pull request Sep 17, 2024
@svgeesus
Copy link

@annevk does my suggested link to resolve @domenic comment work here?

@annevk
Copy link
Member Author

annevk commented Sep 17, 2024

@svgeesus I was out sick, hence the delay here. I think that works, but I see that @domenic hasn't replied yet to the recent updates to CSS Color which were primarily blocking this PR. I'll see about reviewing those now and supplying you with better examples.

Although fillStyle, strokeStyle, and shadowColor setters accepted all kinds of CSS color values, those could not be serialized. Update that by relying on CSS Color for serialization instead, which now has a HTMLCompatible named parameter to preserve compatibility with 2D canvas and <input type=color> for certain colors.

While here, also link the algorithm to be used for color space conversion and correct the reference for 'relative-colorimetric'.

Fixes #8917.
@annevk
Copy link
Member Author

annevk commented Sep 19, 2024

@domenic it now uses the "with HTML-compatible serialization requested" wording. Good enough? I'll file implementation bugs too.

@annevk annevk merged commit 236e055 into main Sep 19, 2024
2 checks passed
@annevk annevk deleted the annevk/canvas-colors branch September 19, 2024 08:12
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 25, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Sep 26, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148

UltraBlame original commit: ba0041c24e1332e588896b9fb72ed44e32f1a385
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Sep 26, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148

UltraBlame original commit: ba0041c24e1332e588896b9fb72ed44e32f1a385
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 26, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148

UltraBlame original commit: ba0041c24e1332e588896b9fb72ed44e32f1a385
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Sep 26, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Sep 27, 2024
…n, a=testonly

Automatic update from web-platform-tests
2D canvas color parsing and serialization

For whatwg/html#8917, w3c/csswg-drafts#10550, and whatwg/html#10481.
--

wpt-commits: 6b71c578c4e9113e56b5445d4697b6a97aedf37d
wpt-pr: 47148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Canvas 2D context color serialization
5 participants