Transitioned to about:failure instead of having the URL in

Constellation.
This commit is contained in:
Lars Bergstrom 2013-09-12 10:50:37 -07:00
parent 26ec02226e
commit d6231a18ef
2 changed files with 45 additions and 33 deletions

View file

@ -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);

View file

@ -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>) -> 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