diff options
Diffstat (limited to 'src/components/script/dom/location.rs')
-rw-r--r-- | src/components/script/dom/location.rs | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/src/components/script/dom/location.rs b/src/components/script/dom/location.rs index 0933d324c8b..93485f0b264 100644 --- a/src/components/script/dom/location.rs +++ b/src/components/script/dom/location.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::BindingDeclarations::LocationBinding; -use dom::bindings::js::JS; +use dom::bindings::js::{JSRef, Temporary}; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::error::Fallible; use dom::window::Window; @@ -29,105 +29,134 @@ impl Location { } } - pub fn new(window: &JS<Window>, page: Rc<Page>) -> JS<Location> { + pub fn new(window: &JSRef<Window>, page: Rc<Page>) -> Temporary<Location> { reflect_dom_object(~Location::new_inherited(page), window, LocationBinding::Wrap) } +} + +pub trait LocationMethods { + fn Assign(&self, _url: DOMString); + fn Replace(&self, _url: DOMString); + fn Reload(&self); + fn Href(&self) -> DOMString; + fn SetHref(&self, _href: DOMString) -> Fallible<()>; + fn Origin(&self) -> DOMString; + fn Protocol(&self) -> DOMString; + fn SetProtocol(&self, _protocol: DOMString); + fn Username(&self) -> DOMString; + fn SetUsername(&self, _username: DOMString); + fn Password(&self) -> DOMString; + fn SetPassword(&self, _password: DOMString); + fn Host(&self) -> DOMString; + fn SetHost(&self, _host: DOMString); + fn Hostname(&self) -> DOMString; + fn SetHostname(&self, _hostname: DOMString); + fn Port(&self) -> DOMString; + fn SetPort(&self, _port: DOMString); + fn Pathname(&self) -> DOMString; + fn SetPathname(&self, _pathname: DOMString); + fn Search(&self) -> DOMString; + fn SetSearch(&self, _search: DOMString); + fn Hash(&self) -> DOMString; + fn SetHash(&self, _hash: DOMString); +} - pub fn Assign(&self, _url: DOMString) { +impl<'a> LocationMethods for JSRef<'a, Location> { + fn Assign(&self, _url: DOMString) { } - pub fn Replace(&self, _url: DOMString) { + fn Replace(&self, _url: DOMString) { } - pub fn Reload(&self) { + fn Reload(&self) { } - pub fn Href(&self) -> DOMString { + fn Href(&self) -> DOMString { self.page.get_url().to_str() } - pub fn SetHref(&self, _href: DOMString) -> Fallible<()> { + fn SetHref(&self, _href: DOMString) -> Fallible<()> { Ok(()) } - pub fn Origin(&self) -> DOMString { + fn Origin(&self) -> DOMString { ~"" } - pub fn Protocol(&self) -> DOMString { + fn Protocol(&self) -> DOMString { ~"" } - pub fn SetProtocol(&self, _protocol: DOMString) { + fn SetProtocol(&self, _protocol: DOMString) { } - pub fn Username(&self) -> DOMString { + fn Username(&self) -> DOMString { ~"" } - pub fn SetUsername(&self, _username: DOMString) { + fn SetUsername(&self, _username: DOMString) { } - pub fn Password(&self) -> DOMString { + fn Password(&self) -> DOMString { ~"" } - pub fn SetPassword(&self, _password: DOMString) { + fn SetPassword(&self, _password: DOMString) { } - pub fn Host(&self) -> DOMString { + fn Host(&self) -> DOMString { ~"" } - pub fn SetHost(&self, _host: DOMString) { + fn SetHost(&self, _host: DOMString) { } - pub fn Hostname(&self) -> DOMString { + fn Hostname(&self) -> DOMString { ~"" } - pub fn SetHostname(&self, _hostname: DOMString) { + fn SetHostname(&self, _hostname: DOMString) { } - pub fn Port(&self) -> DOMString { + fn Port(&self) -> DOMString { ~"" } - pub fn SetPort(&self, _port: DOMString) { + fn SetPort(&self, _port: DOMString) { } - pub fn Pathname(&self) -> DOMString { + fn Pathname(&self) -> DOMString { ~"" } - pub fn SetPathname(&self, _pathname: DOMString) { + fn SetPathname(&self, _pathname: DOMString) { } - pub fn Search(&self) -> DOMString { + fn Search(&self) -> DOMString { ~"" } - pub fn SetSearch(&self, _search: DOMString) { + fn SetSearch(&self, _search: DOMString) { } - pub fn Hash(&self) -> DOMString { + fn Hash(&self) -> DOMString { ~"" } - pub fn SetHash(&self, _hash: DOMString) { + fn SetHash(&self, _hash: DOMString) { } } |