mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
fix Stylist::new() to not panic when resources cannot be loaded
This commit is contained in:
parent
f4381a6f1e
commit
1cf5dd212c
1 changed files with 16 additions and 7 deletions
|
@ -9,6 +9,7 @@ use selectors::matching::{SelectorMap, Rule};
|
||||||
use selectors::matching::DeclarationBlock as GenericDeclarationBlock;
|
use selectors::matching::DeclarationBlock as GenericDeclarationBlock;
|
||||||
use selectors::parser::PseudoElement;
|
use selectors::parser::PseudoElement;
|
||||||
use selectors::tree::TNode;
|
use selectors::tree::TNode;
|
||||||
|
use std::process;
|
||||||
use util::resource_files::read_resource_file;
|
use util::resource_files::read_resource_file;
|
||||||
use util::smallvec::VecLike;
|
use util::smallvec::VecLike;
|
||||||
|
|
||||||
|
@ -59,13 +60,21 @@ impl Stylist {
|
||||||
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
||||||
// (Does it make a difference?)
|
// (Does it make a difference?)
|
||||||
for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() {
|
for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() {
|
||||||
let ua_stylesheet = Stylesheet::from_bytes(
|
match read_resource_file(&[filename]) {
|
||||||
&read_resource_file(&[filename]).unwrap(),
|
Ok(res) => {
|
||||||
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
|
let ua_stylesheet = Stylesheet::from_bytes(
|
||||||
None,
|
&res,
|
||||||
None,
|
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
|
||||||
Origin::UserAgent);
|
None,
|
||||||
stylist.add_stylesheet(ua_stylesheet);
|
None,
|
||||||
|
Origin::UserAgent);
|
||||||
|
stylist.add_stylesheet(ua_stylesheet);
|
||||||
|
}
|
||||||
|
Err(..) => {
|
||||||
|
error!("Stylist::new() failed at loading {}!", filename);
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stylist
|
stylist
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue