Bug 1752658 Part 6 - Pass FlexLayoutResult into ReflowChildren(). r=dholbert

Currently, we pass all the five fields in FlexLayoutResult separately into
ReflowChildren(), but we really should just pass FlexLayoutResult instead.

Differential Revision: https://phabricator.services.mozilla.com/D138100
This commit is contained in:
Ting-Yu Lin 2022-02-08 22:47:20 +00:00
parent 6191c0136b
commit 141dbba00c
2 changed files with 24 additions and 33 deletions

View File

@ -4665,10 +4665,8 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
const LogicalSize availableSizeForItems =
ComputeAvailableSizeForItems(aReflowInput, borderPadding);
const auto [maxBlockEndEdgeOfChildren, areChildrenComplete] = ReflowChildren(
aReflowInput, flr.mContentBoxMainSize, flr.mContentBoxCrossSize,
containerSize, availableSizeForItems, borderPadding,
sumOfChildrenBlockSize, flr.mAscent, flr.mLines, flr.mPlaceholders,
axisTracker, hasLineClampEllipsis);
aReflowInput, containerSize, availableSizeForItems, borderPadding,
sumOfChildrenBlockSize, axisTracker, hasLineClampEllipsis, flr);
// maxBlockEndEdgeOfChildren is relative to border-box, so we need to subtract
// block-start border and padding to make it relative to our content-box. Note
@ -5246,14 +5244,12 @@ nsFlexContainerFrame::FlexLayoutResult nsFlexContainerFrame::DoFlexLayout(
}
std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
const ReflowInput& aReflowInput, const nscoord aContentBoxMainSize,
const nscoord aContentBoxCrossSize, const nsSize& aContainerSize,
const ReflowInput& aReflowInput, const nsSize& aContainerSize,
const LogicalSize& aAvailableSizeForItems,
const LogicalMargin& aBorderPadding,
const nscoord aSumOfPrevInFlowsChildrenBlockSize,
nscoord& aFlexContainerAscent, nsTArray<FlexLine>& aLines,
nsTArray<nsIFrame*>& aPlaceholders, const FlexboxAxisTracker& aAxisTracker,
bool aHasLineClampEllipsis) {
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis,
FlexLayoutResult& aFlr) {
// Before giving each child a final reflow, calculate the origin of the
// flex container's content box (with respect to its border-box), so that
// we can compute our flex item's final positions.
@ -5264,7 +5260,7 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
// If the flex container has no baseline-aligned items, it will use the first
// item to determine its baseline:
const FlexItem* firstItem =
aLines[0].IsEmpty() ? nullptr : &aLines[0].FirstItem();
aFlr.mLines[0].IsEmpty() ? nullptr : &aFlr.mLines[0].FirstItem();
// The block-end of children is relative to the flex container's border-box.
nscoord maxBlockEndEdgeOfChildren = containerContentBoxOrigin.B(flexWM);
@ -5275,11 +5271,11 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
// FINAL REFLOW: Give each child frame another chance to reflow, now that
// we know its final size and position.
for (const FlexLine& line : aLines) {
for (const FlexLine& line : aFlr.mLines) {
for (const FlexItem& item : line.Items()) {
LogicalPoint framePos = aAxisTracker.LogicalPointFromFlexRelativePoint(
item.MainPosition(), item.CrossPosition(), aContentBoxMainSize,
aContentBoxCrossSize);
item.MainPosition(), item.CrossPosition(), aFlr.mContentBoxMainSize,
aFlr.mContentBoxCrossSize);
if (item.Frame()->GetPrevInFlow()) {
// The item is a continuation. Lay it out at the beginning of the
@ -5386,15 +5382,15 @@ std::tuple<nscoord, bool> nsFlexContainerFrame::ReflowChildren(
// the container yet (i.e. if we don't have 'align-self: baseline' on any
// children), then use this child's first baseline as the container's
// baseline.
if (&item == firstItem && aFlexContainerAscent == nscoord_MIN) {
aFlexContainerAscent = itemNormalBPos + item.ResolvedAscent(true);
if (&item == firstItem && aFlr.mAscent == nscoord_MIN) {
aFlr.mAscent = itemNormalBPos + item.ResolvedAscent(true);
}
}
}
if (!aPlaceholders.IsEmpty()) {
ReflowPlaceholders(aReflowInput, aPlaceholders, containerContentBoxOrigin,
aContainerSize);
if (!aFlr.mPlaceholders.IsEmpty()) {
ReflowPlaceholders(aReflowInput, aFlr.mPlaceholders,
containerContentBoxOrigin, aContainerSize);
}
const bool anyChildIncomplete = PushIncompleteChildren(

View File

@ -554,10 +554,6 @@ class nsFlexContainerFrame final : public nsContainerFrame {
/**
* Perform a final Reflow for our child frames.
*
* @param aContentBoxMainSize the final content-box main-size of the flex
* container.
* @param aContentBoxCrossSize the final content-box cross-size of the flex
* container.
* @param aContainerSize this frame's tentative physical border-box size, used
* only for logical to physical coordinate conversion.
* @param aAvailableSizeForItems the size of the available space for our
@ -567,26 +563,25 @@ class nsFlexContainerFrame final : public nsContainerFrame {
* continuation chain).
* @param aSumOfPrevInFlowsChildrenBlockSize See the comment for
* SumOfChildrenBlockSizeProperty.
* @param aFlexContainerAscent [in/out] initially, the "tentative" flex
* container ascent computed in DoFlexLayout; or,
* nscoord_MIN if the ascent hasn't been
* established yet. If the latter, this will be
* updated with an ascent derived from the first
* flex item (if there are any flex items).
* @param aFlr the result returned by DoFlexLayout.
* Note: aFlr is mostly an "input" parameter, but we use
* aFlr.mAscent an "in/out" parameter; it's initially the
* "tentative" flex container ascent computed in DoFlexLayout; or,
* nscoord_MIN if the ascent hasn't been established yet. If the
* latter, this will be updated with an ascent derived from the
* first flex item (if there are any flex items).
* @return nscoord the maximum block-end edge of children of this fragment in
* flex container's coordinate space.
* @return bool true if any child being reflowed is incomplete; false
* otherwise.
*/
std::tuple<nscoord, bool> ReflowChildren(
const ReflowInput& aReflowInput, const nscoord aContentBoxMainSize,
const nscoord aContentBoxCrossSize, const nsSize& aContainerSize,
const ReflowInput& aReflowInput, const nsSize& aContainerSize,
const mozilla::LogicalSize& aAvailableSizeForItems,
const mozilla::LogicalMargin& aBorderPadding,
const nscoord aSumOfPrevInFlowsChildrenBlockSize,
nscoord& aFlexContainerAscent, nsTArray<FlexLine>& aLines,
nsTArray<nsIFrame*>& aPlaceholders,
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis);
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis,
FlexLayoutResult& aFlr);
/**
* Moves the given flex item's frame to the given LogicalPosition (modulo any