Skip to content

Commit

Permalink
Bug 1148833 part 3 - Remove nsIFrame::WillReflow and add a non-virtua…
Browse files Browse the repository at this point in the history
…l MarkInReflow method instead that sets NS_FRAME_IN_REFLOW. Call it at the start of Reflow(). r=roc
  • Loading branch information
Mats Palmgren committed Mar 29, 2015
1 parent 9381fb1 commit ed9ed2d
Show file tree
Hide file tree
Showing 63 changed files with 73 additions and 65 deletions.
2 changes: 0 additions & 2 deletions layout/base/nsPresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9088,8 +9088,6 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
mCurrentReflowRoot = target;
#endif

target->WillReflow(mPresContext);

// If the target frame is the root of the frame hierarchy, then
// use all the available space. If it's simply a `reflow root',
// then use the target frame's size as the available space.
Expand Down
6 changes: 3 additions & 3 deletions layout/doc/obsolete/layout-internals.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ <h2>
are passed in from the widget hierarchy.&nbsp; The nsIHTMLReflow interface
inherits from the nsIReflow interface and adds methods related to word
breaking and whitespace querying.&nbsp; The nsIReflow interface defines
the Reflow() method that initiates the reflow process along with the WillReflow()
and DidReflow() methods that get called before and after the reflow process
respectively.&nbsp; nsReflowState and nsReflowMetrics are parameters to
the Reflow() method that initiates the reflow process along with the
DidReflow() method that get calledafter the reflow process.&nbsp;
nsReflowState and nsReflowMetrics are parameters to
the templatized nsIReflow interface: the former is used to hold state during
reflow of a frame and the latter is used to return the frame's desired
size and alignment to the parent frame during the reflow process.
Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsComboboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
// Constraints we try to satisfy:

// 1) Default width of button is the vertical scrollbar size
Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsFieldSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsHTMLButtonControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
4 changes: 1 addition & 3 deletions layout/forms/nsListControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext,
return;
}

MarkInReflow();
/*
* Due to the fact that our intrinsic height depends on the heights of our
* kids, we end up having to do two-pass reflow, in general -- the first pass
Expand Down Expand Up @@ -457,8 +458,6 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext,
computedHeight = state.ApplyMinMaxHeight(computedHeight);
state.SetComputedHeight(computedHeight);

nsHTMLScrollFrame::WillReflow(aPresContext);

// XXXbz to make the ascent really correct, we should add our
// mComputedPadding.top to it (and subtract it from descent). Need that
// because nsGfxScrollFrame just adds in the border....
Expand Down Expand Up @@ -577,7 +576,6 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,

mLastDropdownComputedHeight = state.ComputedHeight();

nsHTMLScrollFrame::WillReflow(aPresContext);
nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
}

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsMeterFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ nsMeterFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsMeterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsNumberControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsProgressFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ nsProgressFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsProgressFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsRangeFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ nsRangeFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsRangeFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/forms/nsTextControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsTextControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
3 changes: 0 additions & 3 deletions layout/generic/nsAbsoluteContainingBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,6 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
aContainingBlock.width,
aContainingBlock.height);

// Send the WillReflow() notification and position the frame
aKidFrame->WillReflow(aPresContext);

// Get the border values
const nsMargin& border = aReflowState.mStyleBorder->GetComputedBorder();

Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsBRFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("BRFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
WritingMode wm = aReflowState.GetWritingMode();
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsBlockFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsBlockFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
#ifdef DEBUG
Expand Down Expand Up @@ -7003,7 +7004,6 @@ nsBlockFrame::ReflowBullet(nsIFrame* aBulletFrame,
nsHTMLReflowState reflowState(aState.mPresContext, rs,
aBulletFrame, availSize);
nsReflowStatus status;
aBulletFrame->WillReflow(aState.mPresContext);
aBulletFrame->Reflow(aState.mPresContext, aMetrics, reflowState, status);

// Get the float available space using our saved state from before we
Expand Down
3 changes: 0 additions & 3 deletions layout/generic/nsBlockReflowContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ nsBlockReflowContext::ReflowBlock(const LogicalRect& aSpace,
mOuterReflowState.mBlockDelta + mBCoord - aLine->BStart();
}

// Let frame know that we are reflowing it
mFrame->WillReflow(mPresContext);

#ifdef DEBUG
mMetrics.ISize(mWritingMode) = nscoord(0xdeadbeef);
mMetrics.BSize(mWritingMode) = nscoord(0xdeadbeef);
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsBulletFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ nsBulletFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsBulletFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsCanvasFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ nsCanvasFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsCanvasFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE_REFLOW_IN("nsCanvasFrame::Reflow");
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsColumnSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
// Don't support interruption in columns
nsPresContext::InterruptPreventer noInterrupts(aPresContext);

Expand Down
15 changes: 2 additions & 13 deletions layout/generic/nsContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,6 @@ nsContainerFrame::ComputeAutoSize(nsRenderingContext* aRenderingContext,
return result;
}

/**
* Invokes the WillReflow() function, positions the frame and its view (if
* requested), and then calls Reflow(). If the reflow succeeds and the child
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
*/
void
nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
nsPresContext* aPresContext,
Expand All @@ -957,10 +952,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
"FinishReflowChild with unconstrained container width!");
}

// Send the WillReflow() notification, and position the child frame
// and its view if requested
aKidFrame->WillReflow(aPresContext);

// Position the child frame and its view if requested.
if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
aKidFrame->SetPosition(aWM, aPos, aContainerWidth);
}
Expand Down Expand Up @@ -1002,10 +994,7 @@ nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
{
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");

// Send the WillReflow() notification, and position the child frame
// and its view if requested
aKidFrame->WillReflow(aPresContext);

// Position the child frame and its view if requested.
if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
aKidFrame->SetPosition(nsPoint(aX, aY));
}
Expand Down
8 changes: 4 additions & 4 deletions layout/generic/nsContainerFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ class nsContainerFrame : public nsSplittableFrame
bool aShrinkWrap) override;

/**
* Invokes the WillReflow() function, positions the frame and its view (if
* requested), and then calls Reflow(). If the reflow succeeds and the child
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
* Positions aChildFrame and its view (if requested), and then calls Reflow().
* If the reflow status after reflowing the child is FULLY_COMPLETE then any
* next-in-flows are deleted using DeleteNextInFlowChild().
*
* Flags:
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
* don't want to automatically sync the frame and view
* 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
*/
void ReflowChild(nsIFrame* aKidFrame,
void ReflowChild(nsIFrame* aChildFrame,
nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsFirstLetterFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aReflowStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);

Expand Down Expand Up @@ -205,7 +206,6 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
ll.SetInFirstLetter(true);
ll.SetFirstLetterStyleOK(true);

kid->WillReflow(aPresContext);
kid->Reflow(aPresContext, kidMetrics, rs, aReflowStatus);

ll.EndLineReflow();
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsFlexContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3429,6 +3429,7 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFlexContainerFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
PR_LOG(GetFlexContainerLog(), PR_LOG_DEBUG,
Expand Down
16 changes: 1 addition & 15 deletions layout/generic/nsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4410,20 +4410,6 @@ nsFrame::ShrinkWidthToFit(nsRenderingContext *aRenderingContext,
return result;
}

void
nsFrame::WillReflow(nsPresContext* aPresContext)
{
#ifdef DEBUG_dbaron_off
// bug 81268
NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW),
"nsFrame::WillReflow: frame is already in reflow");
#endif

NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
("WillReflow: oldState=%x", mState));
mState |= NS_FRAME_IN_REFLOW;
}

void
nsFrame::DidReflow(nsPresContext* aPresContext,
const nsHTMLReflowState* aReflowState,
Expand Down Expand Up @@ -4524,6 +4510,7 @@ nsFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFrame");
aDesiredSize.ClearSize();
aStatus = NS_FRAME_COMPLETE;
Expand Down Expand Up @@ -8644,7 +8631,6 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState,
#endif

// place the child and reflow
WillReflow(aPresContext);

Reflow(aPresContext, aDesiredSize, reflowState, status);

Expand Down
1 change: 0 additions & 1 deletion layout/generic/nsFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ class nsFrame : public nsBox
nscoord ShrinkWidthToFit(nsRenderingContext *aRenderingContext,
nscoord aWidthInCB);

virtual void WillReflow(nsPresContext* aPresContext) override;
/**
* Calculates the size of this frame after reflowing (calling Reflow on, and
* updating the size and position of) its children, as necessary. The
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsFrameSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
nsIPresShell *shell = aPresContext->PresShell();
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsGfxScrollFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsHTMLScrollFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsGridContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsGridContainerFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);

Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsHTMLCanvasFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ nsHTMLCanvasFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsHTMLCanvasFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
Expand Down
19 changes: 8 additions & 11 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -1766,17 +1766,6 @@ class nsIFrame : public nsQueryFrame
nscoord* aX,
nscoord* aXMost);

/**
* Pre-reflow hook. Before a frame is reflowed this method will be called.
* This call will always be invoked at least once before a subsequent Reflow
* and DidReflow call. It may be called more than once, In general you will
* receive on WillReflow notification before each Reflow request.
*
* XXX Is this really the semantics we want? Because we have the NS_FRAME_IN_REFLOW
* bit we can ensure we don't call it more than once...
*/
virtual void WillReflow(nsPresContext* aPresContext) = 0;

/**
* The frame is given an available size and asked for its desired
* size. This is the frame's opportunity to reflow its children.
Expand Down Expand Up @@ -3021,6 +3010,14 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
}

protected:
void MarkInReflow() {
#ifdef DEBUG_dbaron_off
// bug 81268
NS_ASSERTION(!(mState & NS_FRAME_IN_REFLOW), "frame is already in reflow");
#endif
mState |= NS_FRAME_IN_REFLOW;
}

nsFrameState mState;

// When there is an overflow area only slightly larger than mRect,
Expand Down
1 change: 1 addition & 0 deletions layout/generic/nsImageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsImageFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
Expand Down
2 changes: 2 additions & 0 deletions layout/generic/nsInlineFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
if (nullptr == aReflowState.mLineLayout) {
Expand Down Expand Up @@ -1064,6 +1065,7 @@ nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
if (nullptr == aReflowState.mLineLayout) {
return; // XXX does this happen? why?
}
Expand Down
Loading

0 comments on commit ed9ed2d

Please sign in to comment.