Closed Bug 1620490 Opened 2 years ago Closed 2 years ago

Break DoFlexLayout() into smaller pieces


(Core :: Layout: Flexbox, task)

Not set



Tracking Status
firefox76 --- fixed


(Reporter: TYLin, Assigned: TYLin)


(Blocks 1 open bug)



(7 files)

Currently, DoFlexLayout() roughly does three things in the following order.

  1. Runs the flex layout algorithm, generates flex lines and flex items, and computes all the information.
  2. Performs the final reflow for all children based on the data in step 1.
  3. Computes flex container's final size based on data in step 1 and 2.

I'd like to extract step 2 and step 3 into some helpers. When the flex container needs to split, the data computed in step 1 might need not be computed again in the flex container's continuations.

In doing so, this part of the flex container's Reflow() will be more like

if (restart flex layout) {


For two reasons,

  1. Change the naming to make it consistent with ComputeCrossSize.

  2. Make it a flex container methods because it likely needs to call
    nsSplittableFrame::GetEffectiveComputedBSize() later when we consider
    fragmentation. If not, it doesn't harm anyway.

This is a preparation patch for a later part. I want to extract the
computation of flex container's ReflowOutput into a helper method, and
call the helper in Reflow().

Depends on D65779

They are helpers for DoFlexLayout, which don't need to be public.

Depends on D65780

Also, move UpdateFlexLineAndItemInfo() from the end of DoFlexLayout() to
the end of Reflow() because I'm going to extract the computation of
final size of flex container into a helper method in a later patch, and
call it Reflow() just after DoFlexLayout().

Depends on D65782

Also, remove unused ReflowOutput from DoFlexLayout's argument.

Depends on D65783

Thanks for doing this!

Attachment #9131548 - Attachment description: Bug 1620490 Part 6 - Extract the computation of flex container's final size into a helper methods. → Bug 1620490 Part 6 - Extract the computation of flex container's final size into a helper method.
Pushed by
Part 1 - Rename ResolveFlexContainerMainSize to ComputeMainSize, and make it a flex container method. r=dholbert
Part 2 - Delete unused SortChildrenIfNeeded() declaration. r=dholbert
Part 3 - Export some data computed in DoFlexLayout. r=dholbert
Part 4 - Move the helper methods that handle ComputedFlexContainerInfo into protected section. r=dholbert
Part 5 - Make CreateOrClearFlexContainerInfo() return the container info pointer, and use the pointer in DoFlexLayout. r=dholbert
Part 6 - Extract the computation of flex container's final size into a helper method. r=dholbert
Part 7 - Extract the final reflow for flex container's children into a method. r=dholbert
You need to log in before you can comment on or make changes to this bug.