diff options
Diffstat (limited to 'src/components/layout/layout_task.rs')
-rw-r--r-- | src/components/layout/layout_task.rs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/components/layout/layout_task.rs b/src/components/layout/layout_task.rs index 3d9cca46737..c40ed74f342 100644 --- a/src/components/layout/layout_task.rs +++ b/src/components/layout/layout_task.rs @@ -59,6 +59,7 @@ use std::comm::{channel, Sender, Receiver}; use std::mem; use std::ptr; use style::{AuthorOrigin, Stylesheet, Stylist}; +use style::CSSFontFaceRule; use sync::{Arc, Mutex}; use url::Url; @@ -447,7 +448,25 @@ impl LayoutTask { } fn handle_add_stylesheet(&mut self, sheet: Stylesheet) { - self.stylist.add_stylesheet(sheet, AuthorOrigin) + // Find all font-face rules and notify the font cache of them. + // GWTODO: Need to handle unloading web fonts (when we handle unloading stylesheets!) + // GWTODO: Need to handle font-face nested within media rules. + for rule in sheet.rules.iter() { + match rule { + &CSSFontFaceRule(ref font_face_rule) => { + let mut font_urls = vec!(); + for source_line in font_face_rule.source_lines.iter() { + for source in source_line.sources.iter() { + font_urls.push(source.url.clone()); + } + } + self.font_cache_task.add_web_font(font_urls, font_face_rule.family.as_slice()); + }, + _ => {} + } + } + + self.stylist.add_stylesheet(sheet, AuthorOrigin); } /// Retrieves the flow tree root from the root node. |