Issue #1916 - Part 2: Add a flag to allow FinishReflowChild to handle relative positioning, and convert the caller for which this makes sense.

Backported from Mozilla bug 1547759.
This commit is contained in:
Job Bautista 2022-06-17 19:16:53 +08:00 committed by roytam1
commit 797ddb4d88
4 changed files with 27 additions and 14 deletions

View file

@ -281,7 +281,7 @@ public:
nscoord& Width() { return mWritingMode.IsVertical() ? mBSize : mISize; }
nscoord& Height() { return mWritingMode.IsVertical() ? mISize : mBSize; }
nsSize PhysicalSize()
nsSize PhysicalSize() const
{
return Size(mWritingMode).GetPhysicalSize(mWritingMode);
}

View file

@ -448,16 +448,11 @@ nsBlockReflowContext::PlaceBlock(const ReflowInput& aReflowInput,
ConvertTo(frameWM, mWritingMode,
mContainerSize - mMetrics.PhysicalSize());
// ApplyRelativePositioning in right-to-left writing modes needs to
// know the updated frame width
mFrame->SetSize(mWritingMode, mMetrics.Size(mWritingMode));
aReflowInput.ApplyRelativePositioning(&logPos, mContainerSize);
// Now place the frame and complete the reflow process
nsContainerFrame::FinishReflowChild(mFrame, mPresContext, mMetrics,
&aReflowInput, frameWM, logPos,
mContainerSize,
nsIFrame::ReflowChildFlags::Default);
nsIFrame::ReflowChildFlags::ApplyRelativePositioning);
aOverflowAreas = mMetrics.mOverflowAreas + mFrame->GetPosition();

View file

@ -1190,10 +1190,19 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
WritingMode outerWM = aDesiredSize.GetWritingMode();
LogicalSize convertedSize =
aDesiredSize.Size(outerWM).ConvertTo(aWM, outerWM);
LogicalPoint pos(aPos);
if (aFlags & ReflowChildFlags::ApplyRelativePositioning) {
MOZ_ASSERT(aReflowInput, "caller must have passed reflow input");
// ApplyRelativePositioning in right-to-left writing modes needs to know
// the updated frame width to set the normal position correctly.
aKidFrame->SetSize(aWM, convertedSize);
aReflowInput->ApplyRelativePositioning(&pos, aContainerSize);
}
if (ReflowChildFlags::NoMoveFrame !=
(aFlags & ReflowChildFlags::NoMoveFrame)) {
aKidFrame->SetRect(aWM, LogicalRect(aWM, aPos, convertedSize),
aKidFrame->SetRect(aWM, LogicalRect(aWM, pos, convertedSize),
aContainerSize);
} else {
aKidFrame->SetSize(aWM, convertedSize);
@ -1230,14 +1239,19 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
nscoord aY,
ReflowChildFlags aFlags)
{
MOZ_ASSERT(!(aFlags & ReflowChildFlags::ApplyRelativePositioning),
"only the logical version supports ApplyRelativePositioning "
"since ApplyRelativePositioning requires the container size");
nsPoint curOrigin = aKidFrame->GetPosition();
nsPoint pos(aX, aY);
nsSize size(aDesiredSize.PhysicalSize());
if (ReflowChildFlags::NoMoveFrame !=
(aFlags & ReflowChildFlags::NoMoveFrame)) {
aKidFrame->SetRect(
nsRect(aX, aY, aDesiredSize.Width(), aDesiredSize.Height()));
aKidFrame->SetRect(nsRect(pos, size));
} else {
aKidFrame->SetSize(nsSize(aDesiredSize.Width(), aDesiredSize.Height()));
aKidFrame->SetSize(size);
}
if (aKidFrame->HasView()) {
@ -1248,8 +1262,7 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
aDesiredSize.VisualOverflow(), aFlags);
}
if (!(aFlags & ReflowChildFlags::NoMoveView) &&
(curOrigin.x != aX || curOrigin.y != aY)) {
if (!(aFlags & ReflowChildFlags::NoMoveView) && curOrigin != pos) {
if (!aKidFrame->HasView()) {
// If the frame has moved, then we need to make sure any child views are
// correctly positioned

View file

@ -2247,9 +2247,14 @@ public:
NoMoveFrame = (1 << 1) | NoMoveView,
NoSizeView = 1 << 2,
NoVisibility = 1 << 3,
// Only applies to ReflowChild; if true, don't delete the next-in-flow, even
// if the reflow is fully complete.
NoDeleteNextInFlowChild = 1 << 4
NoDeleteNextInFlowChild = 1 << 4,
// Only applies to FinishReflowChild. Tell it to call
// ApplyRelativePositioning.
ApplyRelativePositioning = 1 << 5
};
/**