Closed Bug 1620490 Opened 2 years ago Closed 2 years ago

Break DoFlexLayout() into smaller pieces

Categories

(Core :: Layout: Flexbox, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

(Blocks 1 open bug)

Details

Attachments

(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

DoFlexLayout(...)
if (restart flex layout) {
  DoFlexLayout(...)
}

ReflowChilden(...)
ComputeFinalSize(...)

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 aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/d74c415aa322
Part 1 - Rename ResolveFlexContainerMainSize to ComputeMainSize, and make it a flex container method. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/d4bda3643a1d
Part 2 - Delete unused SortChildrenIfNeeded() declaration. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/ae1ed37843e9
Part 3 - Export some data computed in DoFlexLayout. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/ae329f32dda9
Part 4 - Move the helper methods that handle ComputedFlexContainerInfo into protected section. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/fdfb108df9e8
Part 5 - Make CreateOrClearFlexContainerInfo() return the container info pointer, and use the pointer in DoFlexLayout. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/7c8aecf26754
Part 6 - Extract the computation of flex container's final size into a helper method. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/25601cd5859a
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.