aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_source/dom_manipulation.rs
diff options
context:
space:
mode:
authorKeith Yeung <kungfukeith11@gmail.com>2016-06-02 15:27:08 -0400
committerKeith Yeung <kungfukeith11@gmail.com>2016-06-02 15:27:08 -0400
commit05fc799f923813bf0b63d50218f916684a499b87 (patch)
treeb7d036eebc3e13d18606df9105a19cb49d92b798 /components/script/task_source/dom_manipulation.rs
parentbdecfa13d2114281472d5df4548a8faaf8a5bd87 (diff)
downloadservo-05fc799f923813bf0b63d50218f916684a499b87.tar.gz
servo-05fc799f923813bf0b63d50218f916684a499b87.zip
Clean up DOMManipulationTaskSource
Diffstat (limited to 'components/script/task_source/dom_manipulation.rs')
-rw-r--r--components/script/task_source/dom_manipulation.rs28
1 files changed, 22 insertions, 6 deletions
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs
index 05b0722f889..67cac79c48c 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -21,8 +21,24 @@ impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
}
impl DOMManipulationTaskSource {
- pub fn clone(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
- box DOMManipulationTaskSource((&self.0).clone())
+ pub fn queue_event(&self,
+ target: &EventTarget,
+ name: Atom,
+ bubbles: EventBubbles,
+ cancelable: EventCancelable) {
+ let target = Trusted::new(target);
+ let _ = self.0.send(MainThreadScriptMsg::DOMManipulation(DOMManipulationTask::FireEvent(
+ target, name, bubbles, cancelable)));
+ }
+
+ pub fn queue_simple_event(&self, target: &EventTarget, name: Atom) {
+ let target = Trusted::new(target);
+ let _ = self.0.send(MainThreadScriptMsg::DOMManipulation(DOMManipulationTask::FireSimpleEvent(
+ target, name)));
+ }
+
+ pub fn clone(&self) -> DOMManipulationTaskSource {
+ DOMManipulationTaskSource((&self.0).clone())
}
}
@@ -30,9 +46,9 @@ pub enum DOMManipulationTask {
// https://html.spec.whatwg.org/multipage/#the-end step 7
DocumentProgress(Box<Runnable + Send>),
// https://dom.spec.whatwg.org/#concept-event-fire
- FireEvent(Atom, Trusted<EventTarget>, EventBubbles, EventCancelable),
+ FireEvent(Trusted<EventTarget>, Atom, EventBubbles, EventCancelable),
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
- FireSimpleEvent(Atom, Trusted<EventTarget>),
+ FireSimpleEvent(Trusted<EventTarget>, Atom),
// https://html.spec.whatwg.org/multipage/#details-notification-task-steps
FireToggleEvent(Box<Runnable + Send>),
// Placeholder until there's a real media element task queue implementation
@@ -49,11 +65,11 @@ impl DOMManipulationTask {
match self {
DocumentProgress(runnable) => runnable.handler(),
- FireEvent(name, element, bubbles, cancelable) => {
+ FireEvent(element, name, bubbles, cancelable) => {
let target = element.root();
target.fire_event(&*name, bubbles, cancelable);
}
- FireSimpleEvent(name, element) => {
+ FireSimpleEvent(element, name) => {
let target = element.root();
target.fire_simple_event(&*name);
}