servo: Merge #12911 - stylo: Traverse anonymous children when styling (from bholley:traverse_anonymous_children); r=emilio
The corresponding Gecko changes are at https://bugzilla.mozilla.org/show_bug.cgi?id=1292662 Source-Repo: https://github.com/servo/servo Source-Revision: 8e39313321791cade116b3a5f34a36d8cf99c0f2
This commit is contained in:
@@ -115,6 +115,7 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
type ConcreteElement = ServoLayoutElement<'ln>;
|
||||
type ConcreteDocument = ServoLayoutDocument<'ln>;
|
||||
type ConcreteRestyleDamage = RestyleDamage;
|
||||
type ConcreteChildrenIterator = ServoChildrenIterator<'ln>;
|
||||
|
||||
fn to_unsafe(&self) -> UnsafeNode {
|
||||
unsafe {
|
||||
@@ -147,6 +148,12 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
self.dump_style_indent(0);
|
||||
}
|
||||
|
||||
fn children(self) -> ServoChildrenIterator<'ln> {
|
||||
ServoChildrenIterator {
|
||||
current: self.first_child(),
|
||||
}
|
||||
}
|
||||
|
||||
fn opaque(&self) -> OpaqueNode {
|
||||
unsafe { self.get_jsmanaged().opaque() }
|
||||
}
|
||||
@@ -163,10 +170,6 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
self.opaque().0
|
||||
}
|
||||
|
||||
fn children_count(&self) -> u32 {
|
||||
unsafe { self.node.children_count() }
|
||||
}
|
||||
|
||||
fn as_element(&self) -> Option<ServoLayoutElement<'ln>> {
|
||||
as_element(self.node)
|
||||
}
|
||||
@@ -280,6 +283,19 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ServoChildrenIterator<'a> {
|
||||
current: Option<ServoLayoutNode<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for ServoChildrenIterator<'a> {
|
||||
type Item = ServoLayoutNode<'a>;
|
||||
fn next(&mut self) -> Option<ServoLayoutNode<'a>> {
|
||||
let node = self.current;
|
||||
self.current = node.and_then(|node| node.next_sibling());
|
||||
node
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> LayoutNode for ServoLayoutNode<'ln> {
|
||||
type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user