From d6231a18ef4ec9fc6517328dd2e4d8be3bb98140 Mon Sep 17 00:00:00 2001 From: Lars Bergstrom Date: Thu, 12 Sep 2013 10:50:37 -0700 Subject: [PATCH] Transitioned to about:failure instead of having the URL in Constellation. --- src/components/main/constellation.rs | 3 +- src/components/util/url.rs | 75 ++++++++++++++++------------ 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/components/main/constellation.rs b/src/components/main/constellation.rs index c38ec1d157d..00332b5f184 100644 --- a/src/components/main/constellation.rs +++ b/src/components/main/constellation.rs @@ -381,8 +381,7 @@ impl Constellation { let size = self.compositor_chan.get_size(); from_value(Size2D(size.width as uint, size.height as uint)) }); - // FIXME(lbergstrom): this should be in/relative-to the servo binary - let failure = ~"../src/test/html/failure.html"; + let failure = ~"about:failure"; let url = make_url(failure, None); pipeline.load(url); diff --git a/src/components/util/url.rs b/src/components/util/url.rs index bdfef004335..8ad5f343a7e 100644 --- a/src/components/util/url.rs +++ b/src/components/util/url.rs @@ -16,42 +16,55 @@ Create a URL object from a string. Does various helpful browsery things like is based off the current url */ +// TODO: about:failure-> pub fn make_url(str_url: ~str, current_url: Option) -> Url { let schm = url::get_scheme(str_url); - let str_url = if schm.is_err() { - if current_url.is_none() { - // Assume we've been given a file path. If it's absolute just return - // it, otherwise make it absolute with the cwd. - if str_url.starts_with("/") { - ~"file://" + str_url - } else { - ~"file://" + os::getcwd().push(str_url).to_str() - } - } else { - let current_url = current_url.unwrap(); - debug!("make_url: current_url: %?", current_url); - if str_url.starts_with("//") { - current_url.scheme + ":" + str_url - } else if current_url.path.is_empty() || - str_url.starts_with("/") { - current_url.scheme + "://" + - current_url.host + "/" + - str_url.trim_left_chars(&'/') - } else { - let mut path = ~[]; - for p in current_url.path.split_iter('/') { - path.push(p.to_str()); + let str_url = match schm { + Err(_) => { + if current_url.is_none() { + // Assume we've been given a file path. If it's absolute just return + // it, otherwise make it absolute with the cwd. + if str_url.starts_with("/") { + ~"file://" + str_url + } else { + ~"file://" + os::getcwd().push(str_url).to_str() } - let path = path.init(); - let mut path = path.iter().map(|x| (*x).clone()).collect::<~[~str]>(); - path.push(str_url); - let path = path.connect("/"); - - current_url.scheme + "://" + current_url.host + path + } else { + let current_url = current_url.unwrap(); + debug!("make_url: current_url: %?", current_url); + if str_url.starts_with("//") { + current_url.scheme + ":" + str_url + } else if current_url.path.is_empty() || + str_url.starts_with("/") { + current_url.scheme + "://" + + current_url.host + "/" + + str_url.trim_left_chars(&'/') + } else { + let mut path = ~[]; + for p in current_url.path.split_iter('/') { + path.push(p.to_str()); + } + let path = path.init(); + let mut path = path.iter().map(|x| (*x).clone()).collect::<~[~str]>(); + path.push(str_url); + let path = path.connect("/"); + + current_url.scheme + "://" + current_url.host + path + } + } + }, + Ok((scheme, page)) => { + match scheme { + ~"about" => { + match page { + ~"failure" => ~"file://" + os::getcwd().push("../src/test/html/failure.html").to_str(), + // TODO: handle the rest of the about: pages + _ => str_url + } + }, + _ => str_url } } - } else { - str_url }; // FIXME: Need to handle errors