use microtasks to await a stable state

This commit is contained in:
Gregory Terzian 2017-05-15 07:19:58 +08:00
parent 5da0aa9f11
commit a8390aea24
12 changed files with 47 additions and 97 deletions

View file

@ -665,14 +665,11 @@ impl ScriptThread {
}
// https://html.spec.whatwg.org/multipage/#await-a-stable-state
pub fn await_stable_state<T: Runnable + Send + 'static>(task: T) {
//TODO use microtasks when they exist
pub fn await_stable_state(task: Microtask) {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
let script_thread = unsafe { &*script_thread };
let _ = script_thread.chan.send(CommonScriptMsg::RunnableMsg(
ScriptThreadEventCategory::DomEvent,
box task));
script_thread.microtask_queue.enqueue(task);
}
});
}