mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove TLayoutNode::first_child.
It is replaced by the TNode implementation for LayoutNode and an inherent implementation for ThreadSafeLayoutNode.
This commit is contained in:
parent
dc167ca343
commit
50d4084e9a
1 changed files with 16 additions and 31 deletions
|
@ -83,9 +83,6 @@ pub trait TLayoutNode {
|
|||
/// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to
|
||||
/// call and as such is marked `unsafe`.
|
||||
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node>;
|
||||
|
||||
/// Returns the first child of this node.
|
||||
fn first_child(&self) -> Option<Self>;
|
||||
}
|
||||
|
||||
/// A wrapper so that layout can access only the methods that it should have access to. Layout must
|
||||
|
@ -117,12 +114,6 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
|
|||
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
|
||||
&self.node
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<LayoutNode<'ln>> {
|
||||
unsafe {
|
||||
self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> LayoutNode<'ln> {
|
||||
|
@ -176,14 +167,8 @@ impl<'ln> LayoutNode<'ln> {
|
|||
|
||||
/// Returns an iterator over this node's children.
|
||||
pub fn children(self) -> LayoutNodeChildrenIterator<'ln> {
|
||||
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
|
||||
// of disambiguating methods.
|
||||
fn first_child<T: TLayoutNode>(this: T) -> Option<T> {
|
||||
this.first_child()
|
||||
}
|
||||
|
||||
LayoutNodeChildrenIterator {
|
||||
current: first_child(self),
|
||||
current: self.first_child(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +201,7 @@ impl<'ln> LayoutNode<'ln> {
|
|||
}
|
||||
|
||||
pub fn has_children(self) -> bool {
|
||||
TLayoutNode::first_child(&self).is_some()
|
||||
self.first_child().is_some()
|
||||
}
|
||||
|
||||
/// While doing a reflow, the node at the root has no parent, as far as we're
|
||||
|
@ -630,20 +615,6 @@ impl<'ln> TLayoutNode for ThreadSafeLayoutNode<'ln> {
|
|||
unsafe fn get_jsmanaged<'a>(&'a self) -> &'a LayoutJS<Node> {
|
||||
self.node.get_jsmanaged()
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
|
||||
if self.pseudo != PseudoElementType::Normal {
|
||||
return None
|
||||
}
|
||||
|
||||
if self.has_before_pseudo() {
|
||||
return Some(self.with_pseudo(PseudoElementType::Before(self.get_before_display())));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||
|
@ -682,6 +653,20 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
|||
self.node.flow_debug_id()
|
||||
}
|
||||
|
||||
fn first_child(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
|
||||
if self.pseudo != PseudoElementType::Normal {
|
||||
return None
|
||||
}
|
||||
|
||||
if self.has_before_pseudo() {
|
||||
return Some(self.with_pseudo(PseudoElementType::Before(self.get_before_display())));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(&node))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the next sibling of this node. Unsafe and private because this can lead to races.
|
||||
unsafe fn next_sibling(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
|
||||
if self.pseudo.is_before() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue