Browse Source

Explain the algoithm a bit.

Steven Kirk 8 years ago
parent
commit
18f9e2840d
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/Avalonia.Layout/LayoutManager.cs

+ 7 - 0
src/Avalonia.Layout/LayoutManager.cs

@@ -138,11 +138,18 @@ namespace Avalonia.Layout
 
         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)
             {
                 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 is ILayoutRoot root)