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

@ -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