Bug 1655608 part 2: Modernize naming of ReflowOutput variables/parameters, throughout nsPage*Frame classes. r=TYLin

Differential Revision: https://phabricator.services.mozilla.com/D85097
This commit is contained in:
Daniel Holbert 2020-07-28 22:11:26 +00:00
parent 441ea15989
commit 9afcc22e25
6 changed files with 52 additions and 47 deletions

View File

@ -23,12 +23,12 @@ nsPageContentFrame* NS_NewPageContentFrame(PresShell* aPresShell,
NS_IMPL_FRAMEARENA_HELPERS(nsPageContentFrame)
void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsPageContentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aReflowOutput, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
MOZ_ASSERT(mPD, "Need a pointer to nsSharedPageData before reflow starts");
@ -58,7 +58,9 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
kidReflowInput.SetComputedBSize(logicalSize.BSize(wm));
// Reflow the page content area
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowInput, 0, 0,
// XXXdholbert It's weird that we're passing down our own aReflowOutput
// outparam to be used for the child frame's reflow here. See bug 1655856.
ReflowChild(frame, aPresContext, aReflowOutput, kidReflowInput, 0, 0,
ReflowChildFlags::Default, aStatus);
// The document element's background should cover the entire canvas, so
@ -77,8 +79,8 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
if (frame->HasOverflowAreas()) {
// The background covers the content area and padding area, so check
// for children sticking outside the child frame's padding edge
nscoord xmost = aDesiredSize.ScrollableOverflow().XMost();
if (xmost > aDesiredSize.Width()) {
nscoord xmost = aReflowOutput.ScrollableOverflow().XMost();
if (xmost > aReflowOutput.Width()) {
nscoord widthToFit =
xmost + padding.right +
kidReflowInput.mStyleBorder->GetComputedBorderWidth(eSideRight);
@ -90,7 +92,7 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
}
// Place and size the child
FinishReflowChild(frame, aPresContext, aDesiredSize, &kidReflowInput, 0, 0,
FinishReflowChild(frame, aPresContext, aReflowOutput, &kidReflowInput, 0, 0,
ReflowChildFlags::Default);
NS_ASSERTION(aPresContext->IsDynamic() || !aStatus.IsFullyComplete() ||
@ -100,19 +102,19 @@ void nsPageContentFrame::Reflow(nsPresContext* aPresContext,
// Reflow our fixed frames
nsReflowStatus fixedStatus;
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, fixedStatus);
ReflowAbsoluteFrames(aPresContext, aReflowOutput, aReflowInput, fixedStatus);
NS_ASSERTION(fixedStatus.IsComplete(),
"fixed frames can be truncated, but not incomplete");
// Return our desired size
WritingMode wm = aReflowInput.GetWritingMode();
aDesiredSize.ISize(wm) = aReflowInput.ComputedISize();
aReflowOutput.ISize(wm) = aReflowInput.ComputedISize();
if (aReflowInput.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
aDesiredSize.BSize(wm) = aReflowInput.ComputedBSize();
aReflowOutput.BSize(wm) = aReflowInput.ComputedBSize();
}
FinishAndStoreOverflow(&aDesiredSize);
FinishAndStoreOverflow(&aReflowOutput);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aReflowOutput);
}
void nsPageContentFrame::AppendDirectlyOwnedAnonBoxes(

View File

@ -26,7 +26,7 @@ class nsPageContentFrame final : public mozilla::ViewportFrame {
friend class nsPageFrame;
// nsIFrame
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
void Reflow(nsPresContext* aPresContext, ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;

View File

@ -45,12 +45,12 @@ nsPageFrame::nsPageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
nsPageFrame::~nsPageFrame() = default;
void nsPageFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsPageFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aReflowOutput, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
MOZ_ASSERT(mPD, "Need a pointer to nsSharedPageData before reflow starts");
@ -83,7 +83,7 @@ void nsPageFrame::Reflow(nsPresContext* aPresContext,
// XXX Shouldn't we do something more friendly when invalid margins
// are set?
if (maxSize.width < onePixelInTwips || maxSize.height < onePixelInTwips) {
aDesiredSize.ClearSize();
aReflowOutput.ClearSize();
NS_WARNING("Reflow aborted; no space for content");
return;
}
@ -135,35 +135,37 @@ void nsPageFrame::Reflow(nsPresContext* aPresContext,
nscoord yc = mPageContentMargin.top;
// Get the child's desired size
ReflowChild(frame, aPresContext, aDesiredSize, kidReflowInput, xc, yc,
// XXXdholbert It's weird that we're passing down our own aReflowOutput
// outparam to be used for the child frame's reflow here. See bug 1655856.
ReflowChild(frame, aPresContext, aReflowOutput, kidReflowInput, xc, yc,
ReflowChildFlags::Default, aStatus);
// Place and size the child
FinishReflowChild(frame, aPresContext, aDesiredSize, &kidReflowInput, xc,
FinishReflowChild(frame, aPresContext, aReflowOutput, &kidReflowInput, xc,
yc, ReflowChildFlags::Default);
NS_ASSERTION(!aStatus.IsFullyComplete() || !frame->GetNextInFlow(),
"bad child flow list");
}
PR_PL(("PageFrame::Reflow %p ", this));
PR_PL(("[%d,%d][%d,%d]\n", aDesiredSize.Width(), aDesiredSize.Height(),
PR_PL(("[%d,%d][%d,%d]\n", aReflowOutput.Width(), aReflowOutput.Height(),
aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
// Return our desired size
WritingMode wm = aReflowInput.GetWritingMode();
aDesiredSize.ISize(wm) = aReflowInput.AvailableISize();
aReflowOutput.ISize(wm) = aReflowInput.AvailableISize();
if (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE) {
aDesiredSize.BSize(wm) = aReflowInput.AvailableBSize();
aReflowOutput.BSize(wm) = aReflowInput.AvailableBSize();
}
aDesiredSize.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aDesiredSize);
aReflowOutput.SetOverflowAreasToDesiredBounds();
FinishAndStoreOverflow(&aReflowOutput);
PR_PL(("PageFrame::Reflow %p ", this));
PR_PL(("[%d,%d]\n", aReflowInput.AvailableWidth(),
aReflowInput.AvailableHeight()));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aReflowOutput);
}
#ifdef DEBUG_FRAME_DUMP
@ -731,11 +733,11 @@ nscoord nsPageBreakFrame::GetIntrinsicISize() {
nscoord nsPageBreakFrame::GetIntrinsicBSize() { return 0; }
void nsPageBreakFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
DO_GLOBAL_REFLOW_COUNT("nsPageBreakFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aReflowOutput, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
// Override reflow, since we don't want to deal with what our
@ -768,7 +770,7 @@ void nsPageBreakFrame::Reflow(nsPresContext* aPresContext,
// XXX(mats) why???
finalSize.BSize(wm) -=
finalSize.BSize(wm) % nsPresContext::CSSPixelsToAppUnits(1);
aDesiredSize.SetSize(wm, finalSize);
aReflowOutput.SetSize(wm, finalSize);
// Note: not using NS_FRAME_FIRST_REFLOW here, since it's not clear whether
// DidReflow will always get called before the next Reflow() call.

View File

@ -26,7 +26,7 @@ class nsPageFrame final : public nsContainerFrame {
friend nsPageFrame* NS_NewPageFrame(mozilla::PresShell* aPresShell,
ComputedStyle* aStyle);
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
void Reflow(nsPresContext* aPresContext, ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;
@ -102,7 +102,7 @@ class nsPageBreakFrame final : public nsLeafFrame {
explicit nsPageBreakFrame(ComputedStyle* aStyle, nsPresContext* aPresContext);
~nsPageBreakFrame();
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
void Reflow(nsPresContext* aPresContext, ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;

View File

@ -94,7 +94,7 @@ float nsPageSequenceFrame::GetPrintPreviewScale() const {
}
void nsPageSequenceFrame::PopulateReflowOutput(
ReflowOutput& aDesiredSize, const ReflowInput& aReflowInput) {
ReflowOutput& aReflowOutput, const ReflowInput& aReflowInput) {
// Aim to fill the whole available space, not only so we can act as a
// background in print preview but also handle overflow in child page frames
// correctly.
@ -105,11 +105,11 @@ void nsPageSequenceFrame::PopulateReflowOutput(
nscoord iSize = wm.IsVertical() ? mSize.Height() : mSize.Width();
nscoord bSize = wm.IsVertical() ? mSize.Width() : mSize.Height();
aDesiredSize.ISize(wm) =
aReflowOutput.ISize(wm) =
std::max(NSToCoordFloor(iSize * scale), aReflowInput.AvailableISize());
aDesiredSize.BSize(wm) =
aReflowOutput.BSize(wm) =
std::max(NSToCoordFloor(bSize * scale), aReflowInput.ComputedBSize());
aDesiredSize.SetOverflowAreasToDesiredBounds();
aReflowOutput.SetOverflowAreasToDesiredBounds();
}
// Helper function to compute the offset needed to center a child
@ -152,14 +152,14 @@ nscoord nsPageSequenceFrame::ComputeCenteringMargin(
* arranged in the same orientation, regardless of writing mode.
*/
void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
ReflowOutput& aDesiredSize,
ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) {
MarkInReflow();
MOZ_ASSERT(aPresContext->IsRootPaginatedDocument(),
"A Page Sequence is only for real pages");
DO_GLOBAL_REFLOW_COUNT("nsPageSequenceFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aReflowOutput, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
NS_FRAME_TRACE_REFLOW_IN("nsPageSequenceFrame::Reflow");
@ -182,10 +182,10 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
// it right in paginated mode.
if (!HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) {
// Return our desired size
PopulateReflowOutput(aDesiredSize, aReflowInput);
FinishAndStoreOverflow(&aDesiredSize);
PopulateReflowOutput(aReflowOutput, aReflowInput);
FinishAndStoreOverflow(&aReflowOutput);
if (GetSize().Width() != aDesiredSize.Width()) {
if (GetSize().Width() != aReflowOutput.Width()) {
CenterPages();
}
return;
@ -245,7 +245,7 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
nscoord maxXMost = 0;
// Tile the pages vertically
ReflowOutput kidSize(aReflowInput);
ReflowOutput kidReflowOutput(aReflowInput);
for (nsIFrame* kidFrame : mFrames) {
// Set the shared data into the page frame before reflow
auto* pf = static_cast<nsPageFrame*>(kidFrame);
@ -268,15 +268,16 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
nscoord x = pageCSSMargin.left;
// Place and size the page.
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowInput, x, y,
ReflowChild(kidFrame, aPresContext, kidReflowOutput, kidReflowInput, x, y,
ReflowChildFlags::Default, status);
FinishReflowChild(kidFrame, aPresContext, kidSize, &kidReflowInput, x, y,
ReflowChildFlags::Default);
y += kidSize.Height();
FinishReflowChild(kidFrame, aPresContext, kidReflowOutput, &kidReflowInput,
x, y, ReflowChildFlags::Default);
y += kidReflowOutput.Height();
y += pageCSSMargin.bottom;
maxXMost = std::max(maxXMost, x + kidSize.Width() + pageCSSMargin.right);
maxXMost =
std::max(maxXMost, x + kidReflowOutput.Width() + pageCSSMargin.right);
// Is the page complete?
nsIFrame* kidNextInFlow = kidFrame->GetNextInFlow();
@ -325,15 +326,15 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
// Return our desired size
// Adjust the reflow size by PrintPreviewScale so the scrollbars end up the
// correct size
PopulateReflowOutput(aDesiredSize, aReflowInput);
PopulateReflowOutput(aReflowOutput, aReflowInput);
FinishAndStoreOverflow(&aDesiredSize);
FinishAndStoreOverflow(&aReflowOutput);
// Now center our pages.
CenterPages();
NS_FRAME_TRACE_REFLOW_OUT("nsPageSequenceFrame::Reflow", aStatus);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aReflowOutput);
}
//----------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ class nsPageSequenceFrame final : public nsContainerFrame {
NS_DECL_FRAMEARENA_HELPERS(nsPageSequenceFrame)
// nsIFrame
void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
void Reflow(nsPresContext* aPresContext, ReflowOutput& aReflowOutput,
const ReflowInput& aReflowInput,
nsReflowStatus& aStatus) override;