diff options
author | Sumit <srivassumit@gmail.com> | 2017-05-14 01:44:14 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-05-15 18:15:38 -0400 |
commit | 3ca89204ffcdcabcf7bb1a343497bdae860c72b2 (patch) | |
tree | bb775040dde9f58f5ad424e39f10eda8ebbb4f1b /components/script/script_thread.rs | |
parent | fa251ec96b445b9ba8439d76e05870a88c2caa0f (diff) | |
download | servo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.tar.gz servo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.zip |
Mutation Observer API
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index b817fc77d1d..811fc67d212 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -479,6 +479,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>>>, @@ -587,6 +590,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() }; @@ -596,6 +613,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() }; @@ -748,6 +772,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, |