mirror of
https://github.com/servo/servo.git
synced 2025-07-31 19:20:22 +01:00
Do not root Location::window
This commit is contained in:
parent
dee3aecea1
commit
5889a75b10
1 changed files with 8 additions and 11 deletions
|
@ -35,33 +35,31 @@ impl Location {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_url(&self) -> Url {
|
fn get_url(&self) -> Url {
|
||||||
self.window.root().get_url()
|
self.window.get_url()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_url_component(&self, value: USVString,
|
fn set_url_component(&self, value: USVString,
|
||||||
setter: fn(&mut Url, USVString)) {
|
setter: fn(&mut Url, USVString)) {
|
||||||
let window = self.window.root();
|
let mut url = self.window.get_url();
|
||||||
let mut url = window.get_url();
|
|
||||||
setter(&mut url, value);
|
setter(&mut url, value);
|
||||||
window.load_url(url);
|
self.window.load_url(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LocationMethods for Location {
|
impl LocationMethods for Location {
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
// https://html.spec.whatwg.org/multipage/#dom-location-assign
|
||||||
fn Assign(&self, url: DOMString) {
|
fn Assign(&self, url: DOMString) {
|
||||||
let window = self.window.root();
|
|
||||||
// TODO: per spec, we should use the _API base URL_ specified by the
|
// TODO: per spec, we should use the _API base URL_ specified by the
|
||||||
// _entry settings object_.
|
// _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) {
|
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
|
// https://html.spec.whatwg.org/multipage/#dom-location-reload
|
||||||
fn Reload(&self) {
|
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
|
// https://url.spec.whatwg.org/#dom-urlutils-hash
|
||||||
|
@ -101,9 +99,8 @@ impl LocationMethods for Location {
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#dom-urlutils-href
|
// https://url.spec.whatwg.org/#dom-urlutils-href
|
||||||
fn SetHref(&self, value: USVString) -> ErrorResult {
|
fn SetHref(&self, value: USVString) -> ErrorResult {
|
||||||
let window = self.window.root();
|
if let Ok(url) = UrlParser::new().base_url(&self.window.get_url()).parse(&value.0) {
|
||||||
if let Ok(url) = UrlParser::new().base_url(&window.get_url()).parse(&value.0) {
|
self.window.load_url(url);
|
||||||
window.load_url(url);
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue