diff options
author | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-15 04:53:43 +0530 |
---|---|---|
committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-08-18 18:37:02 +0530 |
commit | b21df4844c60dc0bcbf5e427be1431003ce2fbce (patch) | |
tree | 273b8533b02b60d7060200bb90e67e73f4120313 /components/script/dom/node.rs | |
parent | 94cd004c286b05c31ea56144d94b257e550947db (diff) | |
download | servo-b21df4844c60dc0bcbf5e427be1431003ce2fbce.tar.gz servo-b21df4844c60dc0bcbf5e427be1431003ce2fbce.zip |
Cleanup node.rs
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 72855380540..bc5af4af038 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -264,7 +264,7 @@ impl LayoutDataRef { /// Borrows the layout data immutably. This function is *not* thread-safe. #[inline] - pub fn borrow<'a>(&'a self) -> Ref<'a, Option<LayoutData>> { + pub fn borrow(&self) -> Ref<Option<LayoutData>> { debug_assert!(task_state::get().is_layout()); self.data_cell.borrow() } @@ -275,7 +275,7 @@ impl LayoutDataRef { /// prevent CSS selector matching from mutably accessing nodes it's not supposed to and racing /// on it. This has already resulted in one bug! #[inline] - pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, Option<LayoutData>> { + pub fn borrow_mut(self) -> RefMut<Option<LayoutData>> { debug_assert!(task_state::get().is_layout()); self.data_cell.borrow_mut() } @@ -908,7 +908,7 @@ impl<'a> NodeHelpers for &'a Node { // Step 1. match parse_author_origin_selector_list_from_str(&selectors) { // Step 2. - Err(()) => return Err(Syntax), + Err(()) => Err(Syntax), // Step 3. Ok(ref selectors) => { let root = self.ancestors().last(); @@ -1326,7 +1326,7 @@ impl Iterator for FollowingNodeIterator { } } self.current = None; - return None + None } } @@ -1372,7 +1372,7 @@ impl Iterator for PrecedingNodeIterator { } self.current = None; - return None + None } } @@ -1663,7 +1663,7 @@ impl Node { Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed); // Step 6. - return Ok(Root::from_ref(node)) + Ok(Root::from_ref(node)) } // https://dom.spec.whatwg.org/#concept-node-insert @@ -2088,24 +2088,18 @@ impl<'a> NodeMethods for &'a Node { // https://dom.spec.whatwg.org/#dom-node-nodevalue fn GetNodeValue(self) -> Option<DOMString> { - match self.type_id { - NodeTypeId::CharacterData(..) => { - let chardata: &CharacterData = CharacterDataCast::to_ref(self).unwrap(); - Some(chardata.Data()) - } - _ => { - None - } + if let NodeTypeId::CharacterData(..) = self.type_id { + let chardata: &CharacterData = CharacterDataCast::to_ref(self).unwrap(); + Some(chardata.Data()) + } else { + None } } // https://dom.spec.whatwg.org/#dom-node-nodevalue fn SetNodeValue(self, val: Option<DOMString>) { - match self.type_id { - NodeTypeId::CharacterData(..) => { - self.SetTextContent(val) - } - _ => {} + if let NodeTypeId::CharacterData(..) = self.type_id { + self.SetTextContent(val) } } @@ -2565,7 +2559,7 @@ pub fn window_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Window> } impl<'a> VirtualMethods for &'a Node { - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { + fn super_type(&self) -> Option<&VirtualMethods> { let eventtarget: &&EventTarget = EventTargetCast::from_borrowed_ref(self); Some(eventtarget as &VirtualMethods) } |