Fix parsing invalid url, clean up font template matching.

This commit is contained in:
Glenn Watson 2014-07-28 11:41:16 +10:00
parent a500099df6
commit a37b5cb326
2 changed files with 22 additions and 25 deletions

View file

@ -97,8 +97,7 @@ impl FontTemplate {
}
},
None => {
match self.is_valid {
true => {
if self.is_valid {
let data = self.get_data();
let handle: Result<FontHandle, ()> = FontHandleMethods::new_from_template(fctx, data.clone(), None);
match handle {
@ -121,14 +120,12 @@ impl FontTemplate {
None
}
}
},
false => {
} else {
None
}
}
}
}
}
/// Get the data for creating a font.
pub fn get(&mut self) -> Option<Arc<FontTemplateData>> {

View file

@ -79,8 +79,8 @@ pub fn parse_font_face_rule(rule: AtRule, parent_rules: &mut Vec<CSSRule>, base_
// url() or local() should be next
let maybe_url = match iter.next() {
Some(&URL(ref string_value)) => {
// FIXME: handle URL parse errors more gracefully.
let url = UrlParser::new().base_url(base_url).parse(string_value.as_slice()).unwrap();
let maybe_url = UrlParser::new().base_url(base_url).parse(string_value.as_slice());
let url = maybe_url.unwrap_or_else(|_| Url::parse("about:invalid").unwrap());
Some(url)
},
Some(&Function(ref string_value, ref _values)) => {