aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_source
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-16 15:36:10 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-16 15:43:33 +0200
commit9a267e53feed09ae236a554b7b58b607cdcc55d9 (patch)
tree9987278164e3dfef6f2ff36eb5b9aabe2729d340 /components/script/task_source
parent4a39631eafe8e7144a92e2c33e0688a8f3b83295 (diff)
downloadservo-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.rs16
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,