diff options
author | glennw <glennw@users.noreply.github.com> | 2014-08-06 09:12:41 +1000 |
---|---|---|
committer | glennw <glennw@users.noreply.github.com> | 2014-08-06 09:12:41 +1000 |
commit | 541f22ade61a6abe7304e07f99d9ba73e7a609b1 (patch) | |
tree | 3aeac28a617269cf9e527bf531fe2dee785703d0 /src/components/layout/layout_task.rs | |
parent | 037537f0794a716de7e0bbec0157814f3ce4edb5 (diff) | |
parent | a37b5cb326146ddb594853587410a9f9fcc4a307 (diff) | |
download | servo-541f22ade61a6abe7304e07f99d9ba73e7a609b1.tar.gz servo-541f22ade61a6abe7304e07f99d9ba73e7a609b1.zip |
Merge pull request #2791 from glennw/web-fonts
Add basic support for web fonts. Synchronous loading only
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. |