-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fonts: Add WebFontDocumentContext for CSS Fonts 4 font fetching #40301
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
Conversation
|
🔨 Triggering try run (#18964463483) for Linux (WPT) |
TimvdLippe
left a comment
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.
Nice! I would expect some CSP tests to start passing as well.
|
|
mrobinson
left a comment
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.
Looks good from the perspective of someone who worked on the font loader. I'm not sure about the origin request parameter.
|
🔨 Triggering try run (#18981318512) for Linux (WPT) |
|
Test results for linux-wpt from try job (#18981318512): Flaky unexpected result (26)
Stable unexpected results that are known to be intermittent (16)
|
|
✨ Try run (#18981318512) succeeded. |
|
I am surprised this fixes zero tests. Shouldn't tests like https://wpt.fyi/results/content-security-policy/font-src/font-stylesheet-font-blocked.sub.html?product=servo or https://wpt.fyi/results/fetch/metadata/generated/css-font-face.sub.tentative.html?product=servo be affected? |
|
Aha, the culprit is: servo/components/fonts/font_context.rs Line 931 in 2a18c6b
|
|
|
|
If my try push in https://github.com/servo/servo/actions/runs/19019558687 goes well, I would like to split this work up into three PRs in sequence:
That will hopefully put us in a position where reporting CSP violations for web fonts doesn't break tests that expect a particular CSP failure but see a violation from our injected Ahem.ttf instead. |
|
Sounds like a good plan to me |
|
Another alternative here would be to ensure that every platform has Ahem loaded into its system font cache before running the tests. It seems like this could be done by injecting it manually on Servo startup. |
About this, I wonder why it is necessary? We are currently waiting for all web fonts to load before taking screenshots. Is there another case that I'm missing here? |
There's a window of time between finishing fetching an external style sheet and starting fetching any web fonts that it defines. Without our injected user style sheet present, we end up sometimes taking a screenshot during that window so the expected font is not applied. |
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
| })); | ||
| } | ||
|
|
||
| fn clone(&self) -> Box<dyn CspViolationHandler> { |
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.
Can't we derive Clone for this struct? It looks like the default implementation to me
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.
We can derive Clone, I don't think it really helps us at all since we still need to write this method.
| pub csp_handler: Box<dyn CspViolationHandler>, | ||
| } | ||
|
|
||
| impl Clone for WebFontDocumentContext { |
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.
Same here, can't we derive Clone?
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.
Nope—the presence of the trait object makes that impossible, and trying to use trait CspViolationHandler: Clone means it can't be used as a trait object.
Rebase of #37021 with review comments applied. These changes bundle up the required information from the relevant global when a stylesheet is added so that any requests for web fonts match the specification.
Testing: Newly passing tests.
Fixes: #36590