Closed Bug 1627125 Opened 1 year ago Closed 1 year ago

Extend existing flex container APIs to support flex item fragmentation

Categories

(Core :: Layout: Flexbox, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla77
Tracking Status
firefox77 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

Details

(Whiteboard: [layout:backlog:77])

Attachments

(8 files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

To support flex item fragmentation, some existing and APIs need to be extended.

  1. We need to pass the remaining available block-size to ReflowFlexItem(), and let it output the child's reflow status.
  2. Currently, we run DoFlexLayout in every flex container's fragments to determine content-box's size and final size. We need to change it to run DoFlexLayout in the first fragment, and cache the relevant data for later fragments to use. That means we need to change the way we compute available block-size and flex container's final size.
  3. One tricky aspect is to consider "box-decoration-break: clone", because the property can affect the computation of available block-size and the final size of the flex container.

Conceptually, if we don't support flex item fragmentation, all the flex items act just like an unbreakable child for flex container. With this in mind, I hope to address the above points without breaking existing tests, and lay the foundation for bug 1622935.

Status: NEW → ASSIGNED
Component: Layout → Layout: Flexbox

In a later part, we want to use NS_UNCONSTRAINEDSIZE for
aAvailableBSizeForContent.

Depends on D69470

We want mContentBoxMainSize and mContentBoxCrossSize in
SharedFlexLineData to be the final content-box without regards to
pagination, but it is not correct yet. A later part will pass
NS_UNCONSTRAINEDSIZE as availableBSizeForContent so that DoFlexLayout
can calculate the correct size.

Depends on D69471

The two variable will be used in ComputeFinalSize in a later part.

I follow the C++ Core Guidelines to return multiple value via std::tuple.
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f21-to-return-multiple-out-values-prefer-returning-a-struct-or-tuple

Depends on D69472

By passing unconstrained availableBSizeForContent to DoFlexLayout, we
can get the desired flex container's content-box size as if there's no
pagination. We then use this content-box size and
maxBlockEndEdgeOfChildren to rewrite the logic to determine flex
container's final size.

I still maintain the compatibility with block frame that if the flex
container is running out of block-size, it can still become incomplete
and requesting an zero block-size continuation. One comment in block
frame feel this is wrong, but fixing it is not in the scope of this bug.
https://searchfox.org/mozilla-central/rev/4ccefc3181f9d237ef4ca8bd17b4e7c101ddf7b5/layout/generic/nsBlockFrame.cpp#7715-7718

Depends on D69473

These reftests are copied from flexbox-unbreakable-child-1-.html and
flexbox-unbreakable-child-1-
-wrap.html with "box-decoration-break:
clone" added to the flex container.

Note that flexbox-unbreakable-child-3-ref.html is redesigned. It is not
copied from flexbox-unbreakable-child-1-ref.html with
"box-decoration-break: clone" added because the bottom border doesn't
show up in sub-test 3 & 4. (bug 1564726 perhaps?)

Depends on D69474

Attachment #9137907 - Attachment description: Bug 1627125 Part 4 - Run DoFlexLayout only in first-in-flow, and cache SharedFlexLineData in it. → Bug 1627125 Part 4 - Run DoFlexLayout only in first-in-flow, and cache SharedFlexData in it.
Attachment #9137908 - Attachment description: Bug 1627125 Part 5 - Make ReflowChildren() output maxBlockEndEdgeOfChildren and their completeness. → Bug 1627125 Part 5 - Make ReflowChildren() output children's max block-end edge and completeness.
Attachment #9137910 - Attachment description: Bug 1627125 Part 7 - Add reftests for flex containers with box-decoration-break: clone and unbreakable children. → Bug 1627125 Part 7 - Add reftests for flex containers with "box-decoration-break: clone" and unbreakable children.
  1. Fixed "warning: use 'using' instead of 'typedef'" for OrderState.

  2. Removed FlexItem* item to fix the "warning: Value stored to 'item'
    is never read".

Depends on D69475

Whiteboard: [layout:backlog:77]
Attachment #9137905 - Attachment description: Bug 1627125 Part 2 - Add a helper to compute available content size, and pass the information to ReflowChildren. → Bug 1627125 Part 2 - Add a helper to compute available size for flex items, and pass the information to ReflowChildren.
Attachment #9137907 - Attachment description: Bug 1627125 Part 4 - Run DoFlexLayout only in first-in-flow, and cache SharedFlexData in it. → Bug 1627125 Part 4 - Run DoFlexLayout only in first-in-flow, and store SharedFlexData in it.
Blocks: 1630457
Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/36907dee3e51
Part 1 - Allow ReflowFlexItem to take available size as an input, and output reflow status. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/a8e29df7db26
Part 2 - Add a helper to compute available size for flex items, and pass the information to ReflowChildren. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/c15c24dcc029
Part 3 - Add aColumnWrapThreshold to DoFlexLayout. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/bd29ea94d3bd
Part 4 - Run DoFlexLayout only in first-in-flow, and store SharedFlexData in it. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/994770def1fc
Part 5 - Make ReflowChildren() output children's max block-end edge and completeness. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/c473fe50e3fa
Part 6 - Redesign the logic that computes flex container's final size with "box-decoration-break: clone" considered. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/c1e6d0ce349e
Part 7 - Add reftests for flex containers with "box-decoration-break: clone" and unbreakable children. r=dholbert
https://hg.mozilla.org/integration/autoland/rev/eb275e9ef6d4
Part 8 - Make nsFlexContainerFrame static-analysis warning free. r=dholbert
Regressions: 1681788
You need to log in before you can comment on or make changes to this bug.