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

2D canvas color parsing and serialization #47148

Merged
merged 4 commits into from
Sep 17, 2024
Merged

2D canvas color parsing and serialization #47148

merged 4 commits into from
Sep 17, 2024

Conversation

annevk
Copy link
Member

@annevk annevk commented Jul 16, 2024

@annevk
Copy link
Member Author

annevk commented Jul 16, 2024

@Loirooriol @weinig @svgeesus would very much appreciate your feedback! (And suggestions for additional tests.)

html/canvas/color.window.js Outdated Show resolved Hide resolved
@annevk
Copy link
Member Author

annevk commented Aug 14, 2024

I've addressed the feedback. Any remaining comments or can this be approved? (I won't merge until we merge the corresponding HTML standard PRs.)

weinig added a commit to weinig/WebKit that referenced this pull request Sep 3, 2024
… canvas

https://bugs.webkit.org/show_bug.cgi?id=278392

Reviewed by NOBODY (OOPS!).

When using HTML serialization (such as in canvas code), `rgb(none none none)`
should serialize as `#000000`, not `rgb(0, 0, 0)` as it currently does.

This is more consistent and matches other browsers.

* LayoutTests/fast/canvas/canvas-color-serialization.html:
* LayoutTests/fast/canvas/canvas-color-serialization-expected.txt:
    - Add serialization tests. Additional will be added in WPT
      via web-platform-tests/wpt#47148.

* Source/WebCore/platform/graphics/ColorSerialization.cpp:
(WebCore::serializationForHTML):
    - Make sure to call through to the HTML serializer for legacy
      rgb() colors that have none (which is indicated by the use
      of SRGBA<float> without the "useColorFunctionSerialization"
      bit set).
weinig added a commit to weinig/WebKit that referenced this pull request Sep 3, 2024
… canvas

https://bugs.webkit.org/show_bug.cgi?id=278392

Reviewed by NOBODY (OOPS!).

When using HTML serialization (such as in canvas code), `rgb(none none none)`
should serialize as `#000000`, not `rgb(0, 0, 0)` as it currently does.

This is more consistent and matches other browsers.

* LayoutTests/fast/canvas/canvas-color-serialization.html:
* LayoutTests/fast/canvas/canvas-color-serialization-expected.txt:
    - Add serialization tests. Additional will be added in WPT
      via web-platform-tests/wpt#47148.

* Source/WebCore/platform/graphics/ColorSerialization.cpp:
(WebCore::serializationForHTML):
    - Make sure to call through to the HTML serializer for legacy
      rgb() colors that have none (which is indicated by the use
      of SRGBA<float> without the "useColorFunctionSerialization"
      bit set).
webkit-commit-queue pushed a commit to weinig/WebKit that referenced this pull request Sep 3, 2024
… canvas

https://bugs.webkit.org/show_bug.cgi?id=278392

Reviewed by Darin Adler.

When using HTML serialization (such as in canvas code), `rgb(none none none)`
should serialize as `#000000`, not `rgb(0, 0, 0)` as it currently does.

This is more consistent and matches other browsers.

* LayoutTests/fast/canvas/canvas-color-serialization.html:
* LayoutTests/fast/canvas/canvas-color-serialization-expected.txt:
    - Add serialization tests. Additional will be added in WPT
      via web-platform-tests/wpt#47148.

* Source/WebCore/platform/graphics/ColorSerialization.cpp:
(WebCore::serializationForHTML):
    - Make sure to call through to the HTML serializer for legacy
      rgb() colors that have none (which is indicated by the use
      of SRGBA<float> without the "useColorFunctionSerialization"
      bit set).

Canonical link: https://commits.webkit.org/283120@main
@annevk annevk merged commit 6b71c57 into master Sep 17, 2024
18 of 20 checks passed
@annevk annevk deleted the annevk/canvas-color branch September 17, 2024 10:35
@annevk
Copy link
Member Author

annevk commented Sep 17, 2024

I've decided to go ahead with this as the standard is blocked on an editorial matter. Might as well have the tests reflect the latest.

annevk added a commit to whatwg/html that referenced this pull request Sep 19, 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 an HTML-compatible serialization method 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'.

Tests: web-platform-tests/wpt#47148.

Fixes #8917.
dizhang168 pushed a commit to dizhang168/html that referenced this pull request Oct 28, 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 an HTML-compatible serialization method 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'.

Tests: web-platform-tests/wpt#47148.

Fixes whatwg#8917.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants