Bug 1622008 Part 3 - Remove nsPresContext* and PresShell* from the argument list of some continuing-frame-creation methods. r=dholbert

Both PresShell() and PresContext() are cached in nsIFrame. This
simplifies the setup for the callers to
nsCSSFrameConstructor::CreateContinuingFrame().

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ting-Yu Lin 2020-03-12 21:50:23 +00:00
Родитель fede1a91ef
Коммит afe9123179
16 изменённых файлов: 56 добавлений и 84 удалений

Просмотреть файл

@ -611,8 +611,7 @@ static bool IsBidiLeaf(nsIFrame* aFrame) {
*/
static void SplitInlineAncestors(nsContainerFrame* aParent,
nsLineList::iterator aLine, nsIFrame* aFrame) {
nsPresContext* presContext = aParent->PresContext();
PresShell* presShell = presContext->PresShell();
PresShell* presShell = aParent->PresShell();
nsIFrame* frame = aFrame;
nsContainerFrame* parent = aParent;
nsContainerFrame* newParent;
@ -627,7 +626,7 @@ static void SplitInlineAncestors(nsContainerFrame* aParent,
if (!frame || frame->GetNextSibling()) {
newParent = static_cast<nsContainerFrame*>(
presShell->FrameConstructor()->CreateContinuingFrame(
presContext, parent, grandparent, false));
parent, grandparent, false));
nsFrameList tail = parent->StealFramesAfter(frame);
@ -740,13 +739,13 @@ static void CreateContinuation(nsIFrame* aFrame,
// of the text that the first letter frame was made out of.
if (parent->IsLetterFrame() && parent->IsFloating()) {
nsFirstLetterFrame* letterFrame = do_QueryFrame(parent);
letterFrame->CreateContinuationForFloatingParent(presContext, aFrame,
aNewFrame, aIsFluid);
letterFrame->CreateContinuationForFloatingParent(aFrame, aNewFrame,
aIsFluid);
return;
}
*aNewFrame = presShell->FrameConstructor()->CreateContinuingFrame(
presContext, aFrame, parent, aIsFluid);
aFrame, parent, aIsFluid);
// The list name kNoReflowPrincipalList would indicate we don't want reflow
// XXXbz this needs higher-level framelist love

Просмотреть файл

@ -7832,8 +7832,7 @@ void nsCSSFrameConstructor::GetAlternateTextFor(Element* aElement, nsAtom* aTag,
}
nsIFrame* nsCSSFrameConstructor::CreateContinuingOuterTableFrame(
PresShell* aPresShell, nsPresContext* aPresContext, nsIFrame* aFrame,
nsContainerFrame* aParentFrame, nsIContent* aContent,
nsIFrame* aFrame, nsContainerFrame* aParentFrame, nsIContent* aContent,
ComputedStyle* aComputedStyle) {
nsTableWrapperFrame* newFrame =
NS_NewTableWrapperFrame(mPresShell, aComputedStyle);
@ -7847,7 +7846,7 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingOuterTableFrame(
nsIFrame* childFrame = aFrame->PrincipalChildList().FirstChild();
if (childFrame) {
nsIFrame* continuingTableFrame =
CreateContinuingFrame(aPresContext, childFrame, newFrame);
CreateContinuingFrame(childFrame, newFrame);
newChildFrames.AppendFrame(nullptr, continuingTableFrame);
NS_ASSERTION(!childFrame->GetNextSibling(),
@ -7861,8 +7860,8 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingOuterTableFrame(
}
nsIFrame* nsCSSFrameConstructor::CreateContinuingTableFrame(
PresShell* aPresShell, nsIFrame* aFrame, nsContainerFrame* aParentFrame,
nsIContent* aContent, ComputedStyle* aComputedStyle) {
nsIFrame* aFrame, nsContainerFrame* aParentFrame, nsIContent* aContent,
ComputedStyle* aComputedStyle) {
nsTableFrame* newFrame = NS_NewTableFrame(mPresShell, aComputedStyle);
newFrame->Init(aContent, aParentFrame, aFrame);
@ -7920,8 +7919,7 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingTableFrame(
}
nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
nsPresContext* aPresContext, nsIFrame* aFrame,
nsContainerFrame* aParentFrame, bool aIsFluid) {
nsIFrame* aFrame, nsContainerFrame* aParentFrame, bool aIsFluid) {
ComputedStyle* computedStyle = aFrame->Style();
nsIFrame* newFrame = nullptr;
nsIFrame* nextContinuation = aFrame->GetNextContinuation();
@ -7961,13 +7959,11 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
newFrame =
ConstructPageFrame(mPresShell, aParentFrame, aFrame, canvasFrame);
} else if (LayoutFrameType::TableWrapper == frameType) {
newFrame = CreateContinuingOuterTableFrame(
mPresShell, aPresContext, aFrame, aParentFrame, content, computedStyle);
newFrame = CreateContinuingOuterTableFrame(aFrame, aParentFrame, content,
computedStyle);
} else if (LayoutFrameType::Table == frameType) {
newFrame = CreateContinuingTableFrame(mPresShell, aFrame, aParentFrame,
content, computedStyle);
newFrame = CreateContinuingTableFrame(aFrame, aParentFrame, content,
computedStyle);
} else if (LayoutFrameType::TableRowGroup == frameType) {
newFrame = NS_NewTableRowGroupFrame(mPresShell, computedStyle);
newFrame->Init(content, aParentFrame, aFrame);
@ -7989,7 +7985,7 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
// See if it's a table cell frame
if (cellFrame->IsTableCellFrame()) {
nsIFrame* continuingCellFrame =
CreateContinuingFrame(aPresContext, cellFrame, rowFrame);
CreateContinuingFrame(cellFrame, rowFrame);
newChildList.AppendFrame(nullptr, continuingCellFrame);
}
cellFrame = cellFrame->GetNextSibling();
@ -8014,8 +8010,8 @@ nsIFrame* nsCSSFrameConstructor::CreateContinuingFrame(
// Create a continuing area frame
nsIFrame* blockFrame = aFrame->PrincipalChildList().FirstChild();
nsIFrame* continuingBlockFrame = CreateContinuingFrame(
aPresContext, blockFrame, static_cast<nsContainerFrame*>(cellFrame));
nsIFrame* continuingBlockFrame =
CreateContinuingFrame(blockFrame, cellFrame);
SetInitialSingleChild(cellFrame, continuingBlockFrame);
newFrame = cellFrame;
@ -9940,8 +9936,7 @@ nsFirstLetterFrame* nsCSSFrameConstructor::CreateFloatingLetterFrame(
nsIFrame* nextTextFrame = nullptr;
if (NeedFirstLetterContinuation(aTextContent)) {
// Create continuation
nextTextFrame =
CreateContinuingFrame(aState.mPresContext, aTextFrame, aParentFrame);
nextTextFrame = CreateContinuingFrame(aTextFrame, aParentFrame);
RefPtr<ComputedStyle> newSC =
styleSet->ResolveStyleForText(aTextContent, aParentComputedStyle);
nextTextFrame->SetComputedStyle(newSC);
@ -10638,8 +10633,7 @@ void nsCSSFrameConstructor::FinishBuildingColumns(
finalList.AppendFrame(aColumnSetWrapper, f);
} else {
auto* continuingColumnSet = static_cast<nsContainerFrame*>(
CreateContinuingFrame(mPresShell->GetPresContext(), prevColumnSet,
aColumnSetWrapper, false));
CreateContinuingFrame(prevColumnSet, aColumnSetWrapper, false));
MOZ_ASSERT(continuingColumnSet->HasColumnSpanSiblings(),
"The bit should propagate to the next continuation!");
@ -10722,8 +10716,7 @@ nsFrameList nsCSSFrameConstructor::CreateColumnSpanSiblings(
// Grab the consecutive non-column-span kids, and reparent them into a new
// continuation of the last non-column-span wrapper frame.
auto* nonColumnSpanWrapper = static_cast<nsContainerFrame*>(
CreateContinuingFrame(mPresShell->GetPresContext(),
lastNonColumnSpanWrapper, parentFrame, false));
CreateContinuingFrame(lastNonColumnSpanWrapper, parentFrame, false));
nonColumnSpanWrapper->AddStateBits(NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR |
NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
MOZ_ASSERT(nonColumnSpanWrapper->HasColumnSpanSiblings(),

Просмотреть файл

@ -315,7 +315,7 @@ class nsCSSFrameConstructor final : public nsFrameManager {
bool DestroyFramesFor(Element* aElement);
// Request to create a continuing frame. This method never returns null.
nsIFrame* CreateContinuingFrame(nsPresContext* aPresContext, nsIFrame* aFrame,
nsIFrame* CreateContinuingFrame(nsIFrame* aFrame,
nsContainerFrame* aParentFrame,
bool aIsFluid = true);
@ -1672,14 +1672,12 @@ class nsCSSFrameConstructor final : public nsFrameManager {
// not null).
bool MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame);
nsIFrame* CreateContinuingOuterTableFrame(PresShell* aPresShell,
nsPresContext* aPresContext,
nsIFrame* aFrame,
nsIFrame* CreateContinuingOuterTableFrame(nsIFrame* aFrame,
nsContainerFrame* aParentFrame,
nsIContent* aContent,
ComputedStyle* aComputedStyle);
nsIFrame* CreateContinuingTableFrame(PresShell* aPresShell, nsIFrame* aFrame,
nsIFrame* CreateContinuingTableFrame(nsIFrame* aFrame,
nsContainerFrame* aParentFrame,
nsIContent* aContent,
ComputedStyle* aComputedStyle);

Просмотреть файл

@ -894,9 +894,8 @@ void nsFieldSetFrame::EnsureChildContinuation(nsIFrame* aChild,
} else {
nsFrameList nifs;
if (!nif) {
auto* pc = PresContext();
auto* fc = pc->PresShell()->FrameConstructor();
nif = fc->CreateContinuingFrame(pc, aChild, this);
auto* fc = PresShell()->FrameConstructor();
nif = fc->CreateContinuingFrame(aChild, this);
if (aStatus.IsOverflowIncomplete()) {
nif->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}

Просмотреть файл

@ -221,8 +221,7 @@ void nsAbsoluteContainingBlock::Reflow(nsContainerFrame* aDelegatingFrame,
if (!nextFrame) {
nextFrame = aPresContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(aPresContext, kidFrame,
aDelegatingFrame);
->CreateContinuingFrame(kidFrame, aDelegatingFrame);
}
// Add it as an overflow container.
// XXXfr This is a hack to fix some of our printing dataloss.

Просмотреть файл

@ -4595,9 +4595,8 @@ bool nsBlockFrame::CreateContinuationFor(BlockReflowInput& aState,
nsIFrame* newFrame = nullptr;
if (!aFrame->GetNextInFlow()) {
newFrame = aState.mPresContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(aState.mPresContext, aFrame, this);
newFrame =
PresShell()->FrameConstructor()->CreateContinuingFrame(aFrame, this);
mFrames.InsertFrame(nullptr, aFrame, newFrame);
@ -4629,9 +4628,8 @@ void nsBlockFrame::SplitFloat(BlockReflowInput& aState, nsIFrame* aFloat,
nextInFlow->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}
} else {
nextInFlow = aState.mPresContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(aState.mPresContext, aFloat, this);
nextInFlow =
PresShell()->FrameConstructor()->CreateContinuingFrame(aFloat, this);
}
if (aFloatStatus.IsOverflowIncomplete()) {
nextInFlow->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);

Просмотреть файл

@ -763,7 +763,7 @@ void nsCanvasFrame::Reflow(nsPresContext* aPresContext,
if (!nextFrame) {
nextFrame = aPresContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(aPresContext, kidFrame, this);
->CreateContinuingFrame(kidFrame, this);
SetOverflowFrames(nsFrameList(nextFrame, nextFrame));
// Root overflow containers will be normal children of
// the canvas frame, but that's ok because there

Просмотреть файл

@ -1182,9 +1182,8 @@ void nsContainerFrame::ReflowOverflowContainerChildren(
if (!nif) {
NS_ASSERTION(frameStatus.NextInFlowNeedsReflow(),
"Someone forgot a NextInFlowNeedsReflow flag");
nif = aPresContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(aPresContext, frame, this);
nif = PresShell()->FrameConstructor()->CreateContinuingFrame(frame,
this);
} else if (!(nif->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
// used to be a normal next-in-flow; steal it from the child list
nsresult rv = nif->GetParent()->StealFrame(nif);
@ -1336,13 +1335,12 @@ nsIFrame* nsContainerFrame::CreateNextInFlow(nsIFrame* aFrame) {
"you should have called nsBlockFrame::CreateContinuationFor instead");
MOZ_ASSERT(mFrames.ContainsFrame(aFrame), "expected an in-flow child frame");
nsPresContext* pc = PresContext();
nsIFrame* nextInFlow = aFrame->GetNextInFlow();
if (nullptr == nextInFlow) {
// Create a continuation frame for the child frame and insert it
// into our child list.
nextInFlow = pc->PresShell()->FrameConstructor()->CreateContinuingFrame(
pc, aFrame, this);
nextInFlow =
PresShell()->FrameConstructor()->CreateContinuingFrame(aFrame, this);
mFrames.InsertFrame(nullptr, aFrame, nextInFlow);
NS_FRAME_LOG(NS_FRAME_TRACE_NEW_FRAMES,

Просмотреть файл

@ -267,8 +267,7 @@ void nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
// created for us) we need to put the continuation with the rest of the
// text that the first letter frame was made out of.
nsIFrame* continuation;
CreateContinuationForFloatingParent(aPresContext, kid, &continuation,
true);
CreateContinuationForFloatingParent(kid, &continuation, true);
}
}
}
@ -283,20 +282,19 @@ bool nsFirstLetterFrame::CanContinueTextRun() const {
}
void nsFirstLetterFrame::CreateContinuationForFloatingParent(
nsPresContext* aPresContext, nsIFrame* aChild, nsIFrame** aContinuation,
bool aIsFluid) {
nsIFrame* aChild, nsIFrame** aContinuation, bool aIsFluid) {
NS_ASSERTION(IsFloating(),
"can only call this on floating first letter frames");
MOZ_ASSERT(aContinuation, "bad args");
*aContinuation = nullptr;
mozilla::PresShell* presShell = aPresContext->PresShell();
mozilla::PresShell* presShell = PresShell();
nsPlaceholderFrame* placeholderFrame = GetPlaceholderFrame();
nsContainerFrame* parent = placeholderFrame->GetParent();
nsIFrame* continuation = presShell->FrameConstructor()->CreateContinuingFrame(
aPresContext, aChild, parent, aIsFluid);
aChild, parent, aIsFluid);
// The continuation will have gotten the first letter style from its
// prev continuation, so we need to repair the ComputedStyle so it

Просмотреть файл

@ -74,8 +74,7 @@ class nsFirstLetterFrame final : public nsContainerFrame {
// place it in the correct place. aContinuation is an outparam for the
// continuation that is created. aIsFluid determines if the continuation is
// fluid or not.
void CreateContinuationForFloatingParent(nsPresContext* aPresContext,
nsIFrame* aChild,
void CreateContinuationForFloatingParent(nsIFrame* aChild,
nsIFrame** aContinuation,
bool aIsFluid);

Просмотреть файл

@ -6912,8 +6912,7 @@ nscoord nsGridContainerFrame::ReflowRowsInFragmentainer(
nsFrameList pushedList;
nsFrameList incompleteList;
nsFrameList overflowIncompleteList;
auto* pc = PresContext();
auto* fc = pc->PresShell()->FrameConstructor();
auto* fc = PresShell()->FrameConstructor();
for (nsIFrame* child = GetChildList(kPrincipalList).FirstChild(); child;) {
MOZ_ASSERT((pushedItems.Contains(child) ? 1 : 0) +
(incompleteItems.Contains(child) ? 1 : 0) +
@ -6929,7 +6928,7 @@ nscoord nsGridContainerFrame::ReflowRowsInFragmentainer(
} else if (incompleteItems.Contains(child)) {
nsIFrame* childNIF = child->GetNextInFlow();
if (!childNIF) {
childNIF = fc->CreateContinuingFrame(pc, child, this);
childNIF = fc->CreateContinuingFrame(child, this);
incompleteList.AppendFrame(nullptr, childNIF);
} else {
auto parent =
@ -6962,7 +6961,7 @@ nscoord nsGridContainerFrame::ReflowRowsInFragmentainer(
} else if (overflowIncompleteItems.Contains(child)) {
nsIFrame* childNIF = child->GetNextInFlow();
if (!childNIF) {
childNIF = fc->CreateContinuingFrame(pc, child, this);
childNIF = fc->CreateContinuingFrame(child, this);
childNIF->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
overflowIncompleteList.AppendFrame(nullptr, childNIF);
} else {

Просмотреть файл

@ -276,8 +276,8 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
// The page isn't complete and it doesn't have a next-in-flow, so
// create a continuing page.
nsIFrame* continuingPage =
aPresContext->PresShell()->FrameConstructor()->CreateContinuingFrame(
aPresContext, kidFrame, this);
PresShell()->FrameConstructor()->CreateContinuingFrame(kidFrame,
this);
// Add it to our child list
mFrames.InsertFrame(nullptr, kidFrame, continuingPage);

Просмотреть файл

@ -8814,10 +8814,9 @@ void nsTextFrame::SetLength(int32_t aLength, nsLineLayout* aLineLayout,
// We also skip this optimization if we were called during bidi
// resolution, so as not to create a new frame which doesn't appear in
// the bidi resolver's list of frames
nsPresContext* presContext = PresContext();
nsIFrame* newFrame =
presContext->PresShell()->FrameConstructor()->CreateContinuingFrame(
presContext, this, GetParent());
PresShell()->FrameConstructor()->CreateContinuingFrame(this,
GetParent());
nsTextFrame* next = static_cast<nsTextFrame*>(newFrame);
nsFrameList temp(next, next);
GetParent()->InsertFrames(kNoReflowPrincipalList, this,

Просмотреть файл

@ -3069,9 +3069,8 @@ void nsTableFrame::ReflowChildren(TableReflowInput& aReflowInput,
// The child doesn't have a next-in-flow so create a continuing
// frame. This hooks the child into the flow
kidNextInFlow =
presContext->PresShell()
->FrameConstructor()
->CreateContinuingFrame(presContext, kidFrame, this);
PresShell()->FrameConstructor()->CreateContinuingFrame(kidFrame,
this);
// Insert the kid's new next-in-flow into our sibling list...
mFrames.InsertFrame(nullptr, kidFrame, kidNextInFlow);

Просмотреть файл

@ -941,8 +941,7 @@ void nsTableRowGroupFrame::SlideChild(TableRowGroupReflowInput& aReflowInput,
// Create a continuing frame, add it to the child list, and then push it
// and the frames that follow
void nsTableRowGroupFrame::CreateContinuingRowFrame(nsPresContext& aPresContext,
nsIFrame& aRowFrame,
void nsTableRowGroupFrame::CreateContinuingRowFrame(nsIFrame& aRowFrame,
nsIFrame** aContRowFrame) {
// XXX what is the row index?
if (!aContRowFrame) {
@ -951,8 +950,7 @@ void nsTableRowGroupFrame::CreateContinuingRowFrame(nsPresContext& aPresContext,
}
// create the continuing frame which will create continuing cell frames
*aContRowFrame =
aPresContext.PresShell()->FrameConstructor()->CreateContinuingFrame(
&aPresContext, &aRowFrame, this);
PresShell()->FrameConstructor()->CreateContinuingFrame(&aRowFrame, this);
// Add the continuing row frame to the child list
mFrames.InsertFrame(nullptr, &aRowFrame, *aContRowFrame);
@ -1030,17 +1028,15 @@ void nsTableRowGroupFrame::SplitSpanningCells(
}
} else {
if (!aContRow) {
CreateContinuingRowFrame(aPresContext, aLastRow,
(nsIFrame**)&aContRow);
CreateContinuingRowFrame(aLastRow, (nsIFrame**)&aContRow);
}
if (aContRow) {
if (row != &aLastRow) {
// aContRow needs a continuation for cell, since cell spanned into
// aLastRow but does not originate there
nsTableCellFrame* contCell = static_cast<nsTableCellFrame*>(
aPresContext.PresShell()
->FrameConstructor()
->CreateContinuingFrame(&aPresContext, cell, &aLastRow));
PresShell()->FrameConstructor()->CreateContinuingFrame(
cell, &aLastRow));
uint32_t colIndex = cell->ColIndex();
aContRow->InsertCellFrame(contCell, colIndex);
}
@ -1185,8 +1181,7 @@ nsresult nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
rowMetrics.Height() <= rowReflowInput.AvailableHeight(),
"data loss - incomplete row needed more height than available, "
"on top of page");
CreateContinuingRowFrame(*aPresContext, *rowFrame,
(nsIFrame**)&contRow);
CreateContinuingRowFrame(*rowFrame, (nsIFrame**)&contRow);
if (contRow) {
aDesiredSize.Height() += rowMetrics.Height();
if (prevRowFrame) aDesiredSize.Height() += cellSpacingB;

Просмотреть файл

@ -384,8 +384,7 @@ class nsTableRowGroupFrame final : public nsContainerFrame,
nsTableRowFrame*& aFirstTruncatedRow,
nscoord& aDesiredHeight);
void CreateContinuingRowFrame(nsPresContext& aPresContext,
nsIFrame& aRowFrame, nsIFrame** aContRowFrame);
void CreateContinuingRowFrame(nsIFrame& aRowFrame, nsIFrame** aContRowFrame);
bool IsSimpleRowFrame(nsTableFrame* aTableFrame, nsTableRowFrame* aRowFrame);