From 23976acf026d0e16b944fe0e3ea98eb125338116 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sat, 18 Jan 2003 15:21:33 +0000 Subject: [PATCH] Make nsContinuingTextFrame::GetFirstInFlow not crash. b=189515 r+sr=bzbarsky --- layout/generic/nsTextFrame.cpp | 13 ++++++++----- layout/html/base/src/nsTextFrame.cpp | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 56582bfc8818..e5cd1d43dd20 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -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; } diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index 56582bfc8818..e5cd1d43dd20 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -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; }