mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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::parser::PseudoElement;
|
||||
use selectors::tree::TNode;
|
||||
use std::process;
|
||||
use util::resource_files::read_resource_file;
|
||||
use util::smallvec::VecLike;
|
||||
|
||||
|
@ -59,13 +60,21 @@ impl Stylist {
|
|||
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
||||
// (Does it make a difference?)
|
||||
for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() {
|
||||
let ua_stylesheet = Stylesheet::from_bytes(
|
||||
&read_resource_file(&[filename]).unwrap(),
|
||||
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
|
||||
None,
|
||||
None,
|
||||
Origin::UserAgent);
|
||||
stylist.add_stylesheet(ua_stylesheet);
|
||||
match read_resource_file(&[filename]) {
|
||||
Ok(res) => {
|
||||
let ua_stylesheet = Stylesheet::from_bytes(
|
||||
&res,
|
||||
Url::parse(&format!("chrome:///{:?}", filename)).unwrap(),
|
||||
None,
|
||||
None,
|
||||
Origin::UserAgent);
|
||||
stylist.add_stylesheet(ua_stylesheet);
|
||||
}
|
||||
Err(..) => {
|
||||
error!("Stylist::new() failed at loading {}!", filename);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
stylist
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue