mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Auto merge of #16883 - jdm:mutationobserver, r=jdm
Mutation Observer API Rebased from #16668. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix (partially) #6633 - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16883) <!-- Reviewable:end -->
This commit is contained in:
commit
5da0aa9f11
15 changed files with 432 additions and 180 deletions
|
@ -481,6 +481,9 @@ pub struct ScriptThread {
|
|||
|
||||
microtask_queue: MicrotaskQueue,
|
||||
|
||||
/// Microtask Queue for adding support for mutation observer microtasks
|
||||
mutation_observer_compound_microtask_queued: Cell<bool>,
|
||||
|
||||
/// The unit of related similar-origin browsing contexts' list of MutationObserver objects
|
||||
mutation_observers: DOMRefCell<Vec<JS<MutationObserver>>>,
|
||||
|
||||
|
@ -589,6 +592,20 @@ impl ScriptThread {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_mutation_observer_compound_microtask_queued(value: bool) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
script_thread.mutation_observer_compound_microtask_queued.set(value);
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_mutation_observer_compound_microtask_queued() -> bool {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
return script_thread.mutation_observer_compound_microtask_queued.get();
|
||||
})
|
||||
}
|
||||
|
||||
pub fn add_mutation_observer(observer: &MutationObserver) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
|
@ -598,6 +615,13 @@ impl ScriptThread {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_mutation_observers() -> Vec<Root<MutationObserver>> {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
script_thread.mutation_observers.borrow().iter().map(|o| Root::from_ref(&**o)).collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn mark_document_with_no_blocked_loads(doc: &Document) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
|
@ -750,6 +774,8 @@ impl ScriptThread {
|
|||
|
||||
microtask_queue: MicrotaskQueue::default(),
|
||||
|
||||
mutation_observer_compound_microtask_queued: Default::default(),
|
||||
|
||||
mutation_observers: Default::default(),
|
||||
|
||||
layout_to_constellation_chan: state.layout_to_constellation_chan,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue