Repository navigation
script: correctly set fonts for offscreen canvases - #49915
Conversation
9268856 to
544248a
Compare
Signed-off-by: Jacob MacKenzie <[email protected]>
11516f1 to
5daf633
Compare
No weights, width, caps yet Signed-off-by: Jacob MacKenzie <[email protected]>
Signed-off-by: Jacob MacKenzie <[email protected]>
Signed-off-by: Jacob MacKenzie <[email protected]>
|
Question for anyone really, for units like Related
TL;DR : What's the consensis for units relative to font metrics or parent font metrics. The fallback values according to the spec for when it is impossible or impractical to measure (more like Chrome,) or see if stylo can have this function made available |
|
Personally I'm going to go for the spec suggestion of sane defaults. Will make a zulip thread for it after. |
canvases Signed-off-by: Jacob MacKenzie <[email protected]>
Dedicated and shared workers used to share the page's `FontContext`.
Fonts a worker loaded could end up in the page, and a font loading in a
worker made the page's `document.fonts.ready` wait for it. Now each of
these workers gets its own empty `FontContext`, which matches the spec
("Within a Worker document, the font source is initially empty") and
what Firefox does. Fonts loaded with `self.fonts` are stored there, and
their WebRender resources are freed when the worker shuts down, like the
layout thread does for pages. Service workers already have their own
`FontContext`, so they're unchanged.
This also fixes loading a second `FontFace` for a URL that was already
loaded for the same family. That failed with "Failed to load font data"
on pages too, because script loads skipped URLs that were already
loaded.
Testing: a page's `document.fonts.ready` no longer waits for a slow font
in a worker (7 ms instead of 2.7 s). With servo#49915 applied locally, a
worker's canvas draws with the font the worker loaded, and can't see
fonts loaded by the page. I also created and closed 20 workers that each
load a font and draw text. Two page tests that loaded the same
`FontFace` twice no longer error, and the WPT `workers` and canvas text
tests still pass.
This builds on servo#50046, so its commits are included here until that one
lands.
Part of servo#49892
Signed-off-by: rogerkorantenng <[email protected]>
Signed-off-by: Jacob MacKenzie <[email protected]>
Signed-off-by: Jacob MacKenzie <[email protected]>
|
Test results for linux-wpt from merge queue job (#45674727058): Flaky unexpected result (25)
Stable unexpected results that are known to be intermittent (5)
Stable unexpected results (38)
|
|
Test results for linux-wpt from merge queue job (#45693508535): Flaky unexpected result (28)
Stable unexpected results that are known to be intermittent (6)
Stable unexpected results (31)
|
|
@mwja These results look good. You should run |
Signed-off-by: Jacob MacKenzie <[email protected]>
|
@mrobinson done, I had to mark the null character width WPT as failing though ( |
Adjusts the set_font implementation on `CanvasState` to correctly handle fonts on offscreen canvases **Important note:** the regular `<canvas>` element set_font incorrectly accepts `inherit` and `initial`, but I think this is a different substantial change not for this PR. [spec](https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font:~:text=value%20%28but%20without%20supporting%20property%2Dindependent%20style%20sheet%20syntax%20like%20%27inherit%27%29%2C) Also full disclosure, there's a bit of manually parsing of font declarations (`em` and `rem` being the only accepted units of `LengthUnit`. - question below) Testing: Lots of tests in tests/wpt/meta/html/canvas/offscreen/text now and tests/wpt/meta/html/canvas/offscreen/reset unexpectedly pass. Expectations have been updated. Fixes: servo#49890 --------- Signed-off-by: Jacob MacKenzie <[email protected]>
Adjusts the set_font implementation on
CanvasStateto correctly handle fonts on offscreen canvasesImportant note: the regular
<canvas>element set_font incorrectly acceptsinheritandinitial, but I think this is a different substantial change not for this PR. specAlso full disclosure, there's a bit of manually parsing of font declarations (
emandrembeing the only accepted units ofLengthUnit. - question below)Testing: Lots of tests in tests/wpt/meta/html/canvas/offscreen/text now and tests/wpt/meta/html/canvas/offscreen/reset unexpectedly pass. Expectations have been updated.
Fixes: #49890