Cleanup NodeIterator, Range, ServoHTMLParser, TextEncoder, URLHelper, URL, VirtualMethods

This commit is contained in:
Manish Goregaokar 2015-08-15 05:32:51 +05:30
parent a53b86f107
commit 19241c95f7
13 changed files with 24 additions and 53 deletions

View file

@ -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

View file

@ -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

View file

@ -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
}
}
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

View file

@ -268,7 +268,7 @@ impl ServoHTMLParser {
}
#[inline]
pub fn tokenizer<'a>(&'a self) -> &'a DOMRefCell<Tokenizer> {
pub fn tokenizer(&self) -> &DOMRefCell<Tokenizer> {
&self.tokenizer
}
}

View file

@ -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
}
}
}

View file

@ -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)
}
}

View file

@ -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);

View file

@ -84,7 +84,7 @@ impl UrlHelper {
if urlA.port() != urlB.port() {
return false
}
return true
true
}
// https://url.spec.whatwg.org/#dom-urlutils-search

View file

@ -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.

View file

@ -166,11 +166,6 @@ dependencies = [
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy"
version = "0.0.11"
source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21"
[[package]]
name = "clock_ticks"
version = "0.0.6"
@ -1109,7 +1104,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "plugins"
version = "0.0.1"
dependencies = [
"clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)",
"tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)",
]

6
ports/cef/Cargo.lock generated
View file

@ -165,11 +165,6 @@ dependencies = [
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy"
version = "0.0.11"
source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21"
[[package]]
name = "clock_ticks"
version = "0.0.6"
@ -1087,7 +1082,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "plugins"
version = "0.0.1"
dependencies = [
"clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)",
"tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)",
]

6
ports/gonk/Cargo.lock generated
View file

@ -151,11 +151,6 @@ dependencies = [
"winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy"
version = "0.0.11"
source = "git+https://github.com/Manishearth/rust-clippy?branch=servo#4d5e15ee6e1061ed7da0a91df3510728cabc0a21"
[[package]]
name = "clock_ticks"
version = "0.0.6"
@ -993,7 +988,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "plugins"
version = "0.0.1"
dependencies = [
"clippy 0.0.11 (git+https://github.com/Manishearth/rust-clippy?branch=servo)",
"tenacious 0.0.9 (git+https://github.com/servo/rust-tenacious)",
]