Make nsContinuingTextFrame::GetFirstInFlow not crash. b=189515 r+sr=bzbarsky

This commit is contained in:
dbaron%dbaron.org 2003-01-18 15:21:33 +00:00
parent 3a031bcf35
commit 23976acf02
2 changed files with 16 additions and 10 deletions

View File

@ -966,11 +966,14 @@ nsContinuingTextFrame::Destroy(nsIPresContext* aPresContext)
nsIFrame*
nsContinuingTextFrame::GetFirstInFlow() const
{
nsContinuingTextFrame* firstInFlow = (nsContinuingTextFrame*)this;
while (firstInFlow->mPrevInFlow) {
firstInFlow = (nsContinuingTextFrame*)firstInFlow->mPrevInFlow;
}
NS_POSTCONDITION(firstInFlow, "illegal state in flow chain.");
// Can't cast to |nsContinuingTextFrame*| because the first one isn't.
nsIFrame *firstInFlow,
*previous = NS_CONST_CAST(nsIFrame*,
NS_STATIC_CAST(const nsIFrame*, this));
do {
firstInFlow = previous;
firstInFlow->GetPrevInFlow(&previous);
} while (previous);
return firstInFlow;
}

View File

@ -966,11 +966,14 @@ nsContinuingTextFrame::Destroy(nsIPresContext* aPresContext)
nsIFrame*
nsContinuingTextFrame::GetFirstInFlow() const
{
nsContinuingTextFrame* firstInFlow = (nsContinuingTextFrame*)this;
while (firstInFlow->mPrevInFlow) {
firstInFlow = (nsContinuingTextFrame*)firstInFlow->mPrevInFlow;
}
NS_POSTCONDITION(firstInFlow, "illegal state in flow chain.");
// Can't cast to |nsContinuingTextFrame*| because the first one isn't.
nsIFrame *firstInFlow,
*previous = NS_CONST_CAST(nsIFrame*,
NS_STATIC_CAST(const nsIFrame*, this));
do {
firstInFlow = previous;
firstInFlow->GetPrevInFlow(&previous);
} while (previous);
return firstInFlow;
}