@@ -108,11 +108,10 @@ fn find_children_recursive(tree: &Taffy, node: NodeId, out: &mut Vec<NodeId>) {
108
108
}
109
109
}
110
110
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 > > {
116
115
let mut cache = self . node_children_cache . borrow_mut ( ) ;
117
116
118
117
// If the cache key does not match the requested node_id, then recompute the children for
@@ -124,12 +123,25 @@ impl LayoutTree for Taffy {
124
123
}
125
124
126
125
// 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 }
128
136
}
129
137
130
138
#[ inline( always) ]
131
139
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]
133
145
}
134
146
135
147
#[ inline( always) ]
@@ -155,11 +167,6 @@ impl LayoutTree for Taffy {
155
167
}
156
168
}
157
169
158
- #[ inline( always) ]
159
- fn child ( & self , node : NodeId , id : usize ) -> NodeId {
160
- self . children [ node. into ( ) ] [ id]
161
- }
162
-
163
170
#[ inline( always) ]
164
171
fn measure_child_size (
165
172
& mut self ,
0 commit comments