use dom_struct::dom_struct;
use servo_url::{ImmutableOrigin, ServoUrl};
use crate::dom::bindings::codegen::Bindings::WorkerLocationBinding::WorkerLocationMethods;
use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::USVString;
use crate::dom::urlhelper::UrlHelper;
use crate::dom::workerglobalscope::WorkerGlobalScope;
use crate::script_runtime::CanGc;
#[dom_struct]
pub struct WorkerLocation {
reflector_: Reflector,
#[no_trace]
url: ServoUrl,
}
impl WorkerLocation {
fn new_inherited(url: ServoUrl) -> WorkerLocation {
WorkerLocation {
reflector_: Reflector::new(),
url,
}
}
pub fn new(global: &WorkerGlobalScope, url: ServoUrl) -> DomRoot<WorkerLocation> {
reflect_dom_object(
Box::new(WorkerLocation::new_inherited(url)),
global,
CanGc::note(),
)
}
#[allow(dead_code)]
pub fn origin(&self) -> ImmutableOrigin {
self.url.origin()
}
}
impl WorkerLocationMethods<crate::DomTypeHolder> for WorkerLocation {
fn Hash(&self) -> USVString {
UrlHelper::Hash(&self.url)
}
fn Host(&self) -> USVString {
UrlHelper::Host(&self.url)
}
fn Hostname(&self) -> USVString {
UrlHelper::Hostname(&self.url)
}
fn Href(&self) -> USVString {
UrlHelper::Href(&self.url)
}
fn Origin(&self) -> USVString {
UrlHelper::Origin(&self.url)
}
fn Pathname(&self) -> USVString {
UrlHelper::Pathname(&self.url)
}
fn Port(&self) -> USVString {
UrlHelper::Port(&self.url)
}
fn Protocol(&self) -> USVString {
UrlHelper::Protocol(&self.url)
}
fn Search(&self) -> USVString {
UrlHelper::Search(&self.url)
}
}