diff options
author | yvt <i@yvt.jp> | 2021-07-10 17:24:27 +0900 |
---|---|---|
committer | yvt <i@yvt.jp> | 2021-07-10 17:55:42 +0900 |
commit | 01a7de50ab1843d85295f9dccad7f4c099e7208c (patch) | |
tree | ee53fb6e8889deb7b880ee969e6c662e6128d210 /components/script/dom/touch.rs | |
parent | ff8d2cdbbfc7a9dc7f38b7dd47cb350fde39388f (diff) | |
parent | 94b613fbdaa2b98f2179fc0bbda13c64e6fa0d38 (diff) | |
download | servo-01a7de50ab1843d85295f9dccad7f4c099e7208c.tar.gz servo-01a7de50ab1843d85295f9dccad7f4c099e7208c.zip |
Merge remote-tracking branch 'upstream/master' into feat-cow-infra
`tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html`
was reverted to the upstream version.
Diffstat (limited to 'components/script/dom/touch.rs')
-rw-r--r-- | components/script/dom/touch.rs | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/components/script/dom/touch.rs b/components/script/dom/touch.rs index 3ebfd17af12..60e69a48ca3 100644 --- a/components/script/dom/touch.rs +++ b/components/script/dom/touch.rs @@ -1,21 +1,20 @@ /* 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/. */ + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use dom::bindings::codegen::Bindings::TouchBinding; -use dom::bindings::codegen::Bindings::TouchBinding::TouchMethods; -use dom::bindings::js::{MutJS, Root}; -use dom::bindings::num::Finite; -use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::eventtarget::EventTarget; -use dom::window::Window; +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; use dom_struct::dom_struct; #[dom_struct] pub struct Touch { reflector_: Reflector, identifier: i32, - target: MutJS<EventTarget>, + target: MutDom<EventTarget>, screen_x: f64, screen_y: f64, client_x: f64, @@ -25,14 +24,20 @@ pub struct Touch { } impl Touch { - fn new_inherited(identifier: i32, target: &EventTarget, - screen_x: Finite<f64>, screen_y: Finite<f64>, - client_x: Finite<f64>, client_y: Finite<f64>, - page_x: Finite<f64>, page_y: Finite<f64>) -> Touch { + fn new_inherited( + identifier: i32, + target: &EventTarget, + screen_x: Finite<f64>, + screen_y: Finite<f64>, + client_x: Finite<f64>, + client_y: Finite<f64>, + page_x: Finite<f64>, + page_y: Finite<f64>, + ) -> Touch { Touch { reflector_: Reflector::new(), identifier: identifier, - target: MutJS::new(target), + target: MutDom::new(target), screen_x: *screen_x, screen_y: *screen_y, client_x: *client_x, @@ -42,56 +47,63 @@ impl Touch { } } - pub fn new(window: &Window, identifier: i32, target: &EventTarget, - screen_x: Finite<f64>, screen_y: Finite<f64>, - client_x: Finite<f64>, client_y: Finite<f64>, - page_x: Finite<f64>, page_y: Finite<f64>) -> Root<Touch> { - reflect_dom_object(box Touch::new_inherited(identifier, target, - screen_x, screen_y, - client_x, client_y, - page_x, page_y), - window, - TouchBinding::Wrap) + pub fn new( + window: &Window, + identifier: i32, + target: &EventTarget, + screen_x: Finite<f64>, + screen_y: Finite<f64>, + client_x: Finite<f64>, + client_y: Finite<f64>, + page_x: Finite<f64>, + page_y: Finite<f64>, + ) -> DomRoot<Touch> { + 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 { - /// https://w3c.github.io/touch-events/#widl-Touch-identifier + /// <https://w3c.github.io/touch-events/#widl-Touch-identifier> fn Identifier(&self) -> i32 { self.identifier } - /// https://w3c.github.io/touch-events/#widl-Touch-target - fn Target(&self) -> Root<EventTarget> { + /// <https://w3c.github.io/touch-events/#widl-Touch-target> + fn Target(&self) -> DomRoot<EventTarget> { self.target.get() } - /// https://w3c.github.io/touch-events/#widl-Touch-screenX + /// <https://w3c.github.io/touch-events/#widl-Touch-screenX> fn ScreenX(&self) -> Finite<f64> { Finite::wrap(self.screen_x) } - /// https://w3c.github.io/touch-events/#widl-Touch-screenY + /// <https://w3c.github.io/touch-events/#widl-Touch-screenY> fn ScreenY(&self) -> Finite<f64> { Finite::wrap(self.screen_y) } - /// https://w3c.github.io/touch-events/#widl-Touch-clientX + /// <https://w3c.github.io/touch-events/#widl-Touch-clientX> fn ClientX(&self) -> Finite<f64> { Finite::wrap(self.client_x) } - /// https://w3c.github.io/touch-events/#widl-Touch-clientY + /// <https://w3c.github.io/touch-events/#widl-Touch-clientY> fn ClientY(&self) -> Finite<f64> { Finite::wrap(self.client_y) } - /// https://w3c.github.io/touch-events/#widl-Touch-clientX + /// <https://w3c.github.io/touch-events/#widl-Touch-clientX> fn PageX(&self) -> Finite<f64> { Finite::wrap(self.page_x) } - /// https://w3c.github.io/touch-events/#widl-Touch-clientY + /// <https://w3c.github.io/touch-events/#widl-Touch-clientY> fn PageY(&self) -> Finite<f64> { Finite::wrap(self.page_y) } |