diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-17 01:21:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-17 01:21:40 -0500 |
commit | 5da0aa9f11b7b1c2dc8b5adf178eebafa92d1849 (patch) | |
tree | ccf0d864f7043d761a57e287a932cd325e1ba756 /components/script/script_thread.rs | |
parent | 837531992864f920342020462830b933d5ed0280 (diff) | |
parent | 3ca89204ffcdcabcf7bb1a343497bdae860c72b2 (diff) | |
download | servo-5da0aa9f11b7b1c2dc8b5adf178eebafa92d1849.tar.gz servo-5da0aa9f11b7b1c2dc8b5adf178eebafa92d1849.zip |
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 -->
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 9ab6fd301bc..a8b20b6cf98 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -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, |