Add WebFontDocumentContext for CSS Fonts 4 font fetching

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
Uthman Yahaya Baba 2025-05-16 04:09:55 +01:00
parent 3af0992ead
commit e9e360edef
8 changed files with 122 additions and 20 deletions

View file

@ -8,6 +8,7 @@ use std::sync::atomic::AtomicBool;
use content_security_policy as csp;
use cssparser::SourceLocation;
use encoding_rs::UTF_8;
use fonts::WebFontDocumentContext;
use mime::{self, Mime};
use net_traits::request::{CorsSettings, Destination, RequestId};
use net_traits::{
@ -232,10 +233,19 @@ impl FetchResponseListener for StylesheetContext {
Some(&loader),
win.css_error_reporter(),
);
//Construct a new WebFontDocumentContext for the stylesheet
let document_context = WebFontDocumentContext {
policy_container: win.global().policy_container(),
document_url: win.global().api_base_url(),
has_trustworthy_ancestor_origin: win
.global()
.has_trustworthy_ancestor_origin(),
insecure_requests_policy: win.global().insecure_requests_policy(),
};
// Layout knows about this stylesheet, because Stylo added it to the Stylist,
// but Layout doesn't know about any new web fonts that it contains.
document.load_web_fonts_from_stylesheet(stylesheet.clone());
document.load_web_fonts_from_stylesheet(stylesheet.clone(), &document_context);
},
}