diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-02 15:38:55 -0500 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-02 15:38:55 -0500 |
commit | e8cf789fc56dfbc4bfd6145d3bd1a30aa9459c95 (patch) | |
tree | b594ff80d72f20ea11b021b31b9b5f3e939efb65 /components/script/task_source/dom_manipulation.rs | |
parent | a99cd2362dd746a73510a2a804196f5c2c09dfec (diff) | |
parent | 05fc799f923813bf0b63d50218f916684a499b87 (diff) | |
download | servo-e8cf789fc56dfbc4bfd6145d3bd1a30aa9459c95.tar.gz servo-e8cf789fc56dfbc4bfd6145d3bd1a30aa9459c95.zip |
Auto merge of #11564 - KiChjang:dom-manipulation-task-source, r=jdm
Clean up DOMManipulationTaskSource
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because refactoring
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11564)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/task_source/dom_manipulation.rs')
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 28 |
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); } |