Browse Source

Explain the algoithm a bit.

pull/1021/head
Steven Kirk 9 years ago
parent
commit
18f9e2840d
  1. 7
      src/Avalonia.Layout/LayoutManager.cs

7
src/Avalonia.Layout/LayoutManager.cs

@ -138,11 +138,18 @@ namespace Avalonia.Layout
private void Measure(ILayoutable control) private void Measure(ILayoutable control)
{ {
// Controls closest to the visual root need to be arranged first. We don't try to store
// ordered invalidation lists, instead we traverse the tree upwards, measuring the
// controls closest to the root first. This has been shown by benchmarks to be the
// fastest and most memory-efficent algorithm.
if (control.VisualParent is ILayoutable parent) if (control.VisualParent is ILayoutable parent)
{ {
Measure(parent); Measure(parent);
} }
// If the control being measured has IsMeasureValid == true here then its measure was
// handed by an ancestor and can be ignored. The measure may have also caused the
// control to be removed.
if (!control.IsMeasureValid && control.IsAttachedToVisualTree) if (!control.IsMeasureValid && control.IsAttachedToVisualTree)
{ {
if (control is ILayoutRoot root) if (control is ILayoutRoot root)

Loading…
Cancel
Save