/* 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 https://mozilla.org/MPL/2.0/. */ use dom_struct::dom_struct; use crate::dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; use crate::dom::bindings::num::Finite; use crate::dom::bindings::reflector::{reflect_dom_object, Reflector}; use crate::dom::bindings::root::{DomRoot, MutDom}; use crate::dom::eventtarget::EventTarget; use crate::dom::window::Window; #[dom_struct] pub struct Touch { reflector_: Reflector, identifier: i32, target: MutDom, screen_x: f64, screen_y: f64, client_x: f64, client_y: f64, page_x: f64, page_y: f64, } impl Touch { #[allow(clippy::too_many_arguments)] fn new_inherited( identifier: i32, target: &EventTarget, screen_x: Finite, screen_y: Finite, client_x: Finite, client_y: Finite, page_x: Finite, page_y: Finite, ) -> Touch { Touch { reflector_: Reflector::new(), identifier, target: MutDom::new(target), screen_x: *screen_x, screen_y: *screen_y, client_x: *client_x, client_y: *client_y, page_x: *page_x, page_y: *page_y, } } #[allow(clippy::too_many_arguments)] pub fn new( window: &Window, identifier: i32, target: &EventTarget, screen_x: Finite, screen_y: Finite, client_x: Finite, client_y: Finite, page_x: Finite, page_y: Finite, ) -> DomRoot { reflect_dom_object( Box::new(Touch::new_inherited( identifier, target, screen_x, screen_y, client_x, client_y, page_x, page_y, )), window, ) } } impl TouchMethods for Touch { /// fn Identifier(&self) -> i32 { self.identifier } /// fn Target(&self) -> DomRoot { self.target.get() } /// fn ScreenX(&self) -> Finite { Finite::wrap(self.screen_x) } /// fn ScreenY(&self) -> Finite { Finite::wrap(self.screen_y) } /// fn ClientX(&self) -> Finite { Finite::wrap(self.client_x) } /// fn ClientY(&self) -> Finite { Finite::wrap(self.client_y) } /// fn PageX(&self) -> Finite { Finite::wrap(self.page_x) } /// fn PageY(&self) -> Finite { Finite::wrap(self.page_y) } }