diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 56582bfc881..e5cd1d43dd2 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/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/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 56582bfc881..e5cd1d43dd2 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/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; }