diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index bbb2d0201f6..9545ad1cf14 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -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 } @@ -154,12 +163,20 @@ impl Stylist { } pub fn add_quirks_mode_stylesheet(&mut self) { - self.add_stylesheet(Stylesheet::from_bytes( - &read_resource_file(&["quirks-mode.css"]).unwrap(), - Url::parse("chrome:///quirks-mode.css").unwrap(), - None, - None, - Origin::UserAgent)) + match read_resource_file(&["quirks-mode.css"]) { + Ok(res) => { + self.add_stylesheet(Stylesheet::from_bytes( + &res, + Url::parse("chrome:///quirks-mode.css").unwrap(), + None, + None, + Origin::UserAgent)); + } + Err(..) => { + error!("Stylist::add_quirks_mode_stylesheet() failed at loading 'quirks-mode.css'!"); + process::exit(1); + } + } } pub fn add_stylesheet(&mut self, stylesheet: Stylesheet) { diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs index 7c61a48f0ba..f9e89df4af1 100644 --- a/components/util/resource_files.rs +++ b/components/util/resource_files.rs @@ -25,14 +25,23 @@ pub fn resources_dir_path() -> PathBuf { // or `/components/servo/target/release`. let mut path = env::current_exe().ok().expect("can't get exe path"); path.pop(); - path.pop(); - path.pop(); - path.pop(); path.push("resources"); - if !path.is_dir() { // self_exe_path() is probably in .../target/release + if !path.is_dir() { // resources dir not in same dir as exe? + path.pop(); + path.pop(); path.pop(); path.pop(); path.push("resources"); + if !path.is_dir() { // self_exe_path() is probably in .../target/release + path.pop(); + path.pop(); + path.push("resources"); + if !path.is_dir() { // self_exe_path() is probably in .../target/release + path.pop(); + path.pop(); + path.push("resources"); + } + } } path } diff --git a/ports/cef/core.rs b/ports/cef/core.rs index 02f884e3c71..c3b16cf9a50 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -27,15 +27,6 @@ static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650 #[cfg(target_os="linux")] static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0"; -#[cfg(target_os="linux")] -fn resources_path() -> Option { - Some("../../servo/resources".to_owned()) -} - -#[cfg(not(target_os="linux"))] -fn resources_path() -> Option { - None -} #[no_mangle] pub extern "C" fn cef_initialize(args: *const cef_main_args_t, @@ -77,7 +68,7 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t, temp_opts.headless = false; temp_opts.hard_fail = false; temp_opts.enable_text_antialiasing = true; - temp_opts.resources_path = resources_path(); + temp_opts.resources_path = None; opts::set(temp_opts); return 1