mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Upgrade Rust.
This commit is contained in:
parent
62c9a779a9
commit
7a4321d649
81 changed files with 265 additions and 236 deletions
|
@ -370,11 +370,11 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait NodeHelpers {
|
||||
fn ancestors(&self) -> AncestorIterator;
|
||||
fn children(&self) -> AbstractNodeChildrenIterator;
|
||||
fn child_elements(&self) -> ChildElementIterator;
|
||||
fn following_siblings(&self) -> AbstractNodeChildrenIterator;
|
||||
pub trait NodeHelpers<'m, 'n> {
|
||||
fn ancestors(&self) -> AncestorIterator<'n>;
|
||||
fn children(&self) -> AbstractNodeChildrenIterator<'n>;
|
||||
fn child_elements(&self) -> ChildElementIterator<'m, 'n>;
|
||||
fn following_siblings(&self) -> AbstractNodeChildrenIterator<'n>;
|
||||
fn is_in_doc(&self) -> bool;
|
||||
fn is_inclusive_ancestor_of(&self, parent: &JSRef<Node>) -> bool;
|
||||
fn is_parent_of(&self, child: &JSRef<Node>) -> bool;
|
||||
|
@ -412,9 +412,9 @@ pub trait NodeHelpers {
|
|||
fn dump_indent(&self, indent: uint);
|
||||
fn debug_str(&self) -> String;
|
||||
|
||||
fn traverse_preorder<'a>(&'a self) -> TreeIterator<'a>;
|
||||
fn sequential_traverse_postorder<'a>(&'a self) -> TreeIterator<'a>;
|
||||
fn inclusively_following_siblings<'a>(&'a self) -> AbstractNodeChildrenIterator<'a>;
|
||||
fn traverse_preorder(&self) -> TreeIterator<'n>;
|
||||
fn sequential_traverse_postorder(&self) -> TreeIterator<'n>;
|
||||
fn inclusively_following_siblings(&self) -> AbstractNodeChildrenIterator<'n>;
|
||||
|
||||
fn to_trusted_node_address(&self) -> TrustedNodeAddress;
|
||||
|
||||
|
@ -427,7 +427,7 @@ pub trait NodeHelpers {
|
|||
fn remove_self(&self);
|
||||
}
|
||||
|
||||
impl<'a> NodeHelpers for JSRef<'a, Node> {
|
||||
impl<'m, 'n> NodeHelpers<'m, 'n> for JSRef<'n, Node> {
|
||||
/// Dumps the subtree rooted at this node, for debugging.
|
||||
fn dump(&self) {
|
||||
self.dump_indent(0);
|
||||
|
@ -550,20 +550,20 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
/// Iterates over this node and all its descendants, in preorder.
|
||||
fn traverse_preorder<'a>(&'a self) -> TreeIterator<'a> {
|
||||
fn traverse_preorder(&self) -> TreeIterator<'n> {
|
||||
let mut nodes = vec!();
|
||||
gather_abstract_nodes(self, &mut nodes, false);
|
||||
TreeIterator::new(nodes)
|
||||
}
|
||||
|
||||
/// Iterates over this node and all its descendants, in postorder.
|
||||
fn sequential_traverse_postorder<'a>(&'a self) -> TreeIterator<'a> {
|
||||
fn sequential_traverse_postorder(&self) -> TreeIterator<'n> {
|
||||
let mut nodes = vec!();
|
||||
gather_abstract_nodes(self, &mut nodes, true);
|
||||
TreeIterator::new(nodes)
|
||||
}
|
||||
|
||||
fn inclusively_following_siblings<'a>(&'a self) -> AbstractNodeChildrenIterator<'a> {
|
||||
fn inclusively_following_siblings(&self) -> AbstractNodeChildrenIterator<'n> {
|
||||
AbstractNodeChildrenIterator {
|
||||
current_node: Some(self.clone()),
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
self == parent || parent.ancestors().any(|ancestor| &ancestor == self)
|
||||
}
|
||||
|
||||
fn following_siblings(&self) -> AbstractNodeChildrenIterator {
|
||||
fn following_siblings(&self) -> AbstractNodeChildrenIterator<'n> {
|
||||
AbstractNodeChildrenIterator {
|
||||
current_node: self.next_sibling().root().map(|next| next.deref().clone()),
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
Ok(NodeList::new_simple_list(&window.root_ref(), nodes))
|
||||
}
|
||||
|
||||
fn ancestors(&self) -> AncestorIterator {
|
||||
fn ancestors(&self) -> AncestorIterator<'n> {
|
||||
AncestorIterator {
|
||||
current: self.parent_node.get().map(|node| (*node.root()).clone()),
|
||||
}
|
||||
|
@ -677,13 +677,13 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
|
|||
self.owner_doc().root().is_html_document
|
||||
}
|
||||
|
||||
fn children(&self) -> AbstractNodeChildrenIterator {
|
||||
fn children(&self) -> AbstractNodeChildrenIterator<'n> {
|
||||
AbstractNodeChildrenIterator {
|
||||
current_node: self.first_child.get().map(|node| (*node.root()).clone()),
|
||||
}
|
||||
}
|
||||
|
||||
fn child_elements(&self) -> ChildElementIterator {
|
||||
fn child_elements(&self) -> ChildElementIterator<'m, 'n> {
|
||||
self.children()
|
||||
.filter(|node| {
|
||||
node.is_element()
|
||||
|
@ -858,7 +858,8 @@ impl<'a> Iterator<JSRef<'a, Node>> for TreeIterator<'a> {
|
|||
if self.index >= self.nodes.len() {
|
||||
None
|
||||
} else {
|
||||
let v = self.nodes.get(self.index).clone();
|
||||
let v = self.nodes[self.index];
|
||||
let v = v.clone();
|
||||
self.index += 1;
|
||||
Some(v)
|
||||
}
|
||||
|
@ -886,7 +887,7 @@ impl NodeIterator {
|
|||
}
|
||||
}
|
||||
|
||||
fn next_child<'b>(&self, node: &JSRef<'b, Node>) -> Option<JSRef<Node>> {
|
||||
fn next_child<'b>(&self, node: &JSRef<'b, Node>) -> Option<JSRef<'b, Node>> {
|
||||
if !self.include_descendants_of_void && node.is_element() {
|
||||
let elem: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
if elem.deref().is_void() {
|
||||
|
@ -901,7 +902,7 @@ impl NodeIterator {
|
|||
}
|
||||
|
||||
impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator {
|
||||
fn next(&mut self) -> Option<JSRef<Node>> {
|
||||
fn next(&mut self) -> Option<JSRef<'a, Node>> {
|
||||
self.current_node = match self.current_node.as_ref().map(|node| node.root()) {
|
||||
None => {
|
||||
if self.include_start {
|
||||
|
@ -1090,9 +1091,11 @@ impl Node {
|
|||
return Err(HierarchyRequest);
|
||||
}
|
||||
match child {
|
||||
Some(ref child) if child.inclusively_following_siblings()
|
||||
.any(|child| child.is_doctype()) => {
|
||||
return Err(HierarchyRequest);
|
||||
Some(ref child) => {
|
||||
if child.inclusively_following_siblings()
|
||||
.any(|child| child.is_doctype()) {
|
||||
return Err(HierarchyRequest)
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -1109,9 +1112,11 @@ impl Node {
|
|||
return Err(HierarchyRequest);
|
||||
}
|
||||
match child {
|
||||
Some(ref child) if child.inclusively_following_siblings()
|
||||
.any(|child| child.is_doctype()) => {
|
||||
return Err(HierarchyRequest);
|
||||
Some(ref child) => {
|
||||
if child.inclusively_following_siblings()
|
||||
.any(|child| child.is_doctype()) {
|
||||
return Err(HierarchyRequest)
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue