aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/location.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2015-02-19 13:08:50 -0500
committerJosh Matthews <josh@joshmatthews.net>2015-03-03 16:25:40 -0500
commite2c4f5ed6726ed7434197180b301f74a967d3ffc (patch)
tree543d4b085a38fdbc134c945d78fff2b2dec619b4 /components/script/dom/location.rs
parentd9f04180a5d9146f4486ede6fabb9da638cccd41 (diff)
downloadservo-e2c4f5ed6726ed7434197180b301f74a967d3ffc.tar.gz
servo-e2c4f5ed6726ed7434197180b301f74a967d3ffc.zip
Move everything unrelated to the frame tree out of Page and into Document or Window. Reduce the API surface of Page to a bare minimum to allow for easier future removal.
Diffstat (limited to 'components/script/dom/location.rs')
-rw-r--r--components/script/dom/location.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs
index 614b623e5b9..13cc1a05c65 100644
--- a/components/script/dom/location.rs
+++ b/components/script/dom/location.rs
@@ -5,33 +5,31 @@
use dom::bindings::codegen::Bindings::LocationBinding;
use dom::bindings::codegen::Bindings::LocationBinding::LocationMethods;
use dom::bindings::global::GlobalRef;
-use dom::bindings::js::{JSRef, Temporary};
+use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::urlhelper::UrlHelper;
use dom::window::Window;
use dom::window::WindowHelpers;
-use page::Page;
use util::str::DOMString;
-
-use std::rc::Rc;
+use url::Url;
#[dom_struct]
pub struct Location {
reflector_: Reflector,
- page: Rc<Page>,
+ window: JS<Window>,
}
impl Location {
- fn new_inherited(page: Rc<Page>) -> Location {
+ fn new_inherited(window: JSRef<Window>) -> Location {
Location {
reflector_: Reflector::new(),
- page: page
+ window: JS::from_rooted(window)
}
}
- pub fn new(window: JSRef<Window>, page: Rc<Page>) -> Temporary<Location> {
- reflect_dom_object(box Location::new_inherited(page),
+ pub fn new(window: JSRef<Window>) -> Temporary<Location> {
+ reflect_dom_object(box Location::new_inherited(window),
GlobalRef::Window(window),
LocationBinding::Wrap)
}
@@ -40,11 +38,11 @@ impl Location {
impl<'a> LocationMethods for JSRef<'a, Location> {
// https://html.spec.whatwg.org/multipage/browsers.html#dom-location-assign
fn Assign(self, url: DOMString) {
- self.page.frame().as_ref().unwrap().window.root().r().load_url(url);
+ self.window.root().r().load_url(url);
}
fn Href(self) -> DOMString {
- UrlHelper::Href(&self.page.get_url())
+ UrlHelper::Href(&self.get_url())
}
fn Stringify(self) -> DOMString {
@@ -52,11 +50,21 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
}
fn Search(self) -> DOMString {
- UrlHelper::Search(&self.page.get_url())
+ UrlHelper::Search(&self.get_url())
}
fn Hash(self) -> DOMString {
- UrlHelper::Hash(&self.page.get_url())
+ UrlHelper::Hash(&self.get_url())
}
}
+trait PrivateLocationHelpers {
+ fn get_url(self) -> Url;
+}
+
+impl<'a> PrivateLocationHelpers for JSRef<'a, Location> {
+ fn get_url(self) -> Url {
+ let window = self.window.root();
+ window.r().get_url()
+ }
+}