-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb+LibGfx: Serialize HTML canvas fill/strokeStyle colors correctly
Before this change we were serializing them in a bogus 8-digit hex color format that isn't actually recognized by HTML. This code will need more work when we start supporting color spaces other than sRGB. (cherry picked from commit 4590c081c2eb257232463ed660498a02f9bbe7b8; amended expected output because serenity does not yet have LadybirdBrowser/ladybird#1603)
- Loading branch information
1 parent
4597138
commit 0b57196
Showing
7 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
Tests/LibWeb/Text/expected/canvas/fillStyle-serialization.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
`green` -> `#008000` | ||
`rgba(128, 128, 128, 0.4)` -> `rgba(128, 128, 128, 0.4)` | ||
`rgba(128, 128, 128, 0)` -> `rgba(128, 128, 128, 0)` | ||
`rgba(128, 128, 128, 1)` -> `#808080` | ||
`rgb(128, 128, 128)` -> `#808080` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
1. "#00ff00ff" | ||
2. "#ff0000ff" | ||
3. "#0000ffff" | ||
4. "#00ff00ff" | ||
5. "#ff0000ff" | ||
1. "#00ff00" | ||
2. "#ff0000" | ||
3. "#0000ff" | ||
4. "#00ff00" | ||
5. "#ff0000" |
18 changes: 18 additions & 0 deletions
18
Tests/LibWeb/Text/input/canvas/fillStyle-serialization.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script src="../include.js"></script> | ||
<canvas id="c" width=300 height=300></canvas> | ||
<script> | ||
test(() => { | ||
let x = c.getContext("2d"); | ||
|
||
function go(color) { | ||
x.fillStyle = color; | ||
println("`" + color + "` -> `" + x.fillStyle + "`"); | ||
} | ||
|
||
go("green"); | ||
go("rgba(128, 128, 128, 0.4)"); | ||
go("rgba(128, 128, 128, 0)"); | ||
go("rgba(128, 128, 128, 1)"); | ||
go("rgb(128, 128, 128)"); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters