Bug 1620490 Part 7 - Extract the final reflow for flex container's children into a method. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D65785

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ting-Yu Lin 2020-03-09 23:25:44 +00:00
Родитель cd5cae1129
Коммит 45bbeae4cc
2 изменённых файлов: 44 добавлений и 12 удалений

Просмотреть файл

@ -4207,21 +4207,27 @@ void nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
AutoCleanLinkedList<FlexLine> lines;
AutoTArray<StrutInfo, 1> struts;
AutoTArray<nsIFrame*, 1> placeholders;
DoFlexLayout(aReflowInput, aStatus, contentBoxMainSize, contentBoxCrossSize,
flexContainerAscent, availableBSizeForContent, lines, struts,
axisTracker, mainGapSize, crossGapSize, hasLineClampEllipsis,
containerInfo);
placeholders, axisTracker, mainGapSize, crossGapSize,
hasLineClampEllipsis, containerInfo);
if (!struts.IsEmpty()) {
// We're restarting flex layout, with new knowledge of collapsed items.
aStatus.Reset();
lines.clear();
placeholders.Clear();
DoFlexLayout(aReflowInput, aStatus, contentBoxMainSize, contentBoxCrossSize,
flexContainerAscent, availableBSizeForContent, lines, struts,
axisTracker, mainGapSize, crossGapSize, hasLineClampEllipsis,
containerInfo);
placeholders, axisTracker, mainGapSize, crossGapSize,
hasLineClampEllipsis, containerInfo);
}
ReflowChildren(aReflowInput, contentBoxMainSize, contentBoxCrossSize,
flexContainerAscent, lines, placeholders, axisTracker,
hasLineClampEllipsis);
ComputeFinalSize(aDesiredSize, aReflowInput, aStatus, contentBoxMainSize,
contentBoxCrossSize, flexContainerAscent, lines,
axisTracker);
@ -4554,18 +4560,17 @@ void nsFlexContainerFrame::DoFlexLayout(
nscoord& aContentBoxMainSize, nscoord& aContentBoxCrossSize,
nscoord& aFlexContainerAscent, nscoord aAvailableBSizeForContent,
LinkedList<FlexLine>& aLines, nsTArray<StrutInfo>& aStruts,
const FlexboxAxisTracker& aAxisTracker, nscoord aMainGapSize,
nscoord aCrossGapSize, bool aHasLineClampEllipsis,
nsTArray<nsIFrame*>& aPlaceholders, const FlexboxAxisTracker& aAxisTracker,
nscoord aMainGapSize, nscoord aCrossGapSize, bool aHasLineClampEllipsis,
ComputedFlexContainerInfo* const aContainerInfo) {
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
MOZ_ASSERT(aLines.isEmpty(), "Caller should pass an empty line-list!");
nsTArray<nsIFrame*> placeholderKids;
MOZ_ASSERT(aPlaceholders.IsEmpty(),
"Caller should pass an empty array for placeholders!");
GenerateFlexLines(aReflowInput, aContentBoxMainSize,
aAvailableBSizeForContent, aStruts, aAxisTracker,
aMainGapSize, aHasLineClampEllipsis, placeholderKids,
aLines);
aMainGapSize, aHasLineClampEllipsis, aPlaceholders, aLines);
if ((aLines.getFirst()->IsEmpty() && !aLines.getFirst()->getNext()) ||
aReflowInput.mStyleDisplay->IsContainLayout()) {
@ -4772,7 +4777,13 @@ void nsFlexContainerFrame::DoFlexLayout(
aContentBoxCrossSize, aReflowInput, aAxisTracker);
}
}
}
void nsFlexContainerFrame::ReflowChildren(
const ReflowInput& aReflowInput, const nscoord aContentBoxMainSize,
const nscoord aContentBoxCrossSize, nscoord& aFlexContainerAscent,
mozilla::LinkedList<FlexLine>& aLines, nsTArray<nsIFrame*>& aPlaceholders,
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis) {
// 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.
@ -4889,8 +4900,8 @@ void nsFlexContainerFrame::DoFlexLayout(
}
}
if (!placeholderKids.IsEmpty()) {
ReflowPlaceholders(aReflowInput, placeholderKids, containerContentBoxOrigin,
if (!aPlaceholders.IsEmpty()) {
ReflowPlaceholders(aReflowInput, aPlaceholders, containerContentBoxOrigin,
containerSize);
}
}

Просмотреть файл

@ -279,6 +279,7 @@ class nsFlexContainerFrame final : public nsContainerFrame {
nscoord aAvailableBSizeForContent,
mozilla::LinkedList<FlexLine>& aLines,
nsTArray<StrutInfo>& aStruts,
nsTArray<nsIFrame*>& aPlaceholders,
const FlexboxAxisTracker& aAxisTracker,
nscoord aMainGapSize, nscoord aCrossGapSize,
bool aHasLineClampEllipsis,
@ -450,6 +451,26 @@ class nsFlexContainerFrame final : public nsContainerFrame {
mozilla::LinkedList<FlexLine>& aLines,
const FlexboxAxisTracker& aAxisTracker);
/**
* 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 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).
*/
void ReflowChildren(
const ReflowInput& aReflowInput, const nscoord aContentBoxMainSize,
const nscoord aContentBoxCrossSize, nscoord& aFlexContainerAscent,
mozilla::LinkedList<FlexLine>& aLines, nsTArray<nsIFrame*>& aPlaceholders,
const FlexboxAxisTracker& aAxisTracker, bool aHasLineClampEllipsis);
/**
* Moves the given flex item's frame to the given LogicalPosition (modulo any
* relative positioning).