mirror of
https://github.com/servo/servo.git
synced 2025-07-30 10:40:27 +01:00
Do not root ChildrenList::node
This commit is contained in:
parent
b149e0c979
commit
17cd4202e7
1 changed files with 6 additions and 6 deletions
|
@ -109,7 +109,7 @@ impl ChildrenList {
|
|||
}
|
||||
|
||||
pub fn len(&self) -> u32 {
|
||||
self.node.root().children_count()
|
||||
self.node.children_count()
|
||||
}
|
||||
|
||||
pub fn item(&self, index: u32) -> Option<Root<Node>> {
|
||||
|
@ -121,7 +121,7 @@ impl ChildrenList {
|
|||
}
|
||||
if index == 0u32 {
|
||||
// Item is first child if any, not worth updating last visited.
|
||||
return self.node.root().GetFirstChild();
|
||||
return self.node.GetFirstChild();
|
||||
}
|
||||
let last_index = self.last_index.get();
|
||||
if index == last_index {
|
||||
|
@ -137,7 +137,7 @@ impl ChildrenList {
|
|||
} else if index > last_index {
|
||||
if index == len - 1u32 {
|
||||
// Item is parent's last child, not worth updating last visited.
|
||||
return Some(self.node.root().GetLastChild().unwrap());
|
||||
return Some(self.node.GetLastChild().unwrap());
|
||||
}
|
||||
if index <= last_index + (len - last_index) / 2u32 {
|
||||
// Item is closer to the last visited child and follows it.
|
||||
|
@ -147,7 +147,7 @@ impl ChildrenList {
|
|||
} else {
|
||||
// Item is closer to parent's last child and obviously
|
||||
// precedes it.
|
||||
self.node.root().GetLastChild().unwrap()
|
||||
self.node.GetLastChild().unwrap()
|
||||
.inclusively_preceding_siblings()
|
||||
.nth((len - index - 1u32) as usize).unwrap()
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ impl ChildrenList {
|
|||
} else {
|
||||
// Item is closer to parent's first child and obviously follows it.
|
||||
debug_assert!(index < last_index / 2u32);
|
||||
self.node.root().GetFirstChild().unwrap()
|
||||
self.node.GetFirstChild().unwrap()
|
||||
.inclusively_following_siblings()
|
||||
.nth(index as usize)
|
||||
.unwrap()
|
||||
|
@ -263,7 +263,7 @@ impl ChildrenList {
|
|||
}
|
||||
|
||||
fn reset(&self) {
|
||||
self.last_visited.set(self.node.root().GetFirstChild().as_ref().map(Root::r));
|
||||
self.last_visited.set(self.node.GetFirstChild().r());
|
||||
self.last_index.set(0u32);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue