mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
css, submodules: Implement named-ancestor-node
This commit is contained in:
parent
b0f185412d
commit
8c3b8fe3d4
3 changed files with 26 additions and 3 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 7f9bd3c32baae72bec864085e81df7773542f790
|
||||
Subproject commit 3bbe4ed4fc3d642e1e651ff3d8123c9dca626c22
|
|
@ -1 +1 @@
|
|||
Subproject commit 6f7633390e76a08ee2bb43fafdbe8ba5d0890896
|
||||
Subproject commit cb49f5f7b4ae92c70b374b544d6e3f5ab1e3da26
|
|
@ -40,7 +40,30 @@ impl NodeSelectHandler: SelectHandler<Node> {
|
|||
tree::parent(&NodeTree, node)
|
||||
}
|
||||
|
||||
// TODO: Use a Bloom filter.
|
||||
fn named_ancestor_node(node: &Node, name: &str) -> Option<Node> {
|
||||
let mut node = *node;
|
||||
loop {
|
||||
let parent = tree::parent(&NodeTree, &node);
|
||||
match parent {
|
||||
Some(parent) => {
|
||||
let mut found = false;
|
||||
do parent.read |data| {
|
||||
if name == node_name(data) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if found {
|
||||
return Some(parent);
|
||||
}
|
||||
node = parent;
|
||||
}
|
||||
None => return None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn node_is_root(node: &Node) -> bool {
|
||||
self.parent_node(node).is_none()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue