aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/touchevent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/touchevent.rs')
-rw-r--r--components/script/dom/touchevent.rs125
1 files changed, 69 insertions, 56 deletions
diff --git a/components/script/dom/touchevent.rs b/components/script/dom/touchevent.rs
index 30044094fcd..4dfbed55147 100644
--- a/components/script/dom/touchevent.rs
+++ b/components/script/dom/touchevent.rs
@@ -1,27 +1,26 @@
/* 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::TouchEventBinding;
-use dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods;
-use dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
-use dom::bindings::inheritance::Castable;
-use dom::bindings::js::{MutJS, Root};
-use dom::bindings::reflector::reflect_dom_object;
-use dom::bindings::str::DOMString;
-use dom::event::{EventBubbles, EventCancelable};
-use dom::touchlist::TouchList;
-use dom::uievent::UIEvent;
-use dom::window::Window;
+use crate::dom::bindings::codegen::Bindings::TouchEventBinding::TouchEventMethods;
+use crate::dom::bindings::codegen::Bindings::UIEventBinding::UIEventMethods;
+use crate::dom::bindings::inheritance::Castable;
+use crate::dom::bindings::reflector::reflect_dom_object;
+use crate::dom::bindings::root::{DomRoot, MutDom};
+use crate::dom::bindings::str::DOMString;
+use crate::dom::event::{EventBubbles, EventCancelable};
+use crate::dom::touchlist::TouchList;
+use crate::dom::uievent::UIEvent;
+use crate::dom::window::Window;
use dom_struct::dom_struct;
use std::cell::Cell;
#[dom_struct]
pub struct TouchEvent {
uievent: UIEvent,
- touches: MutJS<TouchList>,
- target_touches: MutJS<TouchList>,
- changed_touches: MutJS<TouchList>,
+ touches: MutDom<TouchList>,
+ target_touches: MutDom<TouchList>,
+ changed_touches: MutDom<TouchList>,
alt_key: Cell<bool>,
meta_key: Cell<bool>,
ctrl_key: Cell<bool>,
@@ -29,14 +28,16 @@ pub struct TouchEvent {
}
impl TouchEvent {
- fn new_inherited(touches: &TouchList,
- changed_touches: &TouchList,
- target_touches: &TouchList) -> TouchEvent {
+ fn new_inherited(
+ touches: &TouchList,
+ changed_touches: &TouchList,
+ target_touches: &TouchList,
+ ) -> TouchEvent {
TouchEvent {
uievent: UIEvent::new_inherited(),
- touches: MutJS::new(touches),
- target_touches: MutJS::new(target_touches),
- changed_touches: MutJS::new(changed_touches),
+ touches: MutDom::new(touches),
+ target_touches: MutDom::new(target_touches),
+ changed_touches: MutDom::new(changed_touches),
ctrl_key: Cell::new(false),
shift_key: Cell::new(false),
alt_key: Cell::new(false),
@@ -44,33 +45,45 @@ impl TouchEvent {
}
}
- pub fn new_uninitialized(window: &Window,
- touches: &TouchList,
- changed_touches: &TouchList,
- target_touches: &TouchList) -> Root<TouchEvent> {
- reflect_dom_object(box TouchEvent::new_inherited(touches, changed_touches, target_touches),
- window,
- TouchEventBinding::Wrap)
+ pub fn new_uninitialized(
+ window: &Window,
+ touches: &TouchList,
+ changed_touches: &TouchList,
+ target_touches: &TouchList,
+ ) -> DomRoot<TouchEvent> {
+ reflect_dom_object(
+ Box::new(TouchEvent::new_inherited(
+ touches,
+ changed_touches,
+ target_touches,
+ )),
+ window,
+ )
}
- pub fn new(window: &Window,
- type_: DOMString,
- can_bubble: EventBubbles,
- cancelable: EventCancelable,
- view: Option<&Window>,
- detail: i32,
- touches: &TouchList,
- changed_touches: &TouchList,
- target_touches: &TouchList,
- ctrl_key: bool,
- alt_key: bool,
- shift_key: bool,
- meta_key: bool) -> Root<TouchEvent> {
+ pub fn new(
+ window: &Window,
+ type_: DOMString,
+ can_bubble: EventBubbles,
+ cancelable: EventCancelable,
+ view: Option<&Window>,
+ detail: i32,
+ touches: &TouchList,
+ changed_touches: &TouchList,
+ target_touches: &TouchList,
+ ctrl_key: bool,
+ alt_key: bool,
+ shift_key: bool,
+ meta_key: bool,
+ ) -> DomRoot<TouchEvent> {
let ev = TouchEvent::new_uninitialized(window, touches, changed_touches, target_touches);
- ev.upcast::<UIEvent>().InitUIEvent(type_,
- bool::from(can_bubble),
- bool::from(cancelable),
- view, detail);
+ ev.upcast::<UIEvent>().InitUIEvent(
+ type_,
+ bool::from(can_bubble),
+ bool::from(cancelable),
+ view,
+ detail,
+ );
ev.ctrl_key.set(ctrl_key);
ev.alt_key.set(alt_key);
ev.shift_key.set(shift_key);
@@ -80,42 +93,42 @@ impl TouchEvent {
}
impl<'a> TouchEventMethods for &'a TouchEvent {
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-ctrlKey
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-ctrlKey>
fn CtrlKey(&self) -> bool {
self.ctrl_key.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-shiftKey
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-shiftKey>
fn ShiftKey(&self) -> bool {
self.shift_key.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-altKey
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-altKey>
fn AltKey(&self) -> bool {
self.alt_key.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-metaKey
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-metaKey>
fn MetaKey(&self) -> bool {
self.meta_key.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEventInit-touches
- fn Touches(&self) -> Root<TouchList> {
+ /// <https://w3c.github.io/touch-events/#widl-TouchEventInit-touches>
+ fn Touches(&self) -> DomRoot<TouchList> {
self.touches.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-targetTouches
- fn TargetTouches(&self) -> Root<TouchList> {
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-targetTouches>
+ fn TargetTouches(&self) -> DomRoot<TouchList> {
self.target_touches.get()
}
- /// https://w3c.github.io/touch-events/#widl-TouchEvent-changedTouches
- fn ChangedTouches(&self) -> Root<TouchList> {
+ /// <https://w3c.github.io/touch-events/#widl-TouchEvent-changedTouches>
+ fn ChangedTouches(&self) -> DomRoot<TouchList> {
self.changed_touches.get()
}
- /// https://dom.spec.whatwg.org/#dom-event-istrusted
+ /// <https://dom.spec.whatwg.org/#dom-event-istrusted>
fn IsTrusted(&self) -> bool {
self.uievent.IsTrusted()
}