Bug 1627125 Part 1 - Allow ReflowFlexItem to take available size as an input, and output reflow status. r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D69469
This commit is contained in:
Ting-Yu Lin 2020-04-16 05:37:45 +00:00
Родитель 97ea0f945d
Коммит 474e6992c6
3 изменённых файлов: 41 добавлений и 24 удалений

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

@ -758,8 +758,9 @@ struct ReflowInput : public SizeComputationInput {
* @param aPresContext Must be equal to aFrame->PresContext().
* @param aFrame The frame for whose reflow input is being constructed.
* @param aRenderingContext The rendering context to be used for measurements.
* @param aAvailableSpace See comments for availableHeight and availableWidth
* members.
* @param aAvailableSpace The available space to reflow aFrame (in aFrame's
* writing-mode). See comments for mAvailableHeight and mAvailableWidth
* members for more information.
* @param aFlags A set of flags used for additional boolean parameters (see
* below).
*/
@ -775,8 +776,9 @@ struct ReflowInput : public SizeComputationInput {
* @param aParentReflowInput A reference to an ReflowInput object that
* is to be the parent of this object.
* @param aFrame The frame for whose reflow input is being constructed.
* @param aAvailableSpace See comments for availableHeight and availableWidth
* members.
* @param aAvailableSpace The available space to reflow aFrame (in aFrame's
* writing-mode). See comments for mAvailableHeight and mAvailableWidth
* members for more information.
* @param aContainingBlockSize An optional size, in app units, specifying
* the containing block size to use instead of the default which is
* computed by ComputeContainingBlockRectangle().

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

@ -4856,8 +4856,25 @@ void nsFlexContainerFrame::ReflowChildren(
// to clear out a -webkit-line-clamp ellipsis, we can just reposition it
// as-needed.
if (item.NeedsFinalReflow()) {
// The available size must be in item's writing-mode.
const WritingMode itemWM = item.GetWritingMode();
LogicalSize availableSize = aReflowInput.ComputedSize(itemWM);
// XXX: Unconditionally give our children unconstrained block-size until
// we support flex item fragmentation.
availableSize.BSize(itemWM) = NS_UNCONSTRAINEDSIZE;
const nsReflowStatus childReflowStatus =
ReflowFlexItem(aAxisTracker, aReflowInput, item, framePos,
containerSize, aHasLineClampEllipsis);
availableSize, containerSize, aHasLineClampEllipsis);
// XXXdholbert Once we do pagination / splitting, we'll need to actually
// handle incomplete childReflowStatuses. But for now, we give our kids
// unconstrained available height, which means they should always
// complete.
MOZ_ASSERT(childReflowStatus.IsComplete(),
"We gave flex item unconstrained available height, so it "
"should be complete");
} else {
MoveFlexItemToFinalPosition(aReflowInput, item, framePos,
containerSize);
@ -5026,16 +5043,14 @@ void nsFlexContainerFrame::MoveFlexItemToFinalPosition(
PositionChildViews(aItem.Frame());
}
void nsFlexContainerFrame::ReflowFlexItem(
nsReflowStatus nsFlexContainerFrame::ReflowFlexItem(
const FlexboxAxisTracker& aAxisTracker, const ReflowInput& aReflowInput,
const FlexItem& aItem, LogicalPoint& aFramePos,
const nsSize& aContainerSize, bool aHasLineClampEllipsis) {
const LogicalSize& aAvailableSize, const nsSize& aContainerSize,
bool aHasLineClampEllipsis) {
WritingMode outerWM = aReflowInput.GetWritingMode();
WritingMode wm = aItem.Frame()->GetWritingMode();
LogicalSize availSize = aReflowInput.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
ReflowInput childReflowInput(PresContext(), aReflowInput, aItem.Frame(),
availSize);
aAvailableSize);
childReflowInput.mFlags.mInsideLineClamp = GetLineClampValue() != 0;
// This is the final reflow of this flex item; if we previously had a
// -webkit-line-clamp, and we missed our chance to clear the ellipsis
@ -5124,19 +5139,13 @@ void nsFlexContainerFrame::ReflowFlexItem(
// XXXdholbert Perhaps we should call CheckForInterrupt here; see bug 1495532.
// XXXdholbert Once we do pagination / splitting, we'll need to actually
// handle incomplete childReflowStatuses. But for now, we give our kids
// unconstrained available height, which means they should always
// complete.
MOZ_ASSERT(childReflowStatus.IsComplete(),
"We gave flex item unconstrained available height, so it "
"should be complete");
FinishReflowChild(aItem.Frame(), PresContext(), childReflowOutput,
&childReflowInput, outerWM, aFramePos, aContainerSize,
ReflowChildFlags::ApplyRelativePositioning);
aItem.SetAscent(childReflowOutput.BlockStartAscent());
return childReflowStatus;
}
void nsFlexContainerFrame::ReflowPlaceholders(

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

@ -502,13 +502,19 @@ class nsFlexContainerFrame final : public nsContainerFrame {
* @param aItem The flex item to be reflowed.
* @param aFramePos The position where the flex item's frame should
* be placed. (pre-relative positioning)
* @param aAvailableSize The available size to reflow the child frame (in the
* child frame's writing-mode).
* @param aContainerSize The flex container's size (required by some methods
* that we call, to interpret aFramePos correctly).
* @return the child frame's reflow status.
*/
void ReflowFlexItem(const FlexboxAxisTracker& aAxisTracker,
const ReflowInput& aReflowInput, const FlexItem& aItem,
nsReflowStatus ReflowFlexItem(const FlexboxAxisTracker& aAxisTracker,
const ReflowInput& aReflowInput,
const FlexItem& aItem,
mozilla::LogicalPoint& aFramePos,
const nsSize& aContainerSize, bool aHasLineClampEllipsis);
const mozilla::LogicalSize& aAvailableSize,
const nsSize& aContainerSize,
bool aHasLineClampEllipsis);
/**
* Helper-function to perform a "dummy reflow" on all our nsPlaceholderFrame