Skip to content

Commit

Permalink
Handle font values that contain "var()" for OffscreenCanvas
Browse files Browse the repository at this point in the history
This is an offscreen equivalent to Bug 1131922. The fix for that
bug introduced CSSParser::ParseFont, which handles var() and CSS-wide
keywords correctly.

Use CSSParser::ParseFont for OffscreenCanvasRenderingContext2D as well.

Fixed: 1233430
Change-Id: Ic2119c64dec428f3b34f7fc0c15c86b6bcfe9195
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3058649
Reviewed-by: Aaron Krajeski <[email protected]>
Commit-Queue: Anders Hartvoll Ruud <[email protected]>
Cr-Commit-Position: refs/heads/master@{#906604}
  • Loading branch information
andruud authored and chromium-wpt-export-bot committed Jul 29, 2021
1 parent 34cb7e9 commit e7d848c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions html/canvas/offscreen/text/2d.text.font.parse.invalid.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ <h1>2d.text.font.parse.invalid</h1>
ctx.font = '10px inherit';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = '10px revert';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = 'var(--x)';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = 'var(--x, 10px serif)';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = '1em serif; background: green; margin: 10px';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");
Expand Down
12 changes: 12 additions & 0 deletions html/canvas/offscreen/text/2d.text.font.parse.invalid.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ ctx.font = '20px serif';
ctx.font = '10px inherit';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = '10px revert';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = 'var(--x)';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = 'var(--x, 10px serif)';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");

ctx.font = '20px serif';
ctx.font = '1em serif; background: green; margin: 10px';
_assertSame(ctx.font, '20px serif', "ctx.font", "'20px serif'");
Expand Down
12 changes: 12 additions & 0 deletions html/canvas/tools/yaml/offscreen/text.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
ctx.font = '10px inherit';
@assert ctx.font === '20px serif';
ctx.font = '20px serif';
ctx.font = '10px revert';
@assert ctx.font === '20px serif';
ctx.font = '20px serif';
ctx.font = 'var(--x)';
@assert ctx.font === '20px serif';
ctx.font = '20px serif';
ctx.font = 'var(--x, 10px serif)';
@assert ctx.font === '20px serif';
ctx.font = '20px serif';
ctx.font = '1em serif; background: green; margin: 10px';
@assert ctx.font === '20px serif';
Expand Down

0 comments on commit e7d848c

Please sign in to comment.