Bug 897887 - Avoid calling ScheduleReflowSVGNonDisplayText when constructing frames during reflow. r=jwatt

This commit is contained in:
Cameron McCormack 2013-07-31 10:39:04 +10:00
parent 4630a79d76
commit 5a0e1504b3
3 changed files with 12 additions and 3 deletions

View File

@ -704,8 +704,7 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
nsIFrame* anonBlock = svgTextFrame->GetFirstPrincipalChild();
// Just as in nsSVGTextFrame2::DidSetStyleContext, we need to ensure that
// any non-display nsSVGTextFrame2s get reflowed when a child text frame
// gets new style. We don't need to do this when the frame has not yet
// been reflowed, since that will happen soon anyway.
// gets new style.
//
// Note that we must check NS_FRAME_FIRST_REFLOW on our nsSVGTextFrame2's
// anonymous block frame rather than our self, since NS_FRAME_FIRST_REFLOW
@ -713,7 +712,8 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
// document's first reflow. (In which case this DidSetStyleContext call may
// be happening under frame construction under a Reflow() call.)
if (anonBlock && !(anonBlock->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
(svgTextFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
(svgTextFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) &&
!(svgTextFrame->GetStateBits() & NS_STATE_SVG_TEXT_IN_REFLOW)) {
svgTextFrame->ScheduleReflowSVGNonDisplayText();
}
}

View File

@ -3170,6 +3170,9 @@ nsSVGTextFrame2::ScheduleReflowSVGNonDisplayText()
MOZ_ASSERT(!nsSVGUtils::OuterSVGIsCallingReflowSVG(this),
"do not call ScheduleReflowSVGNonDisplayText when the outer SVG "
"frame is under ReflowSVG");
MOZ_ASSERT(!(mState & NS_STATE_SVG_TEXT_IN_REFLOW),
"do not call ScheduleReflowSVGNonDisplayText while reflowing the "
"anonymous block child");
// We need to find an ancestor frame that we can call FrameNeedsReflow
// on that will cause the document to be marked as needing relayout,
@ -5044,6 +5047,8 @@ nsSVGTextFrame2::DoReflow()
kid->MarkIntrinsicWidthsDirty();
}
mState |= NS_STATE_SVG_TEXT_IN_REFLOW;
nscoord width = kid->GetPrefWidth(renderingContext);
nsHTMLReflowState reflowState(presContext, kid,
renderingContext,
@ -5061,6 +5066,8 @@ nsSVGTextFrame2::DoReflow()
kid->DidReflow(presContext, &reflowState, nsDidReflowStatus::FINISHED);
kid->SetSize(nsSize(desiredSize.width, desiredSize.height));
mState &= ~NS_STATE_SVG_TEXT_IN_REFLOW;
TextNodeCorrespondenceRecorder::RecordCorrespondence(this);
}

View File

@ -103,6 +103,8 @@ class Element;
*/
#define NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES NS_FRAME_STATE_BIT(23)
#define NS_STATE_SVG_TEXT_IN_REFLOW NS_FRAME_STATE_BIT(24)
/**
* Byte offsets of channels in a native packed gfxColor or cairo image surface.
*/