Bug 1008917 - part 5,6,7, make ReflowChild() and FinishReflowChild() return type 'void', and make a few related helper methods 'void' too. r=roc

This commit is contained in:
Mats Palmgren 2014-05-13 00:47:53 +00:00
parent 9795aca511
commit 9f6f93ca23
11 changed files with 82 additions and 107 deletions

View File

@ -932,7 +932,7 @@ nsContainerFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
* requested), and then calls Reflow(). If the reflow succeeds and the child
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
*/
nsresult
void
nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -974,7 +974,6 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
->DeleteNextInFlowChild(kidNextInFlow, true);
}
}
return NS_OK;
}
@ -1030,7 +1029,7 @@ nsContainerFrame::PositionChildViews(nsIFrame* aFrame)
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
*/
nsresult
void
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
const nsHTMLReflowMetrics& aDesiredSize,
@ -1064,7 +1063,7 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
}
}
return aKidFrame->DidReflow(aPresContext, aReflowState, nsDidReflowStatus::FINISHED);
aKidFrame->DidReflow(aPresContext, aReflowState, nsDidReflowStatus::FINISHED);
}
nsresult
@ -1075,7 +1074,6 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
nsReflowStatus& aStatus)
{
NS_PRECONDITION(aPresContext, "null pointer");
nsresult rv = NS_OK;
nsFrameList* overflowContainers =
GetPropTableFrames(OverflowContainersProperty());
@ -1146,14 +1144,12 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
nsReflowStatus frameStatus;
// Reflow
rv = ReflowChild(frame, aPresContext, desiredSize, frameState,
prevRect.x, 0, aFlags, frameStatus, &tracker);
NS_ENSURE_SUCCESS(rv, rv);
ReflowChild(frame, aPresContext, desiredSize, frameState,
prevRect.x, 0, aFlags, frameStatus, &tracker);
//XXXfr Do we need to override any shrinkwrap effects here?
// e.g. desiredSize.Width() = prevRect.width;
rv = FinishReflowChild(frame, aPresContext, desiredSize, &frameState,
prevRect.x, 0, aFlags);
NS_ENSURE_SUCCESS(rv, rv);
FinishReflowChild(frame, aPresContext, desiredSize, &frameState,
prevRect.x, 0, aFlags);
// Handle continuations
if (!NS_FRAME_IS_FULLY_COMPLETE(frameStatus)) {
@ -1177,7 +1173,7 @@ nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPres
}
else if (!(nif->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
// used to be a normal next-in-flow; steal it from the child list
rv = static_cast<nsContainerFrame*>(nif->GetParent())
nsresult rv = static_cast<nsContainerFrame*>(nif->GetParent())
->StealFrame(nif);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -190,15 +190,15 @@ public:
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
* case. Also implies NS_FRAME_NO_MOVE_VIEW
*/
nsresult ReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nscoord aX,
nscoord aY,
uint32_t aFlags,
nsReflowStatus& aStatus,
nsOverflowContinuationTracker* aTracker = nullptr);
void ReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nscoord aX,
nscoord aY,
uint32_t aFlags,
nsReflowStatus& aStatus,
nsOverflowContinuationTracker* aTracker = nullptr);
/**
* The second half of frame reflow. Does the following:
@ -217,13 +217,13 @@ public:
* don't want to automatically sync the frame and view
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
*/
static nsresult FinishReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
const nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState* aReflowState,
nscoord aX,
nscoord aY,
uint32_t aFlags);
static void FinishReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
const nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState* aReflowState,
nscoord aX,
nscoord aY,
uint32_t aFlags);
static void PositionChildViews(nsIFrame* aFrame);

View File

@ -1116,19 +1116,17 @@ nsFlexContainerFrame::
nsHTMLReflowMetrics childDesiredSize(childRSForMeasuringHeight);
nsReflowStatus childReflowStatus;
const uint32_t flags = NS_FRAME_NO_MOVE_FRAME;
nsresult rv = ReflowChild(aFlexItem.Frame(), aPresContext,
childDesiredSize, childRSForMeasuringHeight,
0, 0, flags, childReflowStatus);
NS_ENSURE_SUCCESS(rv, rv);
ReflowChild(aFlexItem.Frame(), aPresContext,
childDesiredSize, childRSForMeasuringHeight,
0, 0, flags, childReflowStatus);
MOZ_ASSERT(NS_FRAME_IS_COMPLETE(childReflowStatus),
"We gave flex item unconstrained available height, so it "
"should be complete");
rv = FinishReflowChild(aFlexItem.Frame(), aPresContext,
childDesiredSize, &childRSForMeasuringHeight,
0, 0, flags);
NS_ENSURE_SUCCESS(rv, rv);
FinishReflowChild(aFlexItem.Frame(), aPresContext,
childDesiredSize, &childRSForMeasuringHeight,
0, 0, flags);
// Subtract border/padding in vertical axis, to get _just_
// the effective computed value of the "height" property.
@ -2907,11 +2905,10 @@ nsFlexContainerFrame::SizeItemInCrossAxis(
nsHTMLReflowMetrics childDesiredSize(aChildReflowState);
nsReflowStatus childReflowStatus;
const uint32_t flags = NS_FRAME_NO_MOVE_FRAME;
nsresult rv = ReflowChild(aItem.Frame(), aPresContext,
childDesiredSize, aChildReflowState,
0, 0, flags, childReflowStatus);
ReflowChild(aItem.Frame(), aPresContext,
childDesiredSize, aChildReflowState,
0, 0, flags, childReflowStatus);
aItem.SetHadMeasuringReflow();
NS_ENSURE_SUCCESS(rv, rv);
// XXXdholbert Once we do pagination / splitting, we'll need to actually
// handle incomplete childReflowStatuses. But for now, we give our kids
@ -2922,9 +2919,8 @@ nsFlexContainerFrame::SizeItemInCrossAxis(
// Tell the child we're done with its initial reflow.
// (Necessary for e.g. GetBaseline() to work below w/out asserting)
rv = FinishReflowChild(aItem.Frame(), aPresContext,
childDesiredSize, &aChildReflowState, 0, 0, flags);
NS_ENSURE_SUCCESS(rv, rv);
FinishReflowChild(aItem.Frame(), aPresContext,
childDesiredSize, &aChildReflowState, 0, 0, flags);
// Save the sizing info that we learned from this reflow
// -----------------------------------------------------
@ -3316,11 +3312,10 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
nsHTMLReflowMetrics childDesiredSize(childReflowState);
nsReflowStatus childReflowStatus;
nsresult rv = ReflowChild(item->Frame(), aPresContext,
childDesiredSize, childReflowState,
physicalPosn.x, physicalPosn.y,
0, childReflowStatus);
NS_ENSURE_SUCCESS(rv, rv);
ReflowChild(item->Frame(), aPresContext,
childDesiredSize, childReflowState,
physicalPosn.x, physicalPosn.y,
0, childReflowStatus);
// XXXdholbert Once we do pagination / splitting, we'll need to actually
// handle incomplete childReflowStatuses. But for now, we give our kids
@ -3332,10 +3327,9 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
childReflowState.ApplyRelativePositioning(&physicalPosn);
rv = FinishReflowChild(item->Frame(), aPresContext,
childDesiredSize, &childReflowState,
physicalPosn.x, physicalPosn.y, 0);
NS_ENSURE_SUCCESS(rv, rv);
FinishReflowChild(item->Frame(), aPresContext,
childDesiredSize, &childReflowState,
physicalPosn.x, physicalPosn.y, 0);
// If this is our first child and we haven't established a baseline for
// the container yet (i.e. if we don't have 'align-self: baseline' on any

View File

@ -827,7 +827,7 @@ nsMathMLContainerFrame::UpdateOverflow()
return false;
}
nsresult
void
nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -875,7 +875,6 @@ nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame,
aDesiredSize.mBoundingMetrics.descent = r.YMost() - aDesiredSize.TopAscent();
aDesiredSize.mBoundingMetrics.width = aDesiredSize.Width();
}
return NS_OK;
}
void

View File

@ -277,7 +277,7 @@ public:
// helper method to reflow a child frame. We are inline frames, and we don't
// know our positions until reflow is finished. That's why we ask the
// base method not to worry about our position.
nsresult
void
ReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -1996,14 +1996,13 @@ nsTableFrame::UpdateOverflow()
return FinishAndStoreOverflow(overflowAreas, GetSize());
}
nsresult
void
nsTableFrame::ReflowTable(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nscoord aAvailHeight,
nsIFrame*& aLastChildReflowed,
nsReflowStatus& aStatus)
{
nsresult rv = NS_OK;
aLastChildReflowed = nullptr;
if (!GetPrevInFlow()) {
@ -2019,7 +2018,6 @@ nsTableFrame::ReflowTable(nsHTMLReflowMetrics& aDesiredSize,
aDesiredSize.mOverflowAreas);
ReflowColGroups(aReflowState.rendContext);
return rv;
}
nsIFrame*
@ -2831,9 +2829,8 @@ nsTableFrame::SetupHeaderFooterChild(const nsTableReflowState& aReflowState,
nsHTMLReflowMetrics desiredSize(aReflowState.reflowState);
desiredSize.Width() = desiredSize.Height() = 0;
nsReflowStatus status;
nsresult rv = ReflowChild(aFrame, presContext, desiredSize, kidReflowState,
aReflowState.x, aReflowState.y, 0, status);
NS_ENSURE_SUCCESS(rv, rv);
ReflowChild(aFrame, presContext, desiredSize, kidReflowState,
aReflowState.x, aReflowState.y, 0, status);
// The child will be reflowed again "for real" so no need to place it now
aFrame->SetRepeatable(IsRepeatable(desiredSize.Height(), pageHeight));
@ -2871,7 +2868,7 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState,
// Reflow the children based on the avail size and reason in aReflowState
// update aReflowMetrics a aStatus
nsresult
void
nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame*& aLastChildReflowed,
@ -2881,7 +2878,6 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
aLastChildReflowed = nullptr;
nsIFrame* prevKidFrame = nullptr;
nsresult rv = NS_OK;
nscoord cellSpacingY = GetCellSpacingY();
nsPresContext* presContext = PresContext();
@ -2916,14 +2912,14 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
if (isPaginated) {
if (thead && !GetPrevInFlow()) {
nscoord desiredHeight;
rv = SetupHeaderFooterChild(aReflowState, thead, &desiredHeight);
nsresult rv = SetupHeaderFooterChild(aReflowState, thead, &desiredHeight);
if (NS_FAILED(rv))
return rv;
return;
}
if (tfoot) {
rv = SetupHeaderFooterChild(aReflowState, tfoot, &footerHeight);
nsresult rv = SetupHeaderFooterChild(aReflowState, tfoot, &footerHeight);
if (NS_FAILED(rv))
return rv;
return;
}
}
// if the child is a tbody in paginated mode reduce the height by a repeated footer
@ -2995,8 +2991,8 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
if (kidFrame->GetNextInFlow())
reorder = true;
rv = ReflowChild(kidFrame, presContext, desiredSize, kidReflowState,
aReflowState.x, aReflowState.y, 0, aStatus);
ReflowChild(kidFrame, presContext, desiredSize, kidReflowState,
aReflowState.x, aReflowState.y, 0, aStatus);
if (reorder) {
// reorder row groups the reflow may have changed the nextinflows
@ -3152,8 +3148,6 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
// the children.
mBits.mResizedColumns = false;
ClearGeometryDirty();
return rv;
}
void

View File

@ -343,11 +343,11 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) MOZ_OVERRIDE;
nsresult ReflowTable(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nscoord aAvailHeight,
nsIFrame*& aLastChildReflowed,
nsReflowStatus& aStatus);
void ReflowTable(nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nscoord aAvailHeight,
nsIFrame*& aLastChildReflowed,
nsReflowStatus& aStatus);
nsFrameList& GetColGroups();
@ -542,10 +542,10 @@ protected:
nsTableRowGroupFrame* aFrame,
nscoord* aDesiredHeight);
nsresult ReflowChildren(nsTableReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame*& aLastChildReflowed,
nsOverflowAreas& aOverflowAreas);
void ReflowChildren(nsTableReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame*& aLastChildReflowed,
nsOverflowAreas& aOverflowAreas);
// This calls the col group and column reflow methods, which do two things:
// (1) set all the dimensions to 0

View File

@ -792,7 +792,7 @@ nscoord CalcHeightFromUnpaginatedHeight(nsPresContext* aPresContext,
return std::max(height, 0);
}
nsresult
void
nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
@ -804,7 +804,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
// XXXldb Should we be checking constrained height instead?
const bool isPaginated = aPresContext->IsPaginated();
const bool borderCollapse = aTableFrame.IsBorderCollapse();
nsresult rv = NS_OK;
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
int32_t cellColSpan = 1; // must be defined here so it's set properly for non-cell kids
@ -912,8 +912,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
kidReflowState);
nsReflowStatus status;
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
x, 0, 0, status);
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
x, 0, 0, status);
// allow the table to determine if/how the table needs to be rebalanced
// If any of the cells are not complete, then we're not complete
@ -1029,7 +1029,6 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
}
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
FinishAndStoreOverflow(&aDesiredSize);
return rv;
}
/** Layout the entire row.

View File

@ -254,11 +254,11 @@ protected:
* Called for incremental/dirty and resize reflows. If aDirtyOnly is true then
* only reflow dirty cells.
*/
nsresult ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsTableFrame& aTableFrame,
nsReflowStatus& aStatus);
void ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsTableFrame& aTableFrame,
nsReflowStatus& aStatus);
private:
struct RowBits {

View File

@ -329,7 +329,7 @@ CacheRowHeightsForPrinting(nsPresContext* aPresContext,
}
}
nsresult
void
nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
nsRowGroupReflowState& aReflowState,
@ -340,7 +340,6 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
*aPageBreakBeforeEnd = false;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
nsresult rv = NS_OK;
const bool borderCollapse = tableFrame->IsBorderCollapse();
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
@ -403,8 +402,8 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
kidReflowState.mFlags.mIsTopOfPage = false;
}
rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
0, aReflowState.y, 0, aStatus);
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
0, aReflowState.y, 0, aStatus);
// Place the child
PlaceChild(aPresContext, aReflowState, kidFrame, desiredSize,
@ -472,8 +471,6 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
InvalidateFrame();
}
}
return rv;
}
nsTableRowFrame*
@ -1046,7 +1043,6 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
{
NS_PRECONDITION(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
nsresult rv = NS_OK;
nsTableRowFrame* prevRowFrame = nullptr;
aDesiredSize.Height() = 0;
@ -1099,9 +1095,8 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
// Reflow the cell with the constrained height. A cell with rowspan >1 will get this
// reflow later during SplitSpanningCells.
rv = ReflowChild(rowFrame, aPresContext, rowMetrics, rowReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
if (NS_FAILED(rv)) return rv;
ReflowChild(rowFrame, aPresContext, rowMetrics, rowReflowState,
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
rowFrame->SetSize(nsSize(rowMetrics.Width(), rowMetrics.Height()));
rowFrame->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
rowFrame->DidResize();

View File

@ -358,14 +358,12 @@ protected:
*
* @param aPresContext presentation context to use
* @param aReflowState current inline state
* @return true if we successfully reflowed all the mapped children and false
* otherwise, e.g. we pushed children to the next in flow
*/
nsresult ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
nsRowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
bool* aPageBreakBeforeEnd = nullptr);
void ReflowChildren(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
nsRowGroupReflowState& aReflowState,
nsReflowStatus& aStatus,
bool* aPageBreakBeforeEnd = nullptr);
nsresult SplitRowGroup(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,