aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorPierre Chevalier <pierrechevalier83@gmail.com>2015-10-08 22:58:43 +0100
committerPierre Chevalier <pierrechevalier83@gmail.com>2015-10-08 23:12:20 +0100
commit8b5fe88bd35b663287f7c9d55d7ccaf404a79ac6 (patch)
tree1a7c39f36e1a20c9350c255667dd703f6d769a31 /components/script/dom/node.rs
parentab42ca42967354cba08d1dca83aa99a637bd7a6b (diff)
downloadservo-8b5fe88bd35b663287f7c9d55d7ccaf404a79ac6.tar.gz
servo-8b5fe88bd35b663287f7c9d55d7ccaf404a79ac6.zip
Refactor away duplication of get_rooted functionality
Refactor .get().map(Root::from_rooted) and .get().map(|foo| foo.root()) to .get_rooted() on MutNullableHeap objects. First part done mechanically with the following comand: sed -i s/"get().map(Root::from_rooted)"/"get_rooted()"/g *.rs Second part done manually after finding them with git grep ".get().map(" Fixes 7929.
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 48df7dbf490..9205055cf56 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -298,11 +298,11 @@ impl Node {
assert!(new_child.next_sibling.get().is_none());
match before {
Some(ref before) => {
- assert!(before.parent_node.get().map(Root::from_rooted).r() == Some(self));
+ assert!(before.parent_node.get_rooted().r() == Some(self));
let prev_sibling = before.GetPreviousSibling();
match prev_sibling {
None => {
- assert!(Some(*before) == self.first_child.get().map(Root::from_rooted).r());
+ assert!(Some(*before) == self.first_child.get_rooted().r());
self.first_child.set(Some(JS::from_ref(new_child)));
},
Some(ref prev_sibling) => {
@@ -343,7 +343,7 @@ impl Node {
///
/// Fails unless `child` is a child of this node.
fn remove_child(&self, child: &Node) {
- assert!(child.parent_node.get().map(Root::from_rooted).r() == Some(self));
+ assert!(child.parent_node.get_rooted().r() == Some(self));
let prev_sibling = child.GetPreviousSibling();
match prev_sibling {
None => {
@@ -788,7 +788,7 @@ impl Node {
let doc = self.owner_doc();
let node = try!(doc.r().node_from_nodes_and_strings(nodes));
// Step 2.
- let first_child = self.first_child.get().map(Root::from_rooted);
+ let first_child = self.first_child.get_rooted();
Node::pre_insert(node.r(), self, first_child.r()).map(|_| ())
}
@@ -1937,7 +1937,7 @@ impl NodeMethods for Node {
// https://dom.spec.whatwg.org/#dom-node-parentnode
fn GetParentNode(&self) -> Option<Root<Node>> {
- self.parent_node.get().map(Root::from_rooted)
+ self.parent_node.get_rooted()
}
// https://dom.spec.whatwg.org/#dom-node-parentelement
@@ -1961,22 +1961,22 @@ impl NodeMethods for Node {
// https://dom.spec.whatwg.org/#dom-node-firstchild
fn GetFirstChild(&self) -> Option<Root<Node>> {
- self.first_child.get().map(Root::from_rooted)
+ self.first_child.get_rooted()
}
// https://dom.spec.whatwg.org/#dom-node-lastchild
fn GetLastChild(&self) -> Option<Root<Node>> {
- self.last_child.get().map(Root::from_rooted)
+ self.last_child.get_rooted()
}
// https://dom.spec.whatwg.org/#dom-node-previoussibling
fn GetPreviousSibling(&self) -> Option<Root<Node>> {
- self.prev_sibling.get().map(Root::from_rooted)
+ self.prev_sibling.get_rooted()
}
// https://dom.spec.whatwg.org/#dom-node-nextsibling
fn GetNextSibling(&self) -> Option<Root<Node>> {
- self.next_sibling.get().map(Root::from_rooted)
+ self.next_sibling.get_rooted()
}
// https://dom.spec.whatwg.org/#dom-node-nodevalue
@@ -2482,7 +2482,7 @@ impl VirtualMethods for Node {
self.children_count.set(added.len() as u32);
},
}
- if let Some(list) = self.child_list.get().map(|list| list.root()) {
+ if let Some(list) = self.child_list.get_rooted() {
list.as_children_list().children_changed(mutation);
}
}