diff options
Diffstat (limited to 'servo/components/style/dom.rs')
-rw-r--r-- | servo/components/style/dom.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/servo/components/style/dom.rs b/servo/components/style/dom.rs index 554d79fdb3..358d788845 100644 --- a/servo/components/style/dom.rs +++ b/servo/components/style/dom.rs @@ -207,6 +207,17 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq { } } + /// Returns the depth of this node in the DOM. + fn depth(&self) -> usize { + let mut depth = 0; + let mut curr = *self; + while let Some(parent) = curr.traversal_parent() { + depth += 1; + curr = parent.as_node(); + } + depth + } + /// Get this node's parent element from the perspective of a restyle /// traversal. fn traversal_parent(&self) -> Option<Self::ConcreteElement>; @@ -398,18 +409,6 @@ pub trait TElement: true } - /// Returns the depth of this element in the DOM. - fn depth(&self) -> usize { - let mut depth = 0; - let mut curr = *self; - while let Some(parent) = curr.traversal_parent() { - depth += 1; - curr = parent; - } - - depth - } - /// Get this node's parent element from the perspective of a restyle /// traversal. fn traversal_parent(&self) -> Option<Self> { |