aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/node.rs
diff options
context:
space:
mode:
authorTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-28 05:15:00 +0900
committerTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-30 03:53:07 +0900
commitb0239b5a5ade3723d08ec59c5ca6a03f561d26fd (patch)
treefb287feae5731d3ba6ecb1478c3eba414f89a07f /src/components/script/dom/node.rs
parent6d9dcd087a032ee2962d0e27223a076fcbc72298 (diff)
downloadservo-b0239b5a5ade3723d08ec59c5ca6a03f561d26fd.tar.gz
servo-b0239b5a5ade3723d08ec59c5ca6a03f561d26fd.zip
Use Cell/RefCell for interior mutability of Element.
Diffstat (limited to 'src/components/script/dom/node.rs')
-rw-r--r--src/components/script/dom/node.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 1a9c70f2806..9cf721d389d 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -1297,8 +1297,8 @@ impl Node {
// FIXME: https://github.com/mozilla/servo/issues/1737
copy_elem.namespace = node_elem.namespace.clone();
let window = document.deref().window.root();
- for attr in node_elem.attrs.iter().map(|attr| attr.root()) {
- copy_elem.attrs.push_unrooted(
+ for attr in node_elem.attrs.borrow().iter().map(|attr| attr.root()) {
+ copy_elem.attrs.borrow_mut().push_unrooted(
&Attr::new(&*window,
attr.deref().local_name.clone(), attr.deref().value.clone(),
attr.deref().name.clone(), attr.deref().namespace.clone(),
@@ -1766,9 +1766,11 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
let other_element: &JSRef<Element> = ElementCast::to_ref(other).unwrap();
// FIXME: namespace prefix
- (element.deref().namespace == other_element.deref().namespace) &&
- (element.deref().local_name == other_element.deref().local_name) &&
- (element.deref().attrs.len() == other_element.deref().attrs.len())
+ let element = element.deref();
+ let other_element = other_element.deref();
+ (element.namespace == other_element.namespace) &&
+ (element.local_name == other_element.local_name) &&
+ (element.attrs.borrow().len() == other_element.attrs.borrow().len())
}
fn is_equal_processinginstruction(node: &JSRef<Node>, other: &JSRef<Node>) -> bool {
let pi: &JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
@@ -1784,9 +1786,11 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
fn is_equal_element_attrs(node: &JSRef<Node>, other: &JSRef<Node>) -> bool {
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
let other_element: &JSRef<Element> = ElementCast::to_ref(other).unwrap();
- assert!(element.deref().attrs.len() == other_element.deref().attrs.len());
- element.deref().attrs.iter().map(|attr| attr.root()).all(|attr| {
- other_element.deref().attrs.iter().map(|attr| attr.root()).any(|other_attr| {
+ let element = element.deref();
+ let other_element = other_element.deref();
+ assert!(element.attrs.borrow().len() == other_element.attrs.borrow().len());
+ element.attrs.borrow().iter().map(|attr| attr.root()).all(|attr| {
+ other_element.attrs.borrow().iter().map(|attr| attr.root()).any(|other_attr| {
(attr.namespace == other_attr.namespace) &&
(attr.local_name == other_attr.local_name) &&
(attr.value == other_attr.value)