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
feat: Support font-relative ch
and ic
units
#32171
Conversation
🔨 Triggering try run (#8876068432) for Linux WPT |
Test results for linux-wpt-layout-2020 from try job (#8876068432): Flaky unexpected result (17)
Stable unexpected results that are known to be intermittent (17)
Stable unexpected results (57)
|
|
After servo#31966, which made it possible for the first time to resolve font-relative CSS units, this change adds support for the `ch` and `ic` units. One difference with the `ex` unit that was added in that PR is that these units must reflect the advance width of a character (the zero digit in the case of `ch`, and the CJK water radical for `ic`) as it would be rendered by the current font group. This means that the size of these units don't only depend on the first available font, in the case where that font does not contain a glyph for that character. This is implemented by adding the advance width for these two characters as optional fields of `FontMetrics`, so the advance width computation happens in advance. Then, when the font metrics are queried as part of unit resolution, the font group is searched for the first font containing that character. This change only implements support for these units in upright typesetting modes, since Servo does not yet have support for vertical writing modes. This means that many of the WPT tests that test for the behavior of these units with vertical writing modes do not pass. This change also makes a number of WPT tests pass, which relied on the `ch` and `ic` units. It, however, also makes the test `/css/css-text/white-space/text-wrap-balance-overflow-002.html` fail, since it tests `text-wrap: balance`, which Servo does not yet implement, and it was only previously passing by chance due to the previous behavior of these units.
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#46007) with upstreamable changes. |
🤖 This change no longer contains upstreamable changes to WPT; closed existing upstream pull request (web-platform-tests/wpt#46007). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, Andreu. You'll also need to run our version of rustfmt via ./mach fmt
and please squash you commits so that the upstream WPT PR is closed properly as well. Thank you. Once that's done I'll send this to the MQ.
Oh, I spoke to soon. Our scripts are clever enough to close this upstream PR without needing to squash. |
Looks like there is one more consistently passing test:
|
After #31966, which made it possible for the first time to resolve font-relative CSS units, this change adds support for the
ch
andic
units.One difference with the
ex
unit that was added in that PR is that these units must reflect the advance width of a character (the zero digit in the case ofch
, and the CJK water radical foric
) as it would be rendered by the current font group. This means that the size of these units don't only depend on the first available font, in the case where that font does not contain a glyph for that character.This is implemented by adding the advance width for these two characters as optional fields of
FontMetrics
, so the advance width computation happens in advance. Then, when the font metrics are queried as part of unit resolution, the font group is searched for the first font containing that character.This change only implements support for these units in upright typesetting modes, since Servo does not yet have support for vertical writing modes. This means that many of the WPT tests that test for the behavior of these units with vertical writing modes do not pass.
This change also makes a number of WPT tests pass, which relied on the
ch
andic
units. It, however, also makes the test/css/css-text/white-space/text-wrap-balance-overflow-002.html
fail, since it teststext-wrap: balance
, which Servo does not yet implement, and it was only previously passing by chance due to the previous behavior of these units../mach build -d
does not report any errors./mach test-tidy
does not report any errors