summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJob Bautista <jobbautista9@protonmail.com>2022-06-17 19:16:53 +0800
committerJob Bautista <jobbautista9@protonmail.com>2022-06-17 19:16:53 +0800
commit9842b6054c098fc686c745a7ce2845362fd5bacb (patch)
tree8ff7c4de77164b8a060fe27f9efb9c61e03b2a9d
parentb3cacb2c3ac849f70a2746b252fe0874ffe41e33 (diff)
downloaduxp-9842b6054c098fc686c745a7ce2845362fd5bacb.tar.gz
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.
-rw-r--r--layout/generic/ReflowOutput.h2
-rw-r--r--layout/generic/nsBlockReflowContext.cpp7
-rw-r--r--layout/generic/nsContainerFrame.cpp25
-rw-r--r--layout/generic/nsIFrame.h7
4 files changed, 27 insertions, 14 deletions
diff --git a/layout/generic/ReflowOutput.h b/layout/generic/ReflowOutput.h
index 9877ed6fac..ff1afde2ae 100644
--- a/layout/generic/ReflowOutput.h
+++ b/layout/generic/ReflowOutput.h
@@ -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);
}
diff --git a/layout/generic/nsBlockReflowContext.cpp b/layout/generic/nsBlockReflowContext.cpp
index 494b893917..775f41a044 100644
--- a/layout/generic/nsBlockReflowContext.cpp
+++ b/layout/generic/nsBlockReflowContext.cpp
@@ -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();
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp
index 21033152b3..6af2db5c70 100644
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1187,10 +1187,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);
@@ -1227,14 +1236,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()) {
@@ -1245,8 +1259,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
diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h
index 89557a1e35..be439dbdc2 100644
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -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
};
/**