Do not root Location::window

This commit is contained in:
Anthony Ramine 2015-10-17 15:16:19 +02:00
parent dee3aecea1
commit 5889a75b10

View file

@ -35,33 +35,31 @@ impl Location {
}
fn get_url(&self) -> Url {
self.window.root().get_url()
self.window.get_url()
}
fn set_url_component(&self, value: USVString,
setter: fn(&mut Url, USVString)) {
let window = self.window.root();
let mut url = window.get_url();
let mut url = self.window.get_url();
setter(&mut url, value);
window.load_url(url);
self.window.load_url(url);
}
}
impl LocationMethods for Location {
// https://html.spec.whatwg.org/multipage/#dom-location-assign
fn Assign(&self, url: DOMString) {
let window = self.window.root();
// TODO: per spec, we should use the _API base URL_ specified by the
// _entry settings object_.
let base_url = window.get_url();
let base_url = self.window.get_url();
if let Ok(url) = UrlParser::new().base_url(&base_url).parse(&url) {
window.load_url(url);
self.window.load_url(url);
}
}
// https://html.spec.whatwg.org/multipage/#dom-location-reload
fn Reload(&self) {
self.window.root().load_url(self.get_url());
self.window.load_url(self.get_url());
}
// https://url.spec.whatwg.org/#dom-urlutils-hash
@ -101,9 +99,8 @@ impl LocationMethods for Location {
// https://url.spec.whatwg.org/#dom-urlutils-href
fn SetHref(&self, value: USVString) -> ErrorResult {
let window = self.window.root();
if let Ok(url) = UrlParser::new().base_url(&window.get_url()).parse(&value.0) {
window.load_url(url);
if let Ok(url) = UrlParser::new().base_url(&self.window.get_url()).parse(&value.0) {
self.window.load_url(url);
};
Ok(())
}