mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Fix parsing invalid url, clean up font template matching.
This commit is contained in:
parent
a500099df6
commit
a37b5cb326
2 changed files with 22 additions and 25 deletions
|
@ -97,8 +97,7 @@ impl FontTemplate {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
match self.is_valid {
|
if self.is_valid {
|
||||||
true => {
|
|
||||||
let data = self.get_data();
|
let data = self.get_data();
|
||||||
let handle: Result<FontHandle, ()> = FontHandleMethods::new_from_template(fctx, data.clone(), None);
|
let handle: Result<FontHandle, ()> = FontHandleMethods::new_from_template(fctx, data.clone(), None);
|
||||||
match handle {
|
match handle {
|
||||||
|
@ -121,14 +120,12 @@ impl FontTemplate {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
false => {
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the data for creating a font.
|
/// Get the data for creating a font.
|
||||||
pub fn get(&mut self) -> Option<Arc<FontTemplateData>> {
|
pub fn get(&mut self) -> Option<Arc<FontTemplateData>> {
|
||||||
|
|
|
@ -79,8 +79,8 @@ pub fn parse_font_face_rule(rule: AtRule, parent_rules: &mut Vec<CSSRule>, base_
|
||||||
// url() or local() should be next
|
// url() or local() should be next
|
||||||
let maybe_url = match iter.next() {
|
let maybe_url = match iter.next() {
|
||||||
Some(&URL(ref string_value)) => {
|
Some(&URL(ref string_value)) => {
|
||||||
// FIXME: handle URL parse errors more gracefully.
|
let maybe_url = UrlParser::new().base_url(base_url).parse(string_value.as_slice());
|
||||||
let url = UrlParser::new().base_url(base_url).parse(string_value.as_slice()).unwrap();
|
let url = maybe_url.unwrap_or_else(|_| Url::parse("about:invalid").unwrap());
|
||||||
Some(url)
|
Some(url)
|
||||||
},
|
},
|
||||||
Some(&Function(ref string_value, ref _values)) => {
|
Some(&Function(ref string_value, ref _values)) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue