Bug 1093998 - Make nsContainerFrame::CreateNextInFlow return the new frame instead of using an our param. r=dbaron

This commit is contained in:
Xidorn Quan 2014-12-01 22:03:57 -08:00
parent aa22a12e59
commit abf5a08d63
6 changed files with 14 additions and 37 deletions

View File

@ -617,13 +617,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
"We have to create a continuation, but the block doesn't want us to reflow it?");
// We need to create a continuing column
nsresult rv = CreateNextInFlow(child, kidNextInFlow);
if (NS_FAILED(rv)) {
NS_NOTREACHED("Couldn't create continuation");
child = nullptr;
break;
}
kidNextInFlow = CreateNextInFlow(child);
}
// Make sure we reflow a next-in-flow when it switches between being

View File

@ -1305,20 +1305,17 @@ nsContainerFrame::StealFramesAfter(nsIFrame* aChild)
/*
* Create a next-in-flow for aFrame. Will return the newly created
* frame in aNextInFlowResult <b>if and only if</b> a new frame is
* created; otherwise nullptr is returned in aNextInFlowResult.
* frame <b>if and only if</b> a new frame is created; otherwise
* nullptr is returned.
*/
nsresult
nsContainerFrame::CreateNextInFlow(nsIFrame* aFrame,
nsIFrame*& aNextInFlowResult)
nsIFrame*
nsContainerFrame::CreateNextInFlow(nsIFrame* aFrame)
{
NS_PRECONDITION(GetType() != nsGkAtoms::blockFrame,
"you should have called nsBlockFrame::CreateContinuationFor instead");
NS_PRECONDITION(mFrames.ContainsFrame(aFrame), "expected an in-flow child frame");
nsPresContext* pc = PresContext();
aNextInFlowResult = nullptr;
nsIFrame* nextInFlow = aFrame->GetNextInFlow();
if (nullptr == nextInFlow) {
// Create a continuation frame for the child frame and insert it
@ -1331,9 +1328,9 @@ nsContainerFrame::CreateNextInFlow(nsIFrame* aFrame,
("nsContainerFrame::CreateNextInFlow: frame=%p nextInFlow=%p",
aFrame, nextInFlow));
aNextInFlowResult = nextInFlow;
return nextInFlow;
}
return NS_OK;
return nullptr;
}
/**

View File

@ -134,12 +134,10 @@ public:
* into the principal child list after aFrame.
* @note calling this method on a block frame is illegal. Use
* nsBlockFrame::CreateContinuationFor() instead.
* @param aNextInFlowResult will contain the next-in-flow
* <b>if and only if</b> one is created. If a next-in-flow already
* exists aNextInFlowResult is set to nullptr.
* @return NS_OK if a next-in-flow already exists or is successfully created.
* @return the next-in-flow <b>if and only if</b> one is created. If
* a next-in-flow already exists, nullptr will be returned.
*/
nsresult CreateNextInFlow(nsIFrame* aFrame, nsIFrame*& aNextInFlowResult);
nsIFrame* CreateNextInFlow(nsIFrame* aFrame);
/**
* Delete aNextInFlow and its next-in-flows.

View File

@ -166,7 +166,6 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
{
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
nsresult rv = NS_OK;
// Grab overflow list
DrainOverflowFrames(aPresContext);
@ -272,12 +271,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
// Create a continuation for the child frame if it doesn't already
// have one.
if (!IsFloating()) {
nsIFrame* nextInFlow;
rv = CreateNextInFlow(kid, nextInFlow);
if (NS_FAILED(rv)) {
return;
}
CreateNextInFlow(kid);
// And then push it to our overflow list
const nsFrameList& overflow = mFrames.RemoveFramesAfter(kid);
if (overflow.NotEmpty()) {

View File

@ -778,11 +778,7 @@ nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
// Create a next-in-flow if needed.
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
nsIFrame* newFrame;
nsresult rv = CreateNextInFlow(aFrame, newFrame);
if (NS_FAILED(rv)) {
return;
}
CreateNextInFlow(aFrame);
}
if (NS_INLINE_IS_BREAK_AFTER(aStatus)) {

View File

@ -321,8 +321,7 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext,
}
// Create continuations for the base container
nsIFrame* newBaseContainer;
CreateNextInFlow(aBaseContainer, newBaseContainer);
nsIFrame* newBaseContainer = CreateNextInFlow(aBaseContainer);
// newBaseContainer is null if there are existing next-in-flows.
// We only need to move and push if there were not.
if (newBaseContainer) {
@ -333,8 +332,7 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext,
// Create continuations for text containers
nsIFrame* newLastChild = newBaseContainer;
for (uint32_t i = 0; i < rtcCount; i++) {
nsIFrame* newTextContainer;
CreateNextInFlow(textContainers[i], newTextContainer);
nsIFrame* newTextContainer = CreateNextInFlow(textContainers[i]);
MOZ_ASSERT(newTextContainer, "Next-in-flow of rtc should not exist "
"if the corresponding rbc does not");
mFrames.RemoveFrame(newTextContainer);