aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_thread/lib.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-03 03:53:09 -0500
committerGitHub <noreply@github.com>2017-04-03 03:53:09 -0500
commitfac0d17fd6edf996876d6e6379e48ef4f9cb43d6 (patch)
treecbef60e6e781739ea27f2355105f6859e7da9f28 /components/layout_thread/lib.rs
parent5b037a0aa080799faae93efe59e56938a1eba913 (diff)
parent131b12dc670659ee72052e16b06f5426bdc8758c (diff)
downloadservo-fac0d17fd6edf996876d6e6379e48ef4f9cb43d6.tar.gz
servo-fac0d17fd6edf996876d6e6379e48ef4f9cb43d6.zip
Auto merge of #16224 - servo:valid-fontface, r=upsuper
Make the parser accept @font-face rules without font-family or src. Fix #16165. Also, it turns out that the CSSFontFaceRule IDL specified in the css-fonts spec is not web-compatible. Instead browsers implement a .style attribute like in CSSStyleRule: https://github.com/w3c/csswg-drafts/issues/825 This in turn requires preserving data about which descriptors were set or not (distinguishing unset from set to a value that happens to be the initial value), so this commit also makes every field `Option<_>`. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16224) <!-- Reviewable:end -->
Diffstat (limited to 'components/layout_thread/lib.rs')
-rw-r--r--components/layout_thread/lib.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 74c95499006..abc0a5e771a 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -355,20 +355,24 @@ fn add_font_face_rules(stylesheet: &Stylesheet,
outstanding_web_fonts_counter: &Arc<AtomicUsize>) {
if opts::get().load_webfonts_synchronously {
let (sender, receiver) = ipc::channel().unwrap();
- stylesheet.effective_font_face_rules(&device, guard, |font_face| {
- let effective_sources = font_face.effective_sources();
- font_cache_thread.add_web_font(font_face.family.clone(),
- effective_sources,
- sender.clone());
- receiver.recv().unwrap();
+ stylesheet.effective_font_face_rules(&device, guard, |rule| {
+ if let Some(font_face) = rule.font_face() {
+ let effective_sources = font_face.effective_sources();
+ font_cache_thread.add_web_font(font_face.family().clone(),
+ effective_sources,
+ sender.clone());
+ receiver.recv().unwrap();
+ }
})
} else {
- stylesheet.effective_font_face_rules(&device, guard, |font_face| {
- let effective_sources = font_face.effective_sources();
- outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
- font_cache_thread.add_web_font(font_face.family.clone(),
- effective_sources,
- (*font_cache_sender).clone());
+ stylesheet.effective_font_face_rules(&device, guard, |rule| {
+ if let Some(font_face) = rule.font_face() {
+ let effective_sources = font_face.effective_sources();
+ outstanding_web_fonts_counter.fetch_add(1, Ordering::SeqCst);
+ font_cache_thread.add_web_font(font_face.family().clone(),
+ effective_sources,
+ (*font_cache_sender).clone());
+ }
})
}
}