mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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,34 +97,31 @@ 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 {
|
Ok(handle) => {
|
||||||
Ok(handle) => {
|
let actual_desc = FontTemplateDescriptor::new(handle.boldness(),
|
||||||
let actual_desc = FontTemplateDescriptor::new(handle.boldness(),
|
handle.is_italic());
|
||||||
handle.is_italic());
|
let desc_match = actual_desc == *requested_desc;
|
||||||
let desc_match = actual_desc == *requested_desc;
|
|
||||||
|
|
||||||
self.descriptor = Some(actual_desc);
|
self.descriptor = Some(actual_desc);
|
||||||
self.is_valid = true;
|
self.is_valid = true;
|
||||||
if desc_match {
|
if desc_match {
|
||||||
Some(data)
|
Some(data)
|
||||||
} else {
|
} else {
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(()) => {
|
|
||||||
self.is_valid = false;
|
|
||||||
debug!("Unable to create a font from template {}", self.identifier);
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
Err(()) => {
|
||||||
false => {
|
self.is_valid = false;
|
||||||
None
|
debug!("Unable to create a font from template {}", self.identifier);
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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