Bug 515534. Simplify some nsTableRowGroupFrame methods by assuming that the frame constructor did not screw up. r=bernd
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 18 Sep 2009 14:52:58 -0400
changeset 32866 7e9a167a9c7f502450e7ea3f366b2b0ef40c0e71
parent 32865 dec9bfcc8de53b5dbba29817f9b6395edf4530f0
child 32867 d1f1ad39e10e4f263db7d956cfcd02d917fef70c
push idunknown
push userunknown
push dateunknown
reviewersbernd
bugs515534
milestone1.9.3a1pre
Bug 515534. Simplify some nsTableRowGroupFrame methods by assuming that the frame constructor did not screw up. r=bernd
layout/tables/nsTableRowGroupFrame.cpp
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -71,37 +71,37 @@ NS_QUERYFRAME_TAIL_INHERITING(nsHTMLCont
 /* virtual */ PRBool
 nsTableRowGroupFrame::IsContainingBlock() const
 {
   return PR_TRUE;
 }
 
 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<nsTableRowFrame*>(mFrames.FirstChild())->GetRowIndex();
   }
   // if the row group doesn't have any children, get it the hard way
   if (-1 == result) {
     nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
     if (tableFrame) {
       return tableFrame->GetStartRowIndex(*this);
     }
   }