@@ -108,11 +108,10 @@ fn find_children_recursive(tree: &Taffy, node: NodeId, out: &mut Vec<NodeId>) {
108108 }
109109}
110110
111- impl LayoutTree for Taffy {
112- type ChildIter < ' a > = RefCellVecIter < ' a > ;
113-
114- #[ inline( always) ]
115- fn children ( & self , node : NodeId ) -> Self :: ChildIter < ' _ > {
111+ impl Taffy {
112+ /// Returns the resolved children, taking into account `Display::Contents`
113+ /// Will use cached result if available, else compute and cache.
114+ fn resolve_children ( & self , node : NodeId ) -> RefMut < ' _ , Vec < NodeId > > {
116115 let mut cache = self . node_children_cache . borrow_mut ( ) ;
117116
118117 // If the cache key does not match the requested node_id, then recompute the children for
@@ -124,12 +123,25 @@ impl LayoutTree for Taffy {
124123 }
125124
126125 // In all cases, return a reference into the cache
127- RefCellVecIter { children : RefMut :: map ( cache, |c| & mut c. children ) , index : 0 }
126+ RefMut :: map ( cache, |c| & mut c. children )
127+ }
128+ }
129+
130+ impl LayoutTree for Taffy {
131+ type ChildIter < ' a > = RefCellVecIter < ' a > ;
132+
133+ #[ inline( always) ]
134+ fn children ( & self , node : NodeId ) -> Self :: ChildIter < ' _ > {
135+ RefCellVecIter { children : self . resolve_children ( node) , index : 0 }
128136 }
129137
130138 #[ inline( always) ]
131139 fn child_count ( & self , node : NodeId ) -> usize {
132- self . children [ node. into ( ) ] . len ( )
140+ self . resolve_children ( node) . len ( )
141+ }
142+ #[ inline( always) ]
143+ fn child ( & self , node : NodeId , id : usize ) -> NodeId {
144+ self . resolve_children ( node) [ id]
133145 }
134146
135147 #[ inline( always) ]
@@ -155,11 +167,6 @@ impl LayoutTree for Taffy {
155167 }
156168 }
157169
158- #[ inline( always) ]
159- fn child ( & self , node : NodeId , id : usize ) -> NodeId {
160- self . children [ node. into ( ) ] [ id]
161- }
162-
163170 #[ inline( always) ]
164171 fn measure_child_size (
165172 & mut self ,
0 commit comments