From 6a92d8c036bc11c6aeddeeb08d5c8c21811b6965 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 18 Sep 2009 14:52:58 -0400 Subject: [PATCH] Bug 515534. Simplify some nsTableRowGroupFrame methods by assuming that the frame constructor did not screw up. r=bernd --- layout/tables/nsTableRowGroupFrame.cpp | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index ebb49064f1a..80ee32f6fbd 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -76,27 +76,27 @@ nsTableRowGroupFrame::IsContainingBlock() const PRInt32 nsTableRowGroupFrame::GetRowCount() -{ - PRInt32 count = 0; // init return - - // loop through children, adding one to aCount for every legit row - for (nsIFrame* childFrame = mFrames.FirstChild(); - childFrame; childFrame = childFrame->GetNextSibling()) { - if (NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay) - count++; +{ +#ifdef DEBUG + for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) { + NS_ASSERTION(e.get()->GetStyleDisplay()->mDisplay == + NS_STYLE_DISPLAY_TABLE_ROW, + "Unexpected display"); + NS_ASSERTION(e.get()->GetType() == nsGkAtoms::tableRowFrame, + "Unexpected frame type"); } - return count; +#endif + + return mFrames.GetLength(); } PRInt32 nsTableRowGroupFrame::GetStartRowIndex() { PRInt32 result = -1; - for (nsIFrame* childFrame = mFrames.FirstChild(); - childFrame; childFrame = childFrame->GetNextSibling()) { - if (NS_STYLE_DISPLAY_TABLE_ROW == childFrame->GetStyleDisplay()->mDisplay) { - result = ((nsTableRowFrame *)childFrame)->GetRowIndex(); - break; - } + if (mFrames.NotEmpty()) { + NS_ASSERTION(mFrames.FirstChild()->GetType() == nsGkAtoms::tableRowFrame, + "Unexpected frame type"); + result = static_cast(mFrames.FirstChild())->GetRowIndex(); } // if the row group doesn't have any children, get it the hard way if (-1 == result) {