How do `Limits` work in `layout`?

I created a widget to lay out widgets in a grid and I would like to add the option to dynamically stretch the grid when there is more space available, similar to the built-in Row and Column containers. Moreover, I want to support child widgets that themselves try to take up more space. I’m struggling to wrap my head around how the layout algorithm works regarding the Limits argument to Widget::Layout and how this work together with the Length options.

  1. What does the fill field of Limits do?
  2. The min fields seems to always be Size { width: 0.0, height: 0.0}. What is the effect of this? Do I need to set this value? I can only calculate the minimum size of the grid after I’ve measured all the children but to measure the children I need to supply the limits so that’s a circular dependency.
  3. Lots of widgets have this line at the top of their layout implementation:
let limits = limits.width(self.width).height(self.height);

Why is this necessary?