diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/node.rs | 9 | ||||
-rw-r--r-- | components/script/dom/nodeiterator.rs | 4 | ||||
-rw-r--r-- | components/script/dom/range.rs | 18 | ||||
-rw-r--r-- | components/script/dom/servohtmlparser.rs | 2 | ||||
-rw-r--r-- | components/script/dom/textencoder.rs | 4 | ||||
-rw-r--r-- | components/script/dom/treewalker.rs | 14 | ||||
-rw-r--r-- | components/script/dom/url.rs | 2 | ||||
-rw-r--r-- | components/script/dom/urlhelper.rs | 2 | ||||
-rw-r--r-- | components/script/dom/virtualmethods.rs | 2 |
9 files changed, 23 insertions, 34 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index bc5af4af038..6ca62f181e3 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -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(self) -> RefMut<Option<LayoutData>> { + pub fn borrow_mut(&self) -> RefMut<Option<LayoutData>> { debug_assert!(task_state::get().is_layout()); self.data_cell.borrow_mut() } @@ -2088,12 +2088,7 @@ impl<'a> NodeMethods for &'a Node { // https://dom.spec.whatwg.org/#dom-node-nodevalue fn GetNodeValue(self) -> Option<DOMString> { - if let NodeTypeId::CharacterData(..) = self.type_id { - let chardata: &CharacterData = CharacterDataCast::to_ref(self).unwrap(); - Some(chardata.Data()) - } else { - None - } + CharacterDataCast::to_ref(self).map(|c| c.Data()) } // https://dom.spec.whatwg.org/#dom-node-nodevalue diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index 7e641c83cfd..0958bfca992 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -138,7 +138,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator { } } - return Ok(None); + Ok(None) } // https://dom.spec.whatwg.org/#dom-nodeiterator-previousnode @@ -183,7 +183,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator { } } - return Ok(None); + Ok(None) } // https://dom.spec.whatwg.org/#dom-nodeiterator-detach diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index b67ce2d60c8..78af618eff5 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -122,7 +122,7 @@ impl Range { return Err(HierarchyRequest); } - return Ok((first_contained_child, last_contained_child, contained_children)); + Ok((first_contained_child, last_contained_child, contained_children)) } } @@ -338,17 +338,11 @@ impl<'a> RangeMethods for &'a Range { let end = &inner.end; let end_node = end.node(); let end_offset = end.offset; - match (bp_position(parent.r(), offset + 1, start_node.r(), start_offset).unwrap(), - bp_position(parent.r(), offset, end_node.r(), end_offset).unwrap()) { - (Ordering::Greater, Ordering::Less) => { - // Step 5. - true - }, - _ => { - // Step 6. - false - } - } + // Step 5. + Ordering::Greater == bp_position(parent.r(), offset + 1, + start_node.r(), start_offset).unwrap() && + Ordering::Less == bp_position(parent.r(), offset, + end_node.r(), end_offset).unwrap() } // https://dom.spec.whatwg.org/#dom-range-clonecontents diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs index e979e3f6610..b9ccd50632f 100644 --- a/components/script/dom/servohtmlparser.rs +++ b/components/script/dom/servohtmlparser.rs @@ -268,7 +268,7 @@ impl ServoHTMLParser { } #[inline] - pub fn tokenizer<'a>(&'a self) -> &'a DOMRefCell<Tokenizer> { + pub fn tokenizer(&self) -> &DOMRefCell<Tokenizer> { &self.tokenizer } } diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 29a715a8ed1..1b76de05d0d 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -65,7 +65,7 @@ impl TextEncoder { } _ => { debug!("Encoding Not UTF"); - return Err(Range("The encoding must be utf-8, utf-16le, or utf-16be.".to_owned())) + Err(Range("The encoding must be utf-8, utf-16le, or utf-16be.".to_owned())) } } } @@ -87,7 +87,7 @@ impl<'a> TextEncoderMethods for &'a TextEncoder { let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, ptr::null()); ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize); - return js_object; + js_object } } } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 0c8e6065709..b8271909505 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -104,7 +104,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { node = n; // "2. If node is not null and filtering node returns FILTER_ACCEPT, // then set the currentNode attribute to node, return node." - if let NodeFilterConstants::FILTER_ACCEPT = try!(self.accept_node(node.r())) { + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { self.current_node.set(JS::from_rooted(&node)); return Ok(Some(node)) } @@ -192,7 +192,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { } // "5. Filter node and if the return value is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - if let NodeFilterConstants::FILTER_ACCEPT = try!(self.accept_node(node.r())) { + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { self.current_node.set(JS::from_rooted(&node)); return Ok(Some(node)) } @@ -211,7 +211,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { loop { // "1. While result is not FILTER_REJECT and node has a child, run these subsubsteps:" loop { - if let NodeFilterConstants::FILTER_REJECT = result { + if NodeFilterConstants::FILTER_REJECT == result { break; } match node.r().GetFirstChild() { @@ -223,7 +223,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { result = try!(self.accept_node(node.r())); // "3. If result is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - if let NodeFilterConstants::FILTER_ACCEPT = result { + if NodeFilterConstants::FILTER_ACCEPT == result { self.current_node.set(JS::from_rooted(&node)); return Ok(Some(node)) } @@ -241,7 +241,7 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { result = try!(self.accept_node(node.r())); // "4. If result is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - if let NodeFilterConstants::FILTER_ACCEPT = result { + if NodeFilterConstants::FILTER_ACCEPT == result { self.current_node.set(JS::from_rooted(&node)); return Ok(Some(node)) } @@ -378,7 +378,7 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker { let result = try!(self.accept_node(node.r())); // "3. If result is FILTER_ACCEPT, then set the currentNode // attribute to node and return node." - if let NodeFilterConstants::FILTER_ACCEPT = result { + if NodeFilterConstants::FILTER_ACCEPT == result { self.current_node.set(JS::from_rooted(&node)); return Ok(Some(node)) } @@ -403,7 +403,7 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker { // "5. Filter node and if the return value is FILTER_ACCEPT, then return null." Some(n) => { node = n; - if let NodeFilterConstants::FILTER_ACCEPT = try!(self.accept_node(node.r())) { + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { return Ok(None) } } diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 9bbd0f1b5fc..d4a8b5a23ff 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -142,7 +142,7 @@ impl<'a> URLMethods for &'a URL { } } -fn parser_with_base<'a>(base: Option<&'a Url>) -> UrlParser<'a> { +fn parser_with_base(base: Option<&Url>) -> UrlParser { let mut parser = UrlParser::new(); if let Some(base) = base { parser.base_url(base); diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index cff468574b2..4376a85e390 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -84,7 +84,7 @@ impl UrlHelper { if urlA.port() != urlB.port() { return false } - return true + true } // https://url.spec.whatwg.org/#dom-urlutils-search diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index b67cbb69d4f..437f39422c6 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -48,7 +48,7 @@ use string_cache::Atom; pub trait VirtualMethods { /// Returns self as the superclass of the implementation for this trait, /// if any. - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods>; + fn super_type(&self) -> Option<&VirtualMethods>; /// Called when changing or adding attributes, after the attribute's value /// has been updated. |