Bug 1547759 - Add a flag to allow FinishReflowChild to handle relative positioning, and convert the caller for which this makes sense. r=jfkthame

Note that this changes the writing mode used for the SetSize call from
the parent's to the child's.  (This controls what position is kept
constant.)  I don't think this changes behavior at all, since there is
(for this caller) a SetRect call just below.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
L. David Baron 2019-08-05 11:56:05 +00:00
parent c923b062b3
commit b4137c33ae
4 changed files with 27 additions and 14 deletions

View File

@ -245,7 +245,7 @@ class ReflowOutput {
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

@ -436,15 +436,10 @@ bool 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);
mContainerSize, nsIFrame::ReflowChildFlags::ApplyRelativePositioning);
aOverflowAreas = mMetrics.mOverflowAreas + mFrame->GetPosition();

View File

@ -1041,10 +1041,19 @@ void nsContainerFrame::FinishReflowChild(
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);
@ -1081,14 +1090,19 @@ void nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
const ReflowInput* aReflowInput,
nscoord aX, 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()) {
@ -1099,8 +1113,7 @@ void 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

@ -2551,9 +2551,14 @@ class nsIFrame : public nsQueryFrame {
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
};
/**