diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-16 15:36:10 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-16 15:43:33 +0200 |
commit | 9a267e53feed09ae236a554b7b58b607cdcc55d9 (patch) | |
tree | 9987278164e3dfef6f2ff36eb5b9aabe2729d340 /components/script/task_source | |
parent | 4a39631eafe8e7144a92e2c33e0688a8f3b83295 (diff) | |
download | servo-9a267e53feed09ae236a554b7b58b607cdcc55d9.tar.gz servo-9a267e53feed09ae236a554b7b58b607cdcc55d9.zip |
Send AsyncJobHandler as a MainThreadTask
Diffstat (limited to 'components/script/task_source')
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index f7b7a6577f8..0120564806c 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -6,6 +6,7 @@ use dom::bindings::inheritance::Castable; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask}; use dom::eventtarget::EventTarget; +use dom::globalscope::GlobalScope; use dom::window::Window; use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory}; use script_thread::{MainThreadScriptMsg, Task, TaskCanceller}; @@ -42,6 +43,21 @@ impl TaskSource for DOMManipulationTaskSource { } impl DOMManipulationTaskSource { + pub fn queue_main_thread_task<T>( + &self, + task: Box<T>, + global: &GlobalScope, + ) -> Result<(), ()> + where + T: Task + Send + 'static, + { + let msg = MainThreadScriptMsg::MainThreadTask( + ScriptThreadEventCategory::ScriptEvent, + global.task_canceller().wrap_task(task), + ); + self.0.send(msg).map_err(|_| ()) + } + pub fn queue_event(&self, target: &EventTarget, name: Atom, |