aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorSumit <srivassumit@gmail.com>2017-05-14 01:44:14 -0400
committerJosh Matthews <josh@joshmatthews.net>2017-05-15 18:15:38 -0400
commit3ca89204ffcdcabcf7bb1a343497bdae860c72b2 (patch)
treebb775040dde9f58f5ad424e39f10eda8ebbb4f1b /components/script/dom/node.rs
parentfa251ec96b445b9ba8439d76e05870a88c2caa0f (diff)
downloadservo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.tar.gz
servo-3ca89204ffcdcabcf7bb1a343497bdae860c72b2.zip
Mutation Observer API
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 6d16cac6731..9d697bdcccf 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -7,6 +7,7 @@
use app_units::Au;
use devtools_traits::NodeInfo;
use document_loader::DocumentLoader;
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
@@ -46,6 +47,7 @@ use dom::htmllinkelement::HTMLLinkElement;
use dom::htmlmetaelement::HTMLMetaElement;
use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHelpers};
+use dom::mutationobserver::RegisteredObserver;
use dom::nodelist::NodeList;
use dom::processinginstruction::ProcessingInstruction;
use dom::range::WeakRangeVec;
@@ -72,7 +74,7 @@ use selectors::matching::matches_selector_list;
use selectors::parser::SelectorList;
use servo_url::ServoUrl;
use std::borrow::ToOwned;
-use std::cell::{Cell, UnsafeCell};
+use std::cell::{Cell, UnsafeCell, RefMut};
use std::cmp::max;
use std::default::Default;
use std::iter;
@@ -138,6 +140,9 @@ pub struct Node {
/// node is finalized.
style_and_layout_data: Cell<Option<OpaqueStyleAndLayoutData>>,
+ /// Registered observers for this node.
+ mutation_observers: DOMRefCell<Vec<RegisteredObserver>>,
+
unique_id: UniqueId,
}
@@ -363,6 +368,11 @@ impl Node {
}
}
+ /// Return all registered mutation observers for this node.
+ pub fn registered_mutation_observers(&self) -> RefMut<Vec<RegisteredObserver>> {
+ self.mutation_observers.borrow_mut()
+ }
+
/// Dumps the subtree rooted at this node, for debugging.
pub fn dump(&self) {
self.dump_indent(0);
@@ -1411,6 +1421,8 @@ impl Node {
style_and_layout_data: Cell::new(None),
+ mutation_observers: Default::default(),
+
unique_id: UniqueId::new(),
}
}