Files
tubestation/servo/components/script/dom/workerlocation.rs
Manish Goregaokar 052cbff92f servo: Merge #3518 - Purge Traceable and Untraceable from Servo (from Manishearth:trace-cleanup); r=jdm
Now that we use `JSTraceable` (defined in `script`), we can create arbitrary implementations on non-`script` types (eg `Url` or `RequestHeaderCollection`) where in the past we had to rely on `Traceable` and `Untraceable` to achieve cross-crate impls of `Encodable`.

This removes the two completely. They can be reintroduced if required, though the `untraceable!` macro should suffice.

Fixes #3469

Source-Repo: https://github.com/servo/servo
Source-Revision: b34df7c343579f200d2e67e21fc566842a4e4a91
2014-10-06 10:15:33 -06:00

58 lines
1.6 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::WorkerLocationBinding;
use dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods;
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::global::Worker;
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::urlhelper::UrlHelper;
use dom::workerglobalscope::WorkerGlobalScope;
use servo_util::str::DOMString;
use url::Url;
#[jstraceable]
#[must_root]
pub struct WorkerLocation {
reflector_: Reflector,
url: Url,
}
impl WorkerLocation {
fn new_inherited(url: Url) -> WorkerLocation {
WorkerLocation {
reflector_: Reflector::new(),
url: url,
}
}
pub fn new(global: JSRef<WorkerGlobalScope>, url: Url) -> Temporary<WorkerLocation> {
reflect_dom_object(box WorkerLocation::new_inherited(url),
&Worker(global),
WorkerLocationBinding::Wrap)
}
}
impl<'a> WorkerLocationMethods for JSRef<'a, WorkerLocation> {
fn Href(self) -> DOMString {
UrlHelper::Href(&self.url)
}
fn Search(self) -> DOMString {
UrlHelper::Search(&self.url)
}
fn Hash(self) -> DOMString {
UrlHelper::Hash(&self.url)
}
}
impl Reflectable for WorkerLocation {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
}