diff options
author | Sumit <srivassumit@gmail.com> | 2017-03-16 15:46:45 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-04-05 01:52:38 -0400 |
commit | 107ac9ab56c1a4cee3e5f9828f91ab394e3e8eee (patch) | |
tree | d65a403aaf42a086904eb86a9e9c22b2a6a5cdf5 /components/script/script_thread.rs | |
parent | 5421d833de30e0c963bc6241120263897d4fc68c (diff) | |
download | servo-107ac9ab56c1a4cee3e5f9828f91ab394e3e8eee.tar.gz servo-107ac9ab56c1a4cee3e5f9828f91ab394e3e8eee.zip |
Implement basic interface for MutationObserver and MutationRecord.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 87cf0920b5e..955887addf4 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -46,6 +46,7 @@ use dom::event::{Event, EventBubbles, EventCancelable}; use dom::globalscope::GlobalScope; use dom::htmlanchorelement::HTMLAnchorElement; use dom::htmliframeelement::HTMLIFrameElement; +use dom::mutationobserver::MutationObserver; use dom::node::{Node, NodeDamage, window_from_node}; use dom::serviceworker::TrustedServiceWorkerAddress; use dom::serviceworkerregistration::ServiceWorkerRegistration; @@ -480,6 +481,9 @@ pub struct ScriptThread { microtask_queue: MicrotaskQueue, + /// The unit of related similar-origin browsing contexts' list of MutationObserver objects + mutation_observers: DOMRefCell<Vec<JS<MutationObserver>>>, + /// A handle to the webvr thread, if available webvr_thread: Option<IpcSender<WebVRMsg>>, @@ -570,6 +574,15 @@ impl ScriptThreadFactory for ScriptThread { } impl ScriptThread { + pub fn add_mutation_observer(observer: &MutationObserver) { + SCRIPT_THREAD_ROOT.with(|root| { + let script_thread = unsafe { &*root.get().unwrap() }; + script_thread.mutation_observers + .borrow_mut() + .push(JS::from_ref(observer)); + }) + } + pub fn mark_document_with_no_blocked_loads(doc: &Document) { SCRIPT_THREAD_ROOT.with(|root| { let script_thread = unsafe { &*root.get().unwrap() }; @@ -722,6 +735,8 @@ impl ScriptThread { microtask_queue: MicrotaskQueue::default(), + mutation_observers: Default::default(), + layout_to_constellation_chan: state.layout_to_constellation_chan, webvr_thread: state.webvr_thread, |