mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Invoke backup element queue via a microtask
This commit is contained in:
parent
4665991503
commit
9b587a4f2d
15 changed files with 252 additions and 7 deletions
|
@ -29,6 +29,8 @@ use js::conversions::ToJSValConvertible;
|
|||
use js::jsapi::{Construct1, IsCallable, IsConstructor, HandleValueArray, HandleObject, MutableHandleValue};
|
||||
use js::jsapi::{Heap, JS_GetProperty, JSAutoCompartment, JSContext};
|
||||
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
|
||||
use microtask::Microtask;
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::ops::Deref;
|
||||
|
@ -532,13 +534,7 @@ impl CustomElementReactionStack {
|
|||
self.processing_backup_element_queue.set(BackupElementQueueFlag::Processing);
|
||||
|
||||
// Step 4
|
||||
// TODO: Invoke Microtask
|
||||
|
||||
// Step 4.1
|
||||
self.backup_queue.invoke_reactions();
|
||||
|
||||
// Step 4.2
|
||||
self.processing_backup_element_queue.set(BackupElementQueueFlag::NotProcessing);
|
||||
ScriptThread::enqueue_microtask(Microtask::CustomElementReaction);
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#enqueue-a-custom-element-callback-reaction
|
||||
|
@ -630,6 +626,7 @@ impl ElementQueue {
|
|||
while let Some(element) = self.next_element() {
|
||||
element.invoke_reactions()
|
||||
}
|
||||
self.queue.borrow_mut().clear();
|
||||
}
|
||||
|
||||
fn next_element(&self) -> Option<Root<Element>> {
|
||||
|
|
|
@ -15,6 +15,7 @@ use dom::htmlimageelement::ImageElementMicrotask;
|
|||
use dom::htmlmediaelement::MediaElementMicrotask;
|
||||
use dom::mutationobserver::MutationObserver;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
@ -33,6 +34,7 @@ pub enum Microtask {
|
|||
Promise(EnqueuedPromiseCallback),
|
||||
MediaElement(MediaElementMicrotask),
|
||||
ImageElement(ImageElementMicrotask),
|
||||
CustomElementReaction,
|
||||
NotifyMutationObservers,
|
||||
}
|
||||
|
||||
|
@ -87,6 +89,9 @@ impl MicrotaskQueue {
|
|||
Microtask::ImageElement(ref task) => {
|
||||
task.handler();
|
||||
},
|
||||
Microtask::CustomElementReaction => {
|
||||
ScriptThread::invoke_backup_element_queue();
|
||||
},
|
||||
Microtask::NotifyMutationObservers => {
|
||||
MutationObserver::notify_mutation_observers();
|
||||
}
|
||||
|
|
|
@ -755,6 +755,15 @@ impl ScriptThread {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn invoke_backup_element_queue() {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
if let Some(script_thread) = root.get() {
|
||||
let script_thread = unsafe { &*script_thread };
|
||||
script_thread.custom_element_reaction_stack.invoke_backup_element_queue();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a new script thread.
|
||||
pub fn new(state: InitialScriptState,
|
||||
port: Receiver<MainThreadScriptMsg>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue