mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Transitioned to about:failure instead of having the URL in
Constellation.
This commit is contained in:
parent
26ec02226e
commit
d6231a18ef
2 changed files with 45 additions and 33 deletions
|
@ -381,8 +381,7 @@ impl Constellation {
|
||||||
let size = self.compositor_chan.get_size();
|
let size = self.compositor_chan.get_size();
|
||||||
from_value(Size2D(size.width as uint, size.height as uint))
|
from_value(Size2D(size.width as uint, size.height as uint))
|
||||||
});
|
});
|
||||||
// FIXME(lbergstrom): this should be in/relative-to the servo binary
|
let failure = ~"about:failure";
|
||||||
let failure = ~"../src/test/html/failure.html";
|
|
||||||
let url = make_url(failure, None);
|
let url = make_url(failure, None);
|
||||||
pipeline.load(url);
|
pipeline.load(url);
|
||||||
|
|
||||||
|
|
|
@ -16,42 +16,55 @@ Create a URL object from a string. Does various helpful browsery things like
|
||||||
is based off the current url
|
is based off the current url
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
// TODO: about:failure->
|
||||||
pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
pub fn make_url(str_url: ~str, current_url: Option<Url>) -> Url {
|
||||||
let schm = url::get_scheme(str_url);
|
let schm = url::get_scheme(str_url);
|
||||||
let str_url = if schm.is_err() {
|
let str_url = match schm {
|
||||||
if current_url.is_none() {
|
Err(_) => {
|
||||||
// Assume we've been given a file path. If it's absolute just return
|
if current_url.is_none() {
|
||||||
// it, otherwise make it absolute with the cwd.
|
// Assume we've been given a file path. If it's absolute just return
|
||||||
if str_url.starts_with("/") {
|
// it, otherwise make it absolute with the cwd.
|
||||||
~"file://" + str_url
|
if str_url.starts_with("/") {
|
||||||
} else {
|
~"file://" + str_url
|
||||||
~"file://" + os::getcwd().push(str_url).to_str()
|
} 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 path = path.init();
|
} else {
|
||||||
let mut path = path.iter().map(|x| (*x).clone()).collect::<~[~str]>();
|
let current_url = current_url.unwrap();
|
||||||
path.push(str_url);
|
debug!("make_url: current_url: %?", current_url);
|
||||||
let path = path.connect("/");
|
if str_url.starts_with("//") {
|
||||||
|
current_url.scheme + ":" + str_url
|
||||||
current_url.scheme + "://" + current_url.host + path
|
} 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
|
// FIXME: Need to handle errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue