Be sure to return the reflow status as complete in the case of invalid markup to avoid a hang due to the frame being reflowed over and over again. Patch by steve.swanson@mackichan.com, b=323737, r+sr=rbs

This commit is contained in:
rbs%maths.uq.edu.au 2006-07-18 07:49:02 +00:00
parent d5ca8e945a
commit de01a001d1
23 changed files with 205 additions and 124 deletions

View File

@ -45,11 +45,10 @@ struct nsPresentationData;
struct nsEmbellishData;
struct nsHTMLReflowMetrics;
// IID for the nsIMathMLFrame interface (the IID was taken from IIDS.h)
/* a6cf9113-15b3-11d2-932e-00805f8add32 */
// a781ed45-4338-43cb-9739-a7a8f8418ff3
#define NS_IMATHMLFRAME_IID \
{ 0xa6cf9113, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
{ 0xa781ed45, 0x4338, 0x43cb, \
{ 0x97, 0x39, 0xa7, 0xa8, 0xf8, 0x41, 0x8f, 0xf3 } }
static NS_DEFINE_IID(kIMathMLFrameIID, NS_IMATHMLFRAME_IID);
@ -137,11 +136,17 @@ public:
* desired size and your ascent/descent info. Compute your desired size
* using the information in your children's rectangles, and include any
* space you want for border/padding in the desired size you return.
*
* @param aReflowState [out] forwarded argument from Reflow()
*
* @param aStatus [out] forwarded argument from Reflow()
*/
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize) = 0;
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus) = 0;
/* GetEmbellishData/SetEmbellishData :
* Get/Set the mEmbellishData member variable.

View File

@ -85,7 +85,9 @@ NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLContainerFrame, nsHTMLContainerFrame,
// provide a feedback to the user when a frame with bad markup can not be rendered
nsresult
nsMathMLContainerFrame::ReflowError(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
nsresult rv;
@ -106,6 +108,8 @@ nsMathMLContainerFrame::ReflowError(nsIRenderingContext& aRenderingContext,
NS_WARNING("GetBoundingMetrics failed");
aDesiredSize.width = aDesiredSize.height = 0;
aDesiredSize.ascent = aDesiredSize.descent = 0;
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}
@ -123,6 +127,8 @@ nsMathMLContainerFrame::ReflowError(nsIRenderingContext& aRenderingContext,
// Also return our bounding metrics
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return NS_OK;
}

View File

@ -203,7 +203,9 @@ public:
// (typically invalid markup) was encountered during reflow.
virtual nsresult
ReflowError(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
// 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

View File

@ -107,7 +107,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
return NS_OK;
}

View File

@ -317,7 +317,9 @@ nsMathMLmactionFrame::Reflow(nsPresContext* aPresContext,
NS_IMETHODIMP
nsMathMLmactionFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
aDesiredSize.width = aDesiredSize.height = 0;
aDesiredSize.ascent = aDesiredSize.descent = 0;

View File

@ -79,7 +79,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD
Reflow(nsPresContext* aPresContext,

View File

@ -266,7 +266,9 @@ nsMathMLmfracFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
NS_IMETHODIMP
nsMathMLmfracFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
////////////////////////////////////
// Get the children's desired sizes
@ -280,7 +282,7 @@ nsMathMLmfracFrame::Place(nsIRenderingContext& aRenderingContext,
if (!frameNum || !frameDen || frameDen->GetNextSibling()) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
GetReflowAndBoundingMetricsFor(frameNum, sizeNum, bmNum);
GetReflowAndBoundingMetricsFor(frameDen, sizeDen, bmDen);

View File

@ -114,7 +114,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,

View File

@ -143,7 +143,9 @@ nsMathMLmmultiscriptsFrame::ProcessAttributes()
NS_IMETHODIMP
nsMathMLmmultiscriptsFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
////////////////////////////////////
// Get the children's desired sizes
@ -268,7 +270,7 @@ nsMathMLmmultiscriptsFrame::Place(nsIRenderingContext& aRenderingContext,
// duplicate <mprescripts/> found
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
mprescriptsFrame = childFrame;
firstPrescriptsPair = PR_TRUE;
@ -379,7 +381,7 @@ nsMathMLmmultiscriptsFrame::Place(nsIRenderingContext& aRenderingContext,
if ((0 != width) || !baseFrame || !subScriptFrame || !supScriptFrame) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
// we left out the width of prescripts, so ...

View File

@ -57,7 +57,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
protected:
nsMathMLmmultiscriptsFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}

View File

@ -251,7 +251,9 @@ i.e.:
NS_IMETHODIMP
nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
@ -260,6 +262,8 @@ nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this);
}
@ -276,7 +280,7 @@ nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
if (!baseFrame || !overFrame || overFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);

View File

@ -54,7 +54,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent);

View File

@ -210,7 +210,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
if (2 != count) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(renderingContext, aDesiredSize);
return ReflowError(renderingContext, aDesiredSize, aReflowState, aStatus);
}
////////////

View File

@ -84,7 +84,9 @@ nsMathMLmsubFrame::TransmitAutomaticData()
NS_IMETHODIMP
nsMathMLmsubFrame::Place (nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// extra spacing after sup/subscript
nscoord scriptSpace = NSFloatPointsToTwips(0.5f); // 0.5pt as in plain TeX
@ -105,6 +107,8 @@ nsMathMLmsubFrame::Place (nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this,
subScriptShift,
scriptSpace);
@ -117,6 +121,8 @@ nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aScriptSpace)
@ -144,7 +150,9 @@ nsMathMLmsubFrame::PlaceSubScript (nsPresContext* aPresContext,
NS_WARNING("invalid markup");
return NS_STATIC_CAST(nsMathMLContainerFrame*,
aFrame)->ReflowError(aRenderingContext,
aDesiredSize);
aDesiredSize,
aReflowState,
aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);

View File

@ -57,13 +57,17 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
static nsresult
PlaceSubScript (nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aForFrame,
nscoord aUserSubScriptShift = 0,
nscoord aScriptSpace = NSFloatPointsToTwips(0.5f));

View File

@ -89,7 +89,9 @@ nsMathMLmsubsupFrame::TransmitAutomaticData()
NS_IMETHODIMP
nsMathMLmsubsupFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// extra spacing between base and sup/subscript
nscoord scriptSpace = 0;
@ -120,6 +122,8 @@ nsMathMLmsubsupFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this,
subScriptShift,
supScriptShift,
@ -133,6 +137,8 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aFrame,
nscoord aUserSubScriptShift,
nscoord aUserSupScriptShift,
@ -167,7 +173,9 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsPresContext* aPresContext,
NS_WARNING("invalid markup");
return NS_STATIC_CAST(nsMathMLContainerFrame*,
aFrame)->ReflowError(aRenderingContext,
aDesiredSize);
aDesiredSize,
aReflowState,
aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(subScriptFrame, subScriptSize, bmSubScript);

View File

@ -57,13 +57,17 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
static nsresult
PlaceSubSupScript(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aForFrame,
nscoord aUserSubScriptShift = 0,
nscoord aUserSupScriptShift = 0,

View File

@ -84,7 +84,9 @@ nsMathMLmsupFrame::TransmitAutomaticData()
NS_IMETHODIMP
nsMathMLmsupFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
// extra spacing after sup/subscript
nscoord scriptSpace = NSFloatPointsToTwips(0.5f); // 0.5pt as in plain TeX
@ -105,6 +107,8 @@ nsMathMLmsupFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this,
supScriptShift,
scriptSpace);
@ -117,6 +121,8 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aFrame,
nscoord aUserSupScriptShift,
nscoord aScriptSpace)
@ -145,7 +151,9 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPresContext* aPresContext,
NS_WARNING("invalid markup");
return NS_STATIC_CAST(nsMathMLContainerFrame*,
aFrame)->ReflowError(aRenderingContext,
aDesiredSize);
aDesiredSize,
aReflowState,
aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(supScriptFrame, supScriptSize, bmSupScript);

View File

@ -57,13 +57,17 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
static nsresult
PlaceSuperScript (nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aForFrame,
nscoord aUserSupScriptShift = 0,
nscoord aScriptSpace = NSFloatPointsToTwips(0.5f));

View File

@ -248,7 +248,9 @@ i.e.,:
NS_IMETHODIMP
nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
@ -257,6 +259,8 @@ nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this);
}
@ -273,7 +277,7 @@ nsMathMLmunderFrame::Place(nsIRenderingContext& aRenderingContext,
if (!baseFrame || !underFrame || underFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);

View File

@ -54,7 +54,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent);

View File

@ -285,7 +285,9 @@ i.e.,:
NS_IMETHODIMP
nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
@ -294,6 +296,8 @@ nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
aRenderingContext,
aPlaceOrigin,
aDesiredSize,
aReflowState,
aStatus,
this);
}
@ -314,7 +318,7 @@ nsMathMLmunderoverFrame::Place(nsIRenderingContext& aRenderingContext,
if (!baseFrame || !underFrame || !overFrame || overFrame->GetNextSibling()) {
// report an error, encourage people to get their markups in order
NS_WARNING("invalid markup");
return ReflowError(aRenderingContext, aDesiredSize);
return ReflowError(aRenderingContext, aDesiredSize, aReflowState, aStatus);
}
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);

View File

@ -54,7 +54,9 @@ public:
NS_IMETHOD
Place(nsIRenderingContext& aRenderingContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
NS_IMETHOD
InheritAutomaticData(nsIFrame* aParent);