mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #5992 - zmike:random-fixups, r=larsbergstrom
Attempt to not panic as much if the resources/ dir is not where it's expected to be. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5992) <!-- Reviewable:end -->
This commit is contained in:
commit
76225bdccb
3 changed files with 44 additions and 27 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
|
||||||
}
|
}
|
||||||
|
@ -154,12 +163,20 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_quirks_mode_stylesheet(&mut self) {
|
pub fn add_quirks_mode_stylesheet(&mut self) {
|
||||||
self.add_stylesheet(Stylesheet::from_bytes(
|
match read_resource_file(&["quirks-mode.css"]) {
|
||||||
&read_resource_file(&["quirks-mode.css"]).unwrap(),
|
Ok(res) => {
|
||||||
Url::parse("chrome:///quirks-mode.css").unwrap(),
|
self.add_stylesheet(Stylesheet::from_bytes(
|
||||||
None,
|
&res,
|
||||||
None,
|
Url::parse("chrome:///quirks-mode.css").unwrap(),
|
||||||
Origin::UserAgent))
|
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) {
|
pub fn add_stylesheet(&mut self, stylesheet: Stylesheet) {
|
||||||
|
|
|
@ -25,14 +25,23 @@ pub fn resources_dir_path() -> PathBuf {
|
||||||
// or `<servo source>/components/servo/target/release`.
|
// or `<servo source>/components/servo/target/release`.
|
||||||
let mut path = env::current_exe().ok().expect("can't get exe path");
|
let mut path = env::current_exe().ok().expect("can't get exe path");
|
||||||
path.pop();
|
path.pop();
|
||||||
path.pop();
|
|
||||||
path.pop();
|
|
||||||
path.pop();
|
|
||||||
path.push("resources");
|
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.pop();
|
path.pop();
|
||||||
path.push("resources");
|
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
|
path
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,15 +27,6 @@ static CEF_API_HASH_PLATFORM: &'static [u8] = b"6813214accbf2ebfb6bdcf8d00654650
|
||||||
#[cfg(target_os="linux")]
|
#[cfg(target_os="linux")]
|
||||||
static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0";
|
static CEF_API_HASH_PLATFORM: &'static [u8] = b"2bc564c3871965ef3a2531b528bda3e17fa17a6d\0";
|
||||||
|
|
||||||
#[cfg(target_os="linux")]
|
|
||||||
fn resources_path() -> Option<String> {
|
|
||||||
Some("../../servo/resources".to_owned())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(target_os="linux"))]
|
|
||||||
fn resources_path() -> Option<String> {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
|
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.headless = false;
|
||||||
temp_opts.hard_fail = false;
|
temp_opts.hard_fail = false;
|
||||||
temp_opts.enable_text_antialiasing = true;
|
temp_opts.enable_text_antialiasing = true;
|
||||||
temp_opts.resources_path = resources_path();
|
temp_opts.resources_path = None;
|
||||||
opts::set(temp_opts);
|
opts::set(temp_opts);
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue