use dom_struct::dom_struct;
use js::rust::HandleObject;
use crate::dom::bindings::codegen::Bindings::DOMPointBinding::{DOMPointInit, DOMPointMethods};
use crate::dom::bindings::codegen::Bindings::DOMPointReadOnlyBinding::DOMPointReadOnlyMethods;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
use crate::dom::bindings::root::DomRoot;
use crate::dom::dompointreadonly::{DOMPointReadOnly, DOMPointWriteMethods};
use crate::dom::globalscope::GlobalScope;
use crate::script_runtime::CanGc;
#[dom_struct]
pub struct DOMPoint {
point: DOMPointReadOnly,
}
#[allow(non_snake_case)]
impl DOMPoint {
fn new_inherited(x: f64, y: f64, z: f64, w: f64) -> DOMPoint {
DOMPoint {
point: DOMPointReadOnly::new_inherited(x, y, z, w),
}
}
pub fn new(
global: &GlobalScope,
x: f64,
y: f64,
z: f64,
w: f64,
can_gc: CanGc,
) -> DomRoot<DOMPoint> {
Self::new_with_proto(global, None, x, y, z, w, can_gc)
}
fn new_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
x: f64,
y: f64,
z: f64,
w: f64,
can_gc: CanGc,
) -> DomRoot<DOMPoint> {
reflect_dom_object_with_proto(
Box::new(DOMPoint::new_inherited(x, y, z, w)),
global,
proto,
can_gc,
)
}
pub fn new_from_init(
global: &GlobalScope,
p: &DOMPointInit,
can_gc: CanGc,
) -> DomRoot<DOMPoint> {
DOMPoint::new(global, p.x, p.y, p.z, p.w, can_gc)
}
}
impl DOMPointMethods for DOMPoint {
fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
x: f64,
y: f64,
z: f64,
w: f64,
) -> Fallible<DomRoot<DOMPoint>> {
Ok(DOMPoint::new_with_proto(global, proto, x, y, z, w, can_gc))
}
fn FromPoint(global: &GlobalScope, init: &DOMPointInit, can_gc: CanGc) -> DomRoot<Self> {
Self::new_from_init(global, init, can_gc)
}
fn X(&self) -> f64 {
self.point.X()
}
fn SetX(&self, value: f64) {
self.point.SetX(value);
}
fn Y(&self) -> f64 {
self.point.Y()
}
fn SetY(&self, value: f64) {
self.point.SetY(value);
}
fn Z(&self) -> f64 {
self.point.Z()
}
fn SetZ(&self, value: f64) {
self.point.SetZ(value);
}
fn W(&self) -> f64 {
self.point.W()
}
fn SetW(&self, value: f64) {
self.point.SetW(value);
}
}