Fix memory leak in flow tree by adding weak refs.

Cycles were being created in the flow tree since absolutely positioned
descendants had pointers to their containing blocks. This adds
WeakFlowRef (based on Weak<T>) and makes these backpointers weak
references. This also harmonizes our custom Arc<T>, FlowRef, to be
consistent with the upstream implementation.

Fixes #4915.
This commit is contained in:
Jack Moffitt 2015-03-12 16:32:49 -06:00
parent 660ea05ddb
commit 237150fa49
4 changed files with 147 additions and 18 deletions

View file

@ -804,8 +804,12 @@ impl LayoutTask {
}
if needs_reflow {
self.try_get_layout_root(*node).map(
|mut flow| LayoutTask::reflow_all_nodes(&mut *flow));
match self.try_get_layout_root(*node) {
None => {}
Some(mut flow) => {
LayoutTask::reflow_all_nodes(&mut *flow);
}
}
}
// Create a layout context for use throughout the following passes.