mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add Helper method for creating new WebFontDocumentContext
Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
This commit is contained in:
parent
e9e360edef
commit
8ac9dfcde6
4 changed files with 17 additions and 36 deletions
|
@ -4918,15 +4918,7 @@ impl Document {
|
|||
|
||||
if self.has_browsing_context() {
|
||||
// Construct WebFontDocumentContext for font fetching
|
||||
let document_context = WebFontDocumentContext {
|
||||
policy_container: self.window.global().policy_container(),
|
||||
document_url: self.window.global().api_base_url(),
|
||||
has_trustworthy_ancestor_origin: self
|
||||
.window
|
||||
.global()
|
||||
.has_trustworthy_ancestor_origin(),
|
||||
insecure_requests_policy: self.window.global().insecure_requests_policy(),
|
||||
};
|
||||
let document_context = self.window.new_document_context();
|
||||
|
||||
self.window.layout_mut().add_stylesheet(
|
||||
sheet.clone(),
|
||||
|
|
|
@ -7,10 +7,7 @@ use std::rc::Rc;
|
|||
|
||||
use cssparser::{Parser, ParserInput};
|
||||
use dom_struct::dom_struct;
|
||||
use fonts::{
|
||||
FontContext, FontContextWebFontMethods, FontTemplate, LowercaseFontFamilyName,
|
||||
WebFontDocumentContext,
|
||||
};
|
||||
use fonts::{FontContext, FontContextWebFontMethods, FontTemplate, LowercaseFontFamilyName};
|
||||
use js::rust::HandleObject;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::font_face::SourceList;
|
||||
|
@ -544,12 +541,7 @@ impl FontFaceMethods<crate::DomTypeHolder> for FontFace {
|
|||
.expect("Parsing shouldn't fail as descriptors are valid by construction");
|
||||
|
||||
// Construct a WebFontDocumentContext object for the current document.
|
||||
let document_context = WebFontDocumentContext {
|
||||
policy_container: global.policy_container(),
|
||||
document_url: global.api_base_url(),
|
||||
has_trustworthy_ancestor_origin: global.has_trustworthy_ancestor_origin(),
|
||||
insecure_requests_policy: global.insecure_requests_policy(),
|
||||
};
|
||||
let document_context = global.as_window().new_document_context();
|
||||
|
||||
// Step 4. Using the value of font face’s [[Urls]] slot, attempt to load a font as defined
|
||||
// in [CSS-FONTS-3], as if it was the value of a @font-face rule’s src descriptor.
|
||||
|
|
|
@ -769,6 +769,15 @@ impl Window {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
pub fn new_document_context(&self) -> WebFontDocumentContext {
|
||||
WebFontDocumentContext {
|
||||
policy_container: self.global().policy_container(),
|
||||
document_url: self.global().api_base_url(),
|
||||
has_trustworthy_ancestor_origin: self.global().has_trustworthy_ancestor_origin(),
|
||||
insecure_requests_policy: self.global().insecure_requests_policy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#atob
|
||||
|
@ -2171,12 +2180,8 @@ impl Window {
|
|||
let highlighted_dom_node = document.highlighted_dom_node().map(|node| node.to_opaque());
|
||||
|
||||
//Construct a new document context for the reflow.
|
||||
let document_context = WebFontDocumentContext {
|
||||
policy_container: self.global().policy_container(),
|
||||
document_url: self.global().api_base_url(),
|
||||
has_trustworthy_ancestor_origin: self.global().has_trustworthy_ancestor_origin(),
|
||||
insecure_requests_policy: self.global().insecure_requests_policy(),
|
||||
};
|
||||
let document_context = self.new_document_context();
|
||||
|
||||
// Send new document and relevant styles to layout.
|
||||
let reflow = ReflowRequest {
|
||||
reflow_info: Reflow {
|
||||
|
|
|
@ -8,7 +8,6 @@ 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::{
|
||||
|
@ -234,14 +233,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
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(),
|
||||
};
|
||||
let document_context = win.new_document_context();
|
||||
|
||||
// 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue