Back to index

lightning-sunbird  0.9+nobinonly
nsTableRowFrame.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #include "nsTableRowFrame.h"
00038 #include "nsTableRowGroupFrame.h"
00039 #include "nsIRenderingContext.h"
00040 #include "nsIPresShell.h"
00041 #include "nsPresContext.h"
00042 #include "nsStyleContext.h"
00043 #include "nsStyleConsts.h"
00044 #include "nsHTMLAtoms.h"
00045 #include "nsIContent.h"
00046 #include "nsTableFrame.h"
00047 #include "nsTableCellFrame.h"
00048 #include "nsIView.h"
00049 #include "nsReflowPath.h"
00050 #include "nsCSSRendering.h"
00051 #include "nsLayoutAtoms.h"
00052 #include "nsHTMLParts.h"
00053 #include "nsTableColGroupFrame.h"
00054 #include "nsTableColFrame.h"
00055 #include "nsCOMPtr.h"
00056 
00057 
00058 struct nsTableCellReflowState : public nsHTMLReflowState
00059 {
00060   nsTableCellReflowState(nsPresContext*          aPresContext,
00061                          const nsHTMLReflowState& aParentReflowState,
00062                          nsIFrame*                aFrame,
00063                          const nsSize&            aAvailableSpace,
00064                          nsReflowReason           aReason);
00065 
00066   void FixUp(const nsSize& aAvailSpace,
00067              PRBool        aResetComputedWidth);
00068 };
00069 
00070 nsTableCellReflowState::nsTableCellReflowState(nsPresContext*          aPresContext,
00071                                                const nsHTMLReflowState& aParentRS,
00072                                                nsIFrame*                aFrame,
00073                                                const nsSize&            aAvailSpace,
00074                                                nsReflowReason           aReason)
00075   :nsHTMLReflowState(aPresContext, aParentRS, aFrame, aAvailSpace, aReason)
00076 {
00077 }
00078 
00079 void nsTableCellReflowState::FixUp(const nsSize& aAvailSpace,
00080                                    PRBool        aResetComputedWidth)
00081 {
00082   // fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
00083   if (NS_UNCONSTRAINEDSIZE != aAvailSpace.width) {
00084     if (aResetComputedWidth) {
00085       mComputedWidth = NS_UNCONSTRAINEDSIZE;
00086     }
00087     else if (NS_UNCONSTRAINEDSIZE != mComputedWidth) {
00088       mComputedWidth = aAvailSpace.width - mComputedBorderPadding.left - mComputedBorderPadding.right;
00089       mComputedWidth = PR_MAX(0, mComputedWidth);
00090     }
00091     if (NS_UNCONSTRAINEDSIZE != mComputedHeight) {
00092       if (NS_UNCONSTRAINEDSIZE != aAvailSpace.height) {
00093         mComputedHeight = aAvailSpace.height - mComputedBorderPadding.top - mComputedBorderPadding.bottom;
00094         mComputedHeight = PR_MAX(0, mComputedHeight);
00095       }
00096     }
00097   }
00098 }
00099 
00100 void
00101 nsTableRowFrame::InitChildReflowState(nsPresContext&         aPresContext,
00102                                       const nsSize&           aAvailSize,
00103                                       PRBool                  aBorderCollapse,
00104                                       float                   aPixelsToTwips,
00105                                       nsTableCellReflowState& aReflowState,
00106                                       PRBool                  aResetComputedWidth)
00107 {
00108   nsMargin collapseBorder;
00109   nsMargin* pCollapseBorder = nsnull;
00110   if (aBorderCollapse) {
00111     // we only reflow cells, so don't need to check frame type
00112     nsBCTableCellFrame* bcCellFrame = (nsBCTableCellFrame*)aReflowState.frame;
00113     if (bcCellFrame) {
00114       pCollapseBorder = bcCellFrame->GetBorderWidth(aPixelsToTwips, collapseBorder);
00115     }
00116   }
00117   aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder);
00118   aReflowState.FixUp(aAvailSize, aResetComputedWidth);
00119 }
00120 
00121 void 
00122 nsTableRowFrame::SetFixedHeight(nscoord aValue)
00123 {
00124   nscoord height = PR_MAX(0, aValue);
00125   if (HasFixedHeight()) {
00126     if (height > mStyleFixedHeight) {
00127       mStyleFixedHeight = height;
00128     }
00129   }
00130   else {
00131     mStyleFixedHeight = height;
00132     if (height > 0) {
00133       SetHasFixedHeight(PR_TRUE);
00134     }
00135   }
00136 }
00137 
00138 void 
00139 nsTableRowFrame::SetPctHeight(float  aPctValue,
00140                               PRBool aForce)
00141 {
00142   nscoord height = PR_MAX(0, NSToCoordRound(aPctValue * 100.0f));
00143   if (HasPctHeight()) {
00144     if ((height > mStylePctHeight) || aForce) {
00145       mStylePctHeight = height;
00146     }
00147   }
00148   else {
00149     mStylePctHeight = height;
00150     if (height > 0.0f) {
00151       SetHasPctHeight(PR_TRUE);
00152     }
00153   }
00154 }
00155 
00156 // 'old' is old cached cell's desired size
00157 // 'new' is new cell's size including style constraints
00158 static PRBool
00159 TallestCellGotShorter(nscoord aOld,
00160                       nscoord aNew,
00161                       nscoord aTallest)
00162 {
00163   return ((aNew < aOld) && (aOld == aTallest));
00164 }
00165 
00166 /* ----------- nsTableRowFrame ---------- */
00167 
00168 nsTableRowFrame::nsTableRowFrame()
00169   : nsHTMLContainerFrame()
00170 {
00171   mBits.mRowIndex = mBits.mFirstInserted = 0;
00172   ResetHeight(0);
00173 #ifdef DEBUG_TABLE_REFLOW_TIMING
00174   mTimer = new nsReflowTimer(this);
00175 #endif
00176 }
00177 
00178 nsTableRowFrame::~nsTableRowFrame()
00179 {
00180 #ifdef DEBUG_TABLE_REFLOW_TIMING
00181   nsTableFrame::DebugReflowDone(this);
00182 #endif
00183 }
00184 
00185 NS_IMETHODIMP
00186 nsTableRowFrame::Init(nsPresContext*  aPresContext,
00187                       nsIContent*      aContent,
00188                       nsIFrame*        aParent,
00189                       nsStyleContext*  aContext,
00190                       nsIFrame*        aPrevInFlow)
00191 {
00192   nsresult  rv;
00193 
00194   // Let the the base class do its initialization
00195   rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext,
00196                                   aPrevInFlow);
00197 
00198   // record that children that are ignorable whitespace should be excluded 
00199   mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
00200 
00201   if (aPrevInFlow) {
00202     // Set the row index
00203     nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;
00204     
00205     SetRowIndex(rowFrame->GetRowIndex());
00206   }
00207 
00208   return rv;
00209 }
00210 
00211 
00212 NS_IMETHODIMP
00213 nsTableRowFrame::AppendFrames(nsIAtom*        aListName,
00214                               nsIFrame*       aFrameList)
00215 {
00216   // Append the frames
00217   mFrames.AppendFrames(nsnull, aFrameList);
00218 
00219   // Add the new cell frames to the table
00220   nsTableFrame *tableFrame = nsnull;
00221   nsTableFrame::GetTableFrame(this, tableFrame);
00222   for (nsIFrame* childFrame = aFrameList; childFrame;
00223        childFrame = childFrame->GetNextSibling()) {
00224     if (IS_TABLE_CELL(childFrame->GetType())) {
00225       // Add the cell to the cell map
00226       tableFrame->AppendCell((nsTableCellFrame&)*childFrame, GetRowIndex());
00227       // XXX this could be optimized with some effort
00228       tableFrame->SetNeedStrategyInit(PR_TRUE);
00229     }
00230   }
00231 
00232   // Reflow the new frames. They're already marked dirty, so generate a reflow
00233   // command that tells us to reflow our dirty child frames
00234   tableFrame->AppendDirtyReflowCommand(this);
00235 
00236   return NS_OK;
00237 }
00238 
00239 
00240 NS_IMETHODIMP
00241 nsTableRowFrame::InsertFrames(nsIAtom*        aListName,
00242                               nsIFrame*       aPrevFrame,
00243                               nsIFrame*       aFrameList)
00244 {
00245   // Get the table frame
00246   nsTableFrame* tableFrame = nsnull;
00247   nsTableFrame::GetTableFrame(this, tableFrame);
00248   
00249   // gather the new frames (only those which are cells) into an array
00250   nsIAtom* cellFrameType = (tableFrame->IsBorderCollapse()) ? nsLayoutAtoms::bcTableCellFrame : nsLayoutAtoms::tableCellFrame;
00251   nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
00252   nsVoidArray cellChildren;
00253   for (nsIFrame* childFrame = aFrameList; childFrame;
00254        childFrame = childFrame->GetNextSibling()) {
00255     if (IS_TABLE_CELL(childFrame->GetType())) {
00256       cellChildren.AppendElement(childFrame);
00257       // XXX this could be optimized with some effort
00258       tableFrame->SetNeedStrategyInit(PR_TRUE);
00259     }
00260   }
00261   // insert the cells into the cell map
00262   PRInt32 colIndex = -1;
00263   if (prevCellFrame) {
00264     prevCellFrame->GetColIndex(colIndex);
00265   }
00266   tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
00267 
00268   // Insert the frames in the frame list
00269   mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
00270   
00271   // Reflow the new frames. They're already marked dirty, so generate a reflow
00272   // command that tells us to reflow our dirty child frames
00273   tableFrame->AppendDirtyReflowCommand(this);
00274 
00275   return NS_OK;
00276 }
00277 
00278 NS_IMETHODIMP
00279 nsTableRowFrame::RemoveFrame(nsIAtom*        aListName,
00280                              nsIFrame*       aOldFrame)
00281 {
00282   // Get the table frame
00283   nsTableFrame* tableFrame=nsnull;
00284   nsTableFrame::GetTableFrame(this, tableFrame);
00285   if (tableFrame) {
00286     if (IS_TABLE_CELL(aOldFrame->GetType())) {
00287       nsTableCellFrame* cellFrame = (nsTableCellFrame*)aOldFrame;
00288       PRInt32 colIndex;
00289       cellFrame->GetColIndex(colIndex);
00290       // remove the cell from the cell map
00291       tableFrame->RemoveCell(cellFrame, GetRowIndex());
00292       // XXX this could be optimized with some effort
00293       tableFrame->SetNeedStrategyInit(PR_TRUE);
00294 
00295       // Remove the frame and destroy it
00296       mFrames.DestroyFrame(GetPresContext(), aOldFrame);
00297 
00298       // XXX This could probably be optimized with much effort
00299       tableFrame->SetNeedStrategyInit(PR_TRUE);
00300       // Generate a reflow command so we reflow the table itself.
00301       // Target the row so that it gets a dirty reflow before a resize reflow
00302       // in case another cell gets added to the row during a reflow coallesce.
00303       tableFrame->AppendDirtyReflowCommand(this);
00304     }
00305   }
00306 
00307   return NS_OK;
00308 }
00309 
00310 nscoord 
00311 GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
00312                                  nsTableFrame&     aTableFrame)
00313 {
00314   nscoord height = 0;
00315   nscoord cellSpacingY = aTableFrame.GetCellSpacingY();
00316   PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(aTableCellFrame);
00317   // add in height of rows spanned beyond the 1st one
00318   nsIFrame* nextRow = aTableCellFrame.GetParent()->GetNextSibling();
00319   for (PRInt32 rowX = 1; ((rowX < rowSpan) && nextRow);) {
00320     if (nsLayoutAtoms::tableRowFrame == nextRow->GetType()) {
00321       height += nextRow->GetSize().height;
00322       rowX++;
00323     }
00324     height += cellSpacingY;
00325     nextRow = nextRow->GetNextSibling();
00326   }
00327   return height;
00328 }
00329 
00330 nsTableCellFrame*  
00331 nsTableRowFrame::GetFirstCell() 
00332 {
00333   nsIFrame* childFrame = mFrames.FirstChild();
00334   while (childFrame) {
00335     if (IS_TABLE_CELL(childFrame->GetType())) {
00336       return (nsTableCellFrame*)childFrame;
00337     }
00338     childFrame = childFrame->GetNextSibling();
00339   }
00340   return nsnull;
00341 }
00342 
00346 void
00347 nsTableRowFrame::DidResize(nsPresContext*          aPresContext,
00348                            const nsHTMLReflowState& aReflowState)
00349 {
00350   // Resize and re-align the cell frames based on our row height
00351   nsTableFrame* tableFrame;
00352   nsTableFrame::GetTableFrame(this, tableFrame);
00353   if (!tableFrame) return;
00354   
00355   nsTableIterator iter(*this, eTableDIR);
00356   nsIFrame* childFrame = iter.First();
00357   
00358   nsHTMLReflowMetrics desiredSize(PR_FALSE);
00359   desiredSize.width = mRect.width;
00360   desiredSize.height = mRect.height;
00361   desiredSize.mOverflowArea = nsRect(0, 0, desiredSize.width,
00362                                       desiredSize.height);
00363 
00364   while (childFrame) {
00365     if (IS_TABLE_CELL(childFrame->GetType())) {
00366       nsTableCellFrame* cellFrame = (nsTableCellFrame*)childFrame;
00367       nscoord cellHeight = mRect.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, *tableFrame);
00368 
00369       // resize the cell's height
00370       //if (cellFrameSize.height!=cellHeight)
00371       {
00372         // XXX If the cell frame has a view, then we need to resize
00373         // it as well. We would like to only do that if the cell's size
00374         // is changing. Why is the 'if' stmt above commented out?
00375         cellFrame->SetSize(nsSize(cellFrame->GetSize().width, cellHeight));
00376         // realign cell content based on the new height
00377         /*nsHTMLReflowMetrics desiredSize(nsnull);
00378         nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
00379                                          cellFrame,
00380                                          nsSize(cellFrameSize.width, cellHeight),
00381                                          eReflowReason_Resize);*/
00382         //XXX: the following reflow is necessary for any content of the cell
00383         //     whose height is a percent of the cell's height (maybe indirectly.)
00384         //     But some content crashes when this reflow is issued, to be investigated
00385         //XXX nsReflowStatus status;
00386         //ReflowChild(cellFrame, aPresContext, desiredSize, kidReflowState, status);
00387 
00388         cellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
00389         ConsiderChildOverflow(desiredSize.mOverflowArea, cellFrame);
00390       }
00391     }
00392     // Get the next child
00393     childFrame = iter.Next();
00394   }
00395   FinishAndStoreOverflow(&desiredSize);
00396   if (HasView()) {
00397     nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, this, GetView(), &desiredSize.mOverflowArea, 0);
00398   }
00399   // Let our base class do the usual work
00400 }
00401 
00402 // returns max-ascent amongst all cells that have 'vertical-align: baseline'
00403 // *including* cells with rowspans
00404 nscoord nsTableRowFrame::GetMaxCellAscent() const
00405 {
00406   return mMaxCellAscent;
00407 }
00408 
00409 nscoord
00410 nsTableRowFrame::GetHeight(nscoord aPctBasis) const
00411 {
00412   nscoord height = 0;
00413   if ((aPctBasis > 0) && HasPctHeight()) {
00414     height = NSToCoordRound(GetPctHeight() * (float)aPctBasis);
00415   }
00416   if (HasFixedHeight()) {
00417     height = PR_MAX(height, GetFixedHeight());
00418   }
00419   return PR_MAX(height, GetContentHeight());
00420 }
00421 
00422 void 
00423 nsTableRowFrame::ResetHeight(nscoord aFixedHeight)
00424 {
00425   SetHasFixedHeight(PR_FALSE);
00426   SetHasPctHeight(PR_FALSE);
00427   SetFixedHeight(0);
00428   SetPctHeight(0);
00429   SetContentHeight(0);
00430 
00431   if (aFixedHeight > 0) {
00432     SetFixedHeight(aFixedHeight);
00433   }
00434 
00435   mMaxCellAscent = 0;
00436   mMaxCellDescent = 0;
00437 }
00438 
00439 void
00440 nsTableRowFrame::UpdateHeight(nscoord           aHeight,
00441                               nscoord           aAscent,
00442                               nscoord           aDescent,
00443                               nsTableFrame*     aTableFrame,
00444                               nsTableCellFrame* aCellFrame)
00445 {
00446   if (!aTableFrame || !aCellFrame) {
00447     NS_ASSERTION(PR_FALSE , "invalid call");
00448     return;
00449   }
00450 
00451   if (aHeight != NS_UNCONSTRAINEDSIZE) {
00452     if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
00453       if (GetHeight() < aHeight) {
00454         PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
00455         if (rowSpan == 1) {
00456           SetContentHeight(aHeight);
00457         }
00458       }
00459     }
00460     else { // the alignment on the baseline can change the height
00461       NS_ASSERTION((aAscent != NS_UNCONSTRAINEDSIZE) && (aDescent != NS_UNCONSTRAINEDSIZE), "invalid call");
00462       // see if this is a long ascender
00463       if (mMaxCellAscent < aAscent) {
00464         mMaxCellAscent = aAscent;
00465       }
00466       // see if this is a long descender and without rowspan
00467       if (mMaxCellDescent < aDescent) {
00468         PRInt32 rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
00469         if (rowSpan == 1) {
00470           mMaxCellDescent = aDescent;
00471         }
00472       }
00473       // keep the tallest height in sync
00474       if (GetHeight() < mMaxCellAscent + mMaxCellDescent) {
00475         SetContentHeight(mMaxCellAscent + mMaxCellDescent);
00476       }
00477     }
00478   }
00479 }
00480 
00481 nscoord
00482 nsTableRowFrame::CalcHeight(const nsHTMLReflowState& aReflowState)
00483 {
00484   nsTableFrame* tableFrame = nsnull;
00485   nsTableFrame::GetTableFrame(this, tableFrame);
00486   if (!tableFrame) return 0;
00487 
00488   nscoord computedHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.mComputedHeight)
00489                             ? 0 : aReflowState.mComputedHeight;
00490   ResetHeight(computedHeight);
00491 
00492   const nsStylePosition* position = GetStylePosition();
00493   if (eStyleUnit_Coord == position->mHeight.GetUnit()) {
00494     SetFixedHeight(position->mHeight.GetCoordValue());
00495   }
00496   else if (eStyleUnit_Percent == position->mHeight.GetUnit()) {
00497     SetPctHeight(position->mHeight.GetPercentValue());
00498   }
00499 
00500   for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
00501        kidFrame = kidFrame->GetNextSibling()) {
00502     if (IS_TABLE_CELL(kidFrame->GetType())) {
00503       nscoord availWidth = ((nsTableCellFrame *)kidFrame)->GetPriorAvailWidth();
00504       nsSize desSize = ((nsTableCellFrame *)kidFrame)->GetDesiredSize();
00505       if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) && !mPrevInFlow) {
00506         CalculateCellActualSize(kidFrame, desSize.width, desSize.height, availWidth);
00507       }
00508       // height may have changed, adjust descent to absorb any excess difference
00509       nscoord ascent = ((nsTableCellFrame *)kidFrame)->GetDesiredAscent();
00510       nscoord descent = desSize.height - ascent;
00511       UpdateHeight(desSize.height, ascent, descent, tableFrame, (nsTableCellFrame*)kidFrame);
00512     }
00513   }
00514   return GetHeight();
00515 }
00516 
00517 NS_METHOD nsTableRowFrame::Paint(nsPresContext*      aPresContext,
00518                                  nsIRenderingContext& aRenderingContext,
00519                                  const nsRect&        aDirtyRect,
00520                                  nsFramePaintLayer    aWhichLayer,
00521                                  PRUint32             aFlags)
00522 {
00523   PRBool isVisible;
00524   if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
00525     return NS_OK;
00526   }
00527 
00528 #ifdef DEBUG
00529   // for debug...
00530   if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
00531     aRenderingContext.SetColor(NS_RGB(0,255,0));
00532     aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
00533   }
00534 #endif
00535 
00536   if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
00537       //direct (not table-called) background paint
00538       !(aFlags & (NS_PAINT_FLAG_TABLE_BG_PAINT | NS_PAINT_FLAG_TABLE_CELL_BG_PASS))) {
00539     nsTableFrame* tableFrame;
00540     nsTableFrame::GetTableFrame(this, tableFrame);
00541     NS_ASSERTION(tableFrame, "null table frame");
00542 
00543     TableBackgroundPainter painter(tableFrame,
00544                                    TableBackgroundPainter::eOrigin_TableRow,
00545                                    aPresContext, aRenderingContext,
00546                                    aDirtyRect);
00547     nsresult rv = painter.PaintRow(this);
00548     if (NS_FAILED(rv)) return rv;
00549     aFlags |= NS_PAINT_FLAG_TABLE_BG_PAINT;
00550   }
00551 
00552   PRBool clip = GetStyleDisplay()->IsTableClip();
00553   if (clip) {
00554     aRenderingContext.PushState();
00555     SetOverflowClipRect(aRenderingContext);
00556   }
00557   PaintChildren(aPresContext, aRenderingContext, aDirtyRect,
00558                 aWhichLayer, aFlags);
00559 
00560   // Paint outline
00561   nsRect rect(0, 0, mRect.width, mRect.height);
00562   const nsStyleOutline* outlineStyle = GetStyleOutline();
00563   const nsStyleBorder* borderStyle  = GetStyleBorder();
00564   nsCSSRendering::PaintOutline(aPresContext, aRenderingContext, this,
00565                                aDirtyRect, rect, *borderStyle, *outlineStyle,
00566                                mStyleContext, 0);
00567   if (clip)
00568     aRenderingContext.PopState();
00569   return NS_OK;
00570 
00571 }
00572 
00573 PRIntn
00574 nsTableRowFrame::GetSkipSides() const
00575 {
00576   PRIntn skip = 0;
00577   if (nsnull != mPrevInFlow) {
00578     skip |= 1 << NS_SIDE_TOP;
00579   }
00580   if (nsnull != mNextInFlow) {
00581     skip |= 1 << NS_SIDE_BOTTOM;
00582   }
00583   return skip;
00584 }
00585 
00586 
00587 /* we overload this here because rows have children that can span outside of themselves.
00588  * so the default "get the child rect, see if it contains the event point" action isn't
00589  * sufficient.  We have to ask the row if it has a child that contains the point.
00590  */
00591 NS_IMETHODIMP
00592 nsTableRowFrame::GetFrameForPoint(const nsPoint&    aPoint,
00593                                        nsFramePaintLayer aWhichLayer,
00594                                        nsIFrame**        aFrame)
00595 {
00596   // XXX This would not need to exist (except as a one-liner, to make this
00597   // frame work like a block frame) if rows with rowspan cells made the
00598   // the NS_FRAME_OUTSIDE_CHILDREN bit of mState set correctly (see
00599   // nsIFrame.h).
00600 
00601   // XXXldb Do we need this anymore?
00602 
00603   // I imagine fixing this would help performance of GetFrameForPoint in
00604   // tables.  It may also fix problems with relative positioning.
00605 
00606   // This is basically copied from nsContainerFrame::GetFrameForPointUsing,
00607   // except for one bit removed
00608 
00609   nsIFrame *hit;
00610   nsPoint tmp;
00611 
00612   nsIFrame* kid = GetFirstChild(nsnull);
00613   *aFrame = nsnull;
00614   tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
00615   while (nsnull != kid) {
00616     nsresult rv = kid->GetFrameForPoint(tmp, aWhichLayer, &hit);
00617 
00618     if (NS_SUCCEEDED(rv) && hit) {
00619       *aFrame = hit;
00620     }
00621     kid = kid->GetNextSibling();
00622   }
00623 
00624   if (*aFrame) {
00625     return NS_OK;
00626   }
00627 
00628   return NS_ERROR_FAILURE;
00629 }
00630 
00631 // Calculate the cell's actual size given its pass2 desired width and height.
00632 // Takes into account the specified height (in the style), and any special logic
00633 // needed for backwards compatibility.
00634 // Modifies the desired width and height that are passed in.
00635 nsresult
00636 nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
00637                                          nscoord&  aDesiredWidth,
00638                                          nscoord&  aDesiredHeight,
00639                                          nscoord   aAvailWidth)
00640 {
00641   nscoord specifiedHeight = 0;
00642   
00643   // Get the height specified in the style information
00644   const nsStylePosition* position = aCellFrame->GetStylePosition();
00645 
00646   nsTableFrame* tableFrame = nsnull;
00647   nsTableFrame::GetTableFrame(this, tableFrame);
00648   if (!tableFrame) return NS_ERROR_NULL_POINTER;
00649   
00650   PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan((nsTableCellFrame&)*aCellFrame);
00651   
00652   switch (position->mHeight.GetUnit()) {
00653     case eStyleUnit_Coord:
00654       specifiedHeight = position->mHeight.GetCoordValue();
00655       if (1 == rowSpan) 
00656         SetFixedHeight(specifiedHeight);
00657       break;
00658     case eStyleUnit_Percent: {
00659       if (1 == rowSpan) 
00660         SetPctHeight(position->mHeight.GetPercentValue());
00661       // pct heights are handled when all of the cells are finished, so don't set specifiedHeight 
00662       break;
00663     }
00664     case eStyleUnit_Auto:
00665     default:
00666       break;
00667   }
00668 
00669   // If the specified height is greater than the desired height, then use the specified height
00670   if (specifiedHeight > aDesiredHeight)
00671     aDesiredHeight = specifiedHeight;
00672  
00673   if ((0 == aDesiredWidth) && (NS_UNCONSTRAINEDSIZE != aAvailWidth)) { // special Nav4 compatibility code for the width
00674     aDesiredWidth = aAvailWidth;
00675   } 
00676 
00677   return NS_OK;
00678 }
00679 
00680 // Calculates the available width for the table cell based on the known
00681 // column widths taking into account column spans and column spacing
00682 static void 
00683 CalcAvailWidth(nsTableFrame&     aTableFrame,
00684                nscoord           aTableComputedWidth,
00685                float             aPixelToTwips,
00686                nsTableCellFrame& aCellFrame,
00687                nscoord           aCellSpacingX,
00688                nscoord&          aColAvailWidth,
00689                nscoord&          aCellAvailWidth)
00690 {
00691   aColAvailWidth = aCellAvailWidth = NS_UNCONSTRAINEDSIZE;
00692   PRInt32 colIndex;
00693   aCellFrame.GetColIndex(colIndex);
00694   PRInt32 colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
00695   nscoord cellSpacing = 0;
00696 
00697   for (PRInt32 spanX = 0; spanX < colspan; spanX++) {
00698     nscoord colWidth = aTableFrame.GetColumnWidth(colIndex + spanX);
00699     if (colWidth != WIDTH_NOT_SET) {
00700       if (NS_UNCONSTRAINEDSIZE == aColAvailWidth) {
00701         aColAvailWidth = colWidth; 
00702       }
00703       else {
00704         aColAvailWidth += colWidth;
00705       }
00706     }
00707     if ((spanX > 0) && (aTableFrame.GetNumCellsOriginatingInCol(colIndex + spanX) > 0)) {
00708       cellSpacing += aCellSpacingX;
00709     }
00710   }
00711   if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
00712     aColAvailWidth += cellSpacing;
00713   } 
00714   aCellAvailWidth = aColAvailWidth;
00715 
00716   // for a cell with a colspan > 1, use its fix width (if set) as the avail width 
00717   // if this is its initial reflow
00718   if ((aCellFrame.GetStateBits() & NS_FRAME_FIRST_REFLOW)
00719       && (aTableFrame.GetEffectiveColSpan(aCellFrame) > 1)) {
00720     // see if the cell has a style width specified
00721     const nsStylePosition* cellPosition = aCellFrame.GetStylePosition();
00722     if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
00723       // need to add padding into fixed width
00724       nsMargin borderPadding(0,0,0,0);
00725       if (NS_UNCONSTRAINEDSIZE != aTableComputedWidth) {
00726         borderPadding = nsTableFrame::GetBorderPadding(nsSize(aTableComputedWidth, 0), 
00727                                                        aPixelToTwips,  &aCellFrame);
00728       }
00729       nscoord fixWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
00730       if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
00731         aCellAvailWidth = PR_MIN(aColAvailWidth, fixWidth);
00732       } else {
00733         aCellAvailWidth = fixWidth;
00734       }
00735     }
00736   }
00737 }
00738 
00739 nscoord
00740 GetSpaceBetween(PRInt32       aPrevColIndex,
00741                 PRInt32       aColIndex,
00742                 PRInt32       aColSpan,
00743                 nsTableFrame& aTableFrame,
00744                 nscoord       aCellSpacingX,
00745                 PRBool        aIsLeftToRight)
00746 {
00747   nscoord space = 0;
00748   PRInt32 colX;
00749   if (aIsLeftToRight) {
00750     for (colX = aPrevColIndex + 1; aColIndex > colX; colX++) {
00751       space += aTableFrame.GetColumnWidth(colX);
00752       if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
00753         space += aCellSpacingX;
00754       }
00755     }
00756   } 
00757   else {
00758     PRInt32 lastCol = aColIndex + aColSpan - 1;
00759     for (colX = aPrevColIndex - 1; colX > lastCol; colX--) {
00760       space += aTableFrame.GetColumnWidth(colX);
00761       if (aTableFrame.GetNumCellsOriginatingInCol(colX) > 0) {
00762         space += aCellSpacingX;
00763       }
00764     }
00765   }
00766   return space;
00767 }
00768 
00769 static nscoord
00770 GetComputedWidth(const nsHTMLReflowState& aReflowState,
00771                  nsTableFrame&            aTableFrame)
00772 {
00773   const nsHTMLReflowState* parentReflow = aReflowState.parentReflowState;
00774   nscoord computedWidth = 0;
00775   while (parentReflow) {
00776     if (parentReflow->frame == &aTableFrame) {
00777       computedWidth = parentReflow->mComputedWidth;
00778       break;
00779     }
00780     parentReflow = parentReflow->parentReflowState;
00781   }
00782   return computedWidth;
00783 }
00784 
00785 // subtract the heights of aRow's prev in flows from the unpaginated height
00786 static
00787 nscoord CalcHeightFromUnpaginatedHeight(nsPresContext*  aPresContext,
00788                                         nsTableRowFrame& aRow)
00789 {
00790   nscoord height = 0;
00791   nsTableRowFrame* firstInFlow = (nsTableRowFrame*)aRow.GetFirstInFlow();
00792   if (!firstInFlow) ABORT1(0);
00793   if (firstInFlow->HasUnpaginatedHeight()) {
00794     height = firstInFlow->GetUnpaginatedHeight(aPresContext);
00795     for (nsIFrame* prevInFlow = aRow.GetPrevInFlow(); prevInFlow;
00796          prevInFlow = prevInFlow->GetPrevInFlow()) {
00797       height -= prevInFlow->GetSize().height;
00798     }
00799   }
00800   return PR_MAX(height, 0);
00801 }
00802 
00803 // Called for a dirty or resize reflow. Reflows all the existing table cell 
00804 // frames unless aDirtyOnly is PR_TRUE in which case only reflow the dirty frames
00805 
00806 NS_METHOD 
00807 nsTableRowFrame::ReflowChildren(nsPresContext*          aPresContext,
00808                                 nsHTMLReflowMetrics&     aDesiredSize,
00809                                 const nsHTMLReflowState& aReflowState,
00810                                 nsTableFrame&            aTableFrame,
00811                                 nsReflowStatus&          aStatus,
00812                                 PRBool                   aDirtyOnly)
00813 {
00814   aStatus = NS_FRAME_COMPLETE;
00815 
00816   GET_PIXELS_TO_TWIPS(aPresContext, p2t);
00817   PRBool borderCollapse = (((nsTableFrame*)aTableFrame.GetFirstInFlow())->IsBorderCollapse());
00818 
00819   nsIFrame* tablePrevInFlow = aTableFrame.GetPrevInFlow();
00820   PRBool isPaginated = aPresContext->IsPaginated();
00821 
00822   nsresult rv = NS_OK;
00823 
00824   nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
00825   PRInt32 cellColSpan = 1;  // must be defined here so it's set properly for non-cell kids
00826   
00827   nsTableIteration dir = (aReflowState.availableWidth == NS_UNCONSTRAINEDSIZE)
00828                          ? eTableLTR : eTableDIR;
00829   nsTableIterator iter(*this, dir);
00830   // remember the col index of the previous cell to handle rowspans into this row
00831   PRInt32 firstPrevColIndex = (iter.IsLeftToRight()) ? -1 : aTableFrame.GetColCount();
00832   PRInt32 prevColIndex  = firstPrevColIndex;
00833   nscoord x = 0; // running total of children x offset
00834 
00835   PRBool isAutoLayout = aTableFrame.IsAutoLayout();
00836   PRBool needToNotifyTable = PR_TRUE;
00837   nscoord paginatedHeight = 0;
00838   // If the incremental reflow command is a StyleChanged reflow and
00839   // it's target is the current frame, then make sure we send
00840   // StyleChange reflow reasons down to the children so that they
00841   // don't over-optimize their reflow.
00842 
00843   PRBool notifyStyleChange = PR_FALSE;
00844   if (eReflowReason_Incremental == aReflowState.reason) {
00845     nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
00846     if (command) {
00847       nsReflowType type;
00848       command->GetType(type);
00849       if (eReflowType_StyleChanged == type) {
00850         notifyStyleChange = PR_TRUE;
00851       }
00852     }
00853   }
00854   // Reflow each of our existing cell frames
00855   nsIFrame* kidFrame = iter.First();
00856   while (kidFrame) {
00857     nsIAtom* frameType = kidFrame->GetType();
00858 
00859     // See if we should only reflow the dirty child frames
00860     PRBool doReflowChild = PR_TRUE;
00861     if (aDirtyOnly && ((kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) == 0)) {
00862       doReflowChild = PR_FALSE;
00863     }
00864     else if ((NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) && IS_TABLE_CELL(frameType)) {
00865       // We don't reflow a rowspan >1 cell here with a constrained height. 
00866       // That happens in nsTableRowGroupFrame::SplitSpanningCells.
00867       if (aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame) > 1) {
00868         doReflowChild = PR_FALSE;
00869       }
00870     }
00871     if (aReflowState.mFlags.mSpecialHeightReflow) {
00872       if (!isPaginated && (IS_TABLE_CELL(frameType) &&
00873                            !((nsTableCellFrame*)kidFrame)->NeedSpecialReflow())) {
00874         kidFrame = iter.Next(); 
00875         continue;
00876       }
00877     }
00878 
00879     // Reflow the child frame
00880     if (doReflowChild) {
00881       if (IS_TABLE_CELL(frameType)) {
00882         nsTableCellFrame* cellFrame = (nsTableCellFrame*)kidFrame;
00883         PRInt32 cellColIndex;
00884         cellFrame->GetColIndex(cellColIndex);
00885         cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
00886 
00887         // If the adjacent cell is in a prior row (because of a rowspan) add in the space
00888         if ((iter.IsLeftToRight() && (prevColIndex != (cellColIndex - 1))) ||
00889             (!iter.IsLeftToRight() && (prevColIndex != cellColIndex + cellColSpan))) {
00890           x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame, 
00891                                cellSpacingX, iter.IsLeftToRight());
00892         }
00893         // Calculate the available width for the table cell using the known column widths
00894         nscoord availColWidth, availCellWidth;
00895         CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
00896                        *cellFrame, cellSpacingX, availColWidth, availCellWidth);
00897 
00898         // remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
00899         prevColIndex = (iter.IsLeftToRight()) ? cellColIndex + (cellColSpan - 1) : cellColIndex;
00900         // always request MEW. Since we may turn MEW on for selected cells during incremental
00901         // reflow, we need to request MEW *now* so that those incremental reflows will be
00902         // able to build on existing MEW data in the children.
00903         nsHTMLReflowMetrics desiredSize(PR_TRUE);
00904   
00905         // If the avail width is not the same as last time we reflowed the cell or
00906         // the cell wants to be bigger than what was available last time or
00907         // it is a style change reflow or we are printing, then we must reflow the
00908         // cell. Otherwise we can skip the reflow.
00909         nsIFrame* kidNextInFlow = kidFrame->GetNextInFlow();
00910         nsSize cellDesiredSize = cellFrame->GetDesiredSize();
00911         if ((availCellWidth != cellFrame->GetPriorAvailWidth())       ||
00912             (cellDesiredSize.width > cellFrame->GetPriorAvailWidth()) ||
00913             (eReflowReason_StyleChange == aReflowState.reason)        ||
00914             isPaginated                                               ||
00915             (cellFrame->NeedPass2Reflow() &&
00916              NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)     ||
00917             (aReflowState.mFlags.mSpecialHeightReflow && cellFrame->NeedSpecialReflow()) ||
00918             (!aReflowState.mFlags.mSpecialHeightReflow && cellFrame->HadSpecialReflow()) ||
00919             HasPctHeight()                                            ||
00920             notifyStyleChange) {
00921           // Reflow the cell to fit the available width, height
00922           nsSize  kidAvailSize(availColWidth, aReflowState.availableHeight);
00923           nsReflowReason reason = eReflowReason_Resize;
00924           PRBool cellToWatch = PR_FALSE;
00925           // If it's a dirty frame, then check whether it's the initial reflow
00926           if (kidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
00927             reason = eReflowReason_Initial;
00928             cellToWatch = PR_TRUE;
00929           }
00930           else if (eReflowReason_StyleChange == aReflowState.reason) {
00931             reason = eReflowReason_StyleChange;
00932             cellToWatch = PR_TRUE;
00933           }
00934           else if (notifyStyleChange) {
00935             reason = eReflowReason_StyleChange;
00936             cellToWatch = PR_TRUE;
00937           }
00938           if (cellToWatch) {
00939             cellFrame->DidSetStyleContext(aPresContext); // XXX check this
00940             if (!tablePrevInFlow && isAutoLayout) {
00941               // request the maximum width if availWidth is constrained
00942               // XXX we could just do this always, but blocks have some problems
00943               if (NS_UNCONSTRAINEDSIZE != availCellWidth) {
00944                 desiredSize.mFlags |= NS_REFLOW_CALC_MAX_WIDTH; 
00945               }
00946             }
00947             else {
00948               cellToWatch = PR_FALSE;
00949             }
00950           }
00951   
00952           nscoord oldMaxWidth     = cellFrame->GetMaximumWidth();
00953           nscoord oldMaxElemWidth = cellFrame->GetPass1MaxElementWidth();
00954 
00955           // Reflow the child
00956           nsTableCellReflowState kidReflowState(aPresContext, aReflowState, 
00957                                                 kidFrame, kidAvailSize, reason);
00958           InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse, p2t, kidReflowState);
00959 
00960           nsReflowStatus status;
00961           rv = ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
00962                            x, 0, 0, status);
00963 
00964           if (cellToWatch) { 
00965             nscoord maxWidth = (NS_UNCONSTRAINEDSIZE == availCellWidth) 
00966                                 ? desiredSize.width : desiredSize.mMaximumWidth;
00967             // save the max element width and max width
00968             if (desiredSize.mComputeMEW) {
00969               cellFrame->SetPass1MaxElementWidth(desiredSize.width, desiredSize.mMaxElementWidth);
00970               if (desiredSize.mMaxElementWidth > desiredSize.width) {
00971                 desiredSize.width = desiredSize.mMaxElementWidth;
00972               }
00973             }
00974             cellFrame->SetMaximumWidth(maxWidth);
00975           }
00976 
00977           // allow the table to determine if/how the table needs to be rebalanced
00978           if (cellToWatch && needToNotifyTable) {
00979             needToNotifyTable = !aTableFrame.CellChangedWidth(*cellFrame, oldMaxWidth, oldMaxElemWidth);
00980           }
00981 
00982           // If any of the cells are not complete, then we're not complete
00983           if (NS_FRAME_IS_NOT_COMPLETE(status)) {
00984             aStatus = NS_FRAME_NOT_COMPLETE;
00985           }
00986         }
00987         else { 
00988           desiredSize.width = cellDesiredSize.width;
00989           desiredSize.height = cellDesiredSize.height;
00990           nsRect *overflowArea =
00991             cellFrame->GetOverflowAreaProperty();
00992           if (overflowArea)
00993             desiredSize.mOverflowArea = *overflowArea;
00994           else
00995             desiredSize.mOverflowArea.SetRect(0, 0, cellDesiredSize.width,
00996                                               cellDesiredSize.height);
00997           
00998           // if we are in a floated table, our position is not yet established, so we cannot reposition our views
00999           // the containing glock will do this for us after positioning the table
01000           if (!aTableFrame.GetStyleDisplay()->IsFloating()) {
01001             // Because we may have moved the frame we need to make sure any views are
01002             // positioned properly. We have to do this, because any one of our parent
01003             // frames could have moved and we have no way of knowing...
01004             nsTableFrame::RePositionViews(kidFrame);
01005           }
01006         }
01007         
01008         if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
01009           if (!mPrevInFlow) {
01010             // Calculate the cell's actual size given its pass2 size. This function
01011             // takes into account the specified height (in the style), and any special
01012             // logic needed for backwards compatibility
01013             CalculateCellActualSize(kidFrame, desiredSize.width, 
01014                                     desiredSize.height, availCellWidth);
01015           }
01016           // height may have changed, adjust descent to absorb any excess difference
01017           nscoord ascent = cellFrame->GetDesiredAscent();
01018           nscoord descent = desiredSize.height - ascent;
01019           UpdateHeight(desiredSize.height, ascent, descent, &aTableFrame, cellFrame);
01020         }
01021         else {
01022           paginatedHeight = PR_MAX(paginatedHeight, desiredSize.height);
01023           PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
01024           if (1 == rowSpan) {
01025             SetContentHeight(paginatedHeight);
01026           }
01027         }
01028 
01029         // Place the child
01030         if (NS_UNCONSTRAINEDSIZE != availColWidth) {
01031           desiredSize.width = PR_MAX(availCellWidth, availColWidth);
01032         }
01033 
01034         FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
01035         
01036         x += desiredSize.width;  
01037       }
01038       else {// it's an unknown frame type, give it a generic reflow and ignore the results
01039         nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
01040                                               kidFrame, nsSize(0,0), eReflowReason_Resize);
01041         InitChildReflowState(*aPresContext, nsSize(0,0), PR_FALSE, p2t, kidReflowState);
01042         nsHTMLReflowMetrics desiredSize(PR_FALSE);
01043         nsReflowStatus  status;
01044         ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
01045         kidFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
01046       }
01047     }
01048     else if (IS_TABLE_CELL(frameType)) {
01049       // we need to account for the cell's width even if it isn't reflowed
01050       x += kidFrame->GetSize().width;
01051     }
01052     ConsiderChildOverflow(aDesiredSize.mOverflowArea, kidFrame);
01053     kidFrame = iter.Next(); // Get the next child
01054     x += cellSpacingX;
01055   }
01056 
01057   // just set our width to what was available. The table will calculate the width and not use our value.
01058   aDesiredSize.width = aReflowState.availableWidth;
01059 
01060   if (aReflowState.mFlags.mSpecialHeightReflow) {
01061     aDesiredSize.height = mRect.height;
01062   }
01063   else if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
01064     aDesiredSize.height = CalcHeight(aReflowState);
01065     if (mPrevInFlow) {
01066       nscoord height = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
01067       aDesiredSize.height = PR_MAX(aDesiredSize.height, height);
01068     }
01069     else {
01070       if (isPaginated && HasStyleHeight()) {
01071         // set the unpaginated height so next in flows can try to honor it
01072         SetHasUnpaginatedHeight(PR_TRUE);
01073         SetUnpaginatedHeight(aPresContext, aDesiredSize.height);
01074       }
01075       if (isPaginated && HasUnpaginatedHeight()) {
01076         aDesiredSize.height = PR_MAX(aDesiredSize.height, GetUnpaginatedHeight(aPresContext));
01077       }
01078     }
01079   }
01080   else { // constrained height, paginated
01081     aDesiredSize.height = paginatedHeight;
01082     if (aDesiredSize.height <= aReflowState.availableHeight) {
01083       nscoord height = CalcHeightFromUnpaginatedHeight(aPresContext, *this);
01084       aDesiredSize.height = PR_MAX(aDesiredSize.height, height);
01085       aDesiredSize.height = PR_MIN(aDesiredSize.height, aReflowState.availableHeight);
01086     }
01087   }
01088   nsRect rowRect(0, 0, aDesiredSize.width, aDesiredSize.height);
01089   aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, rowRect);
01090   FinishAndStoreOverflow(&aDesiredSize);
01091   return rv;
01092 }
01093 
01094 NS_METHOD nsTableRowFrame::IncrementalReflow(nsPresContext*          aPresContext,
01095                                              nsHTMLReflowMetrics&     aDesiredSize,
01096                                              const nsHTMLReflowState& aReflowState,
01097                                              nsTableFrame&            aTableFrame,
01098                                              nsReflowStatus&          aStatus)
01099 {
01100   CalcHeight(aReflowState); // need to recalculate it based on last reflow sizes
01101  
01102   // the row is a target if its path has a reflow command
01103   nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
01104   if (command)
01105     IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
01106 
01107   // see if the chidren are targets as well
01108   nsReflowPath::iterator iter = aReflowState.path->FirstChild();
01109   nsReflowPath::iterator end  = aReflowState.path->EndChildren();
01110   for (; iter != end; ++iter)
01111     IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, *iter);
01112 
01113   return NS_OK;
01114 }
01115 
01116 NS_METHOD 
01117 nsTableRowFrame::IR_TargetIsMe(nsPresContext*          aPresContext,
01118                                nsHTMLReflowMetrics&     aDesiredSize,
01119                                const nsHTMLReflowState& aReflowState,
01120                                nsTableFrame&            aTableFrame,
01121                                nsReflowStatus&          aStatus)
01122 {
01123   nsresult rv = NS_FRAME_COMPLETE;
01124 
01125   nsReflowType type;
01126   aReflowState.path->mReflowCommand->GetType(type);
01127   switch (type) {
01128     case eReflowType_ReflowDirty: 
01129       // Reflow the dirty child frames. Typically this is newly added frames.
01130       rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_TRUE);
01131       break;
01132     case eReflowType_StyleChanged :
01133       rv = IR_StyleChanged(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus);
01134       break;
01135     case eReflowType_ContentChanged :
01136       NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
01137       rv = NS_ERROR_ILLEGAL_VALUE;
01138       break;
01139     default:
01140       NS_NOTYETIMPLEMENTED("unexpected reflow command type");
01141       rv = NS_ERROR_NOT_IMPLEMENTED;
01142       break;
01143   }
01144 
01145   return rv;
01146 }
01147 
01148 NS_METHOD 
01149 nsTableRowFrame::IR_StyleChanged(nsPresContext*          aPresContext,
01150                                  nsHTMLReflowMetrics&     aDesiredSize,
01151                                  const nsHTMLReflowState& aReflowState,
01152                                  nsTableFrame&            aTableFrame,
01153                                  nsReflowStatus&          aStatus)
01154 {
01155   nsresult rv = NS_OK;
01156   // we presume that all the easy optimizations were done in the nsHTMLStyleSheet before we were called here
01157   // XXX: we can optimize this when we know which style attribute changed
01158   aTableFrame.SetNeedStrategyInit(PR_TRUE);
01159   rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, aTableFrame, aStatus, PR_FALSE);
01160   return rv;
01161 }
01162 
01163 NS_METHOD 
01164 nsTableRowFrame::IR_TargetIsChild(nsPresContext*          aPresContext,
01165                                   nsHTMLReflowMetrics&     aDesiredSize,
01166                                   const nsHTMLReflowState& aReflowState,
01167                                   nsTableFrame&            aTableFrame,
01168                                   nsReflowStatus&          aStatus,
01169                                   nsIFrame*                aNextFrame)
01170 
01171 {
01172   if (!aNextFrame) return NS_ERROR_NULL_POINTER;
01173   nsresult rv = NS_OK;
01174 
01175   GET_PIXELS_TO_TWIPS(aPresContext, p2t);
01176   PRBool isAutoLayout = aTableFrame.IsAutoLayout();
01177   const nsStyleDisplay* childDisplay = aNextFrame->GetStyleDisplay();
01178   if (NS_STYLE_DISPLAY_TABLE_CELL == childDisplay->mDisplay) {
01179     nsTableCellFrame* cellFrame = (nsTableCellFrame*)aNextFrame;
01180     // Get the x coord of the cell
01181     nsPoint cellOrigin = cellFrame->GetPosition();
01182 
01183     // At this point, we know the column widths. Compute the cell available width
01184     PRInt32 cellColIndex;
01185     cellFrame->GetColIndex(cellColIndex);
01186     nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
01187 
01188     nscoord colAvailWidth, cellAvailWidth;
01189     CalcAvailWidth(aTableFrame, GetComputedWidth(aReflowState, aTableFrame), p2t,
01190                    *cellFrame, cellSpacingX, colAvailWidth, cellAvailWidth);
01191 
01192     // Always let the cell be as high as it wants. We ignore the height that's
01193     // passed in and always place the entire row. Let the row group decide
01194     // whether we fit or wehther the entire row is pushed
01195     nsSize  cellAvailSize(cellAvailWidth, NS_UNCONSTRAINEDSIZE);
01196 
01197     // Pass along the reflow command
01198     // Unless this is a fixed-layout table, then have the cell incrementally
01199     // update its maximum width. 
01200     nsHTMLReflowMetrics cellMet(PR_TRUE,
01201                                 isAutoLayout ? NS_REFLOW_CALC_MAX_WIDTH : 0);
01202     GET_PIXELS_TO_TWIPS(aPresContext, p2t);
01203     nsTableCellReflowState kidRS(aPresContext, aReflowState, aNextFrame, cellAvailSize, 
01204                                  aReflowState.reason);
01205     // If the table will intialize the strategy (and balance) or balance, make the computed 
01206     // width unconstrained. This avoids having the cell block compute a bogus max width 
01207     // which will bias the balancing. Leave the avail width alone, since it is a best guess.
01208     // After the table balances, the cell will get reflowed with the correct computed width.
01209     PRBool resetComputedWidth = aTableFrame.NeedStrategyInit() || aTableFrame.NeedStrategyBalance();
01210     if (resetComputedWidth)
01211       cellFrame->SetNeedPass2Reflow(PR_TRUE);
01212     InitChildReflowState(*aPresContext, cellAvailSize, aTableFrame.IsBorderCollapse(), 
01213                          p2t, kidRS, resetComputedWidth); 
01214 
01215     // Remember the current desired size, we'll need it later
01216     nscoord oldCellMinWidth     = cellFrame->GetPass1MaxElementWidth();
01217     nscoord oldCellMaximumWidth = cellFrame->GetMaximumWidth();
01218     nsSize  oldCellDesSize      = cellFrame->GetDesiredSize();
01219     nscoord oldCellDesAscent    = cellFrame->GetDesiredAscent();
01220     nscoord oldCellDesDescent   = oldCellDesSize.height - oldCellDesAscent;
01221     
01222     // Reflow the cell passing it the incremental reflow command. We can't pass
01223     // in a max width of NS_UNCONSTRAINEDSIZE, because the max width must match
01224     // the width of the previous reflow...
01225     rv = ReflowChild(aNextFrame, aPresContext, cellMet, kidRS,
01226                      cellOrigin.x, 0, 0, aStatus);
01227     nsSize initCellDesSize(cellMet.width, cellMet.height);
01228     nscoord initCellDesAscent = cellMet.ascent;
01229     nscoord initCellDesDescent = cellMet.descent;
01230     
01231     // cache the max-elem and maximum widths
01232     cellFrame->SetPass1MaxElementWidth(cellMet.width, cellMet.mMaxElementWidth);
01233     cellFrame->SetMaximumWidth(cellMet.mMaximumWidth);
01234 
01235     // Calculate the cell's actual size given its pass2 size. This function
01236     // takes into account the specified height (in the style), and any special
01237     // logic needed for backwards compatibility
01238     CalculateCellActualSize(aNextFrame, cellMet.width, cellMet.height, cellAvailWidth);
01239 
01240     // height may have changed, adjust descent to absorb any excess difference
01241     cellMet.descent = cellMet.height - cellMet.ascent;
01242 
01243     // if the cell got shorter and it may have been the tallest, recalc the tallest cell
01244     PRBool tallestCellGotShorter = PR_FALSE;
01245     PRBool hasVerticalAlignBaseline = cellFrame->HasVerticalAlignBaseline();
01246     if (!hasVerticalAlignBaseline) { 
01247       // only the height matters
01248       tallestCellGotShorter = 
01249         TallestCellGotShorter(oldCellDesSize.height, cellMet.height, GetHeight());
01250     }
01251     else {
01252       // the ascent matters
01253       tallestCellGotShorter = 
01254         TallestCellGotShorter(oldCellDesAscent, cellMet.ascent, mMaxCellAscent);
01255       // the descent of cells without rowspan also matters
01256       if (!tallestCellGotShorter) {
01257         PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
01258         if (rowSpan == 1) {
01259          tallestCellGotShorter = 
01260            TallestCellGotShorter(oldCellDesDescent, cellMet.descent, mMaxCellDescent);
01261         }
01262       }
01263     }
01264     if (tallestCellGotShorter) {
01265       CalcHeight(aReflowState);
01266     }
01267     else {
01268       UpdateHeight(cellMet.height, cellMet.ascent, cellMet.descent, &aTableFrame, cellFrame);
01269     }
01270 
01271     // if the cell's desired size didn't changed, our height is unchanged
01272     aDesiredSize.mNothingChanged = PR_FALSE;
01273     PRInt32 rowSpan = aTableFrame.GetEffectiveRowSpan(*cellFrame);
01274     if ((initCellDesSize.width  == oldCellDesSize.width)  &&
01275         (initCellDesSize.height == oldCellDesSize.height) &&
01276         (oldCellMaximumWidth    == cellMet.mMaximumWidth)) {
01277       if (!hasVerticalAlignBaseline) { // only the cell's height matters
01278         aDesiredSize.mNothingChanged = PR_TRUE;
01279       }
01280       else { // cell's ascent and cell's descent matter
01281         if (initCellDesAscent == oldCellDesAscent) {
01282           if ((rowSpan == 1) && (initCellDesDescent == oldCellDesDescent)) {
01283             aDesiredSize.mNothingChanged = PR_TRUE;
01284           }
01285         }
01286       }
01287     }
01288     aDesiredSize.height = (aDesiredSize.mNothingChanged) ? mRect.height : GetHeight();
01289     if (1 == rowSpan) {
01290       cellMet.height = aDesiredSize.height;
01291     }
01292     else {
01293       nscoord heightOfRows = aDesiredSize.height + GetHeightOfRowsSpannedBelowFirst(*cellFrame, aTableFrame); 
01294       cellMet.height = PR_MAX(cellMet.height, heightOfRows); 
01295       // XXX need to check what happens when this height differs from height of the cell's previous mRect.height
01296     }
01297 
01298     // Now place the child
01299     cellMet.width = colAvailWidth;
01300     FinishReflowChild(aNextFrame, aPresContext, nsnull, cellMet, cellOrigin.x, 0, 0);
01301 
01302     // Notify the table if the cell width changed so it can decide whether to rebalance
01303     if (!aDesiredSize.mNothingChanged) {
01304       aTableFrame.CellChangedWidth(*cellFrame, oldCellMinWidth, oldCellMaximumWidth); 
01305     } 
01306 
01307     // Return our desired size. Note that our desired width is just whatever width
01308     // we were given by the row group frame
01309     aDesiredSize.width  = aReflowState.availableWidth;
01310     if (!aDesiredSize.mNothingChanged) {
01311       if (aDesiredSize.height == mRect.height) { // our height didn't change
01312         cellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
01313         nsRect dirtyRect = cellFrame->GetRect();
01314         dirtyRect.height = mRect.height;
01315         ConsiderChildOverflow(aDesiredSize.mOverflowArea, cellFrame);
01316         dirtyRect.UnionRect(dirtyRect, aDesiredSize.mOverflowArea);
01317         Invalidate(dirtyRect);
01318       }
01319     }
01320     else { // we dont realign vertical but we need to update the overflow area
01321       nsIFrame* cellKidFrame = cellFrame->GetFirstChild(nsnull);
01322       if (cellKidFrame) {
01323         // XXX This is bogus. The code above changes the cell width
01324         // and height but leaves the overflow area alone. How can that
01325         // be right?
01326 
01327         // Make sure the overflow area includes the width and height, in any case.
01328         cellMet.mOverflowArea.UnionRect(cellMet.mOverflowArea,
01329                                         nsRect(0, 0, cellMet.width, cellMet.height));
01330         cellFrame->ConsiderChildOverflow(cellMet.mOverflowArea, cellKidFrame);
01331         cellFrame->FinishAndStoreOverflow(&cellMet);
01332         if (cellFrame->HasView()) {
01333           nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, cellFrame, cellFrame->GetView(), &cellMet.mOverflowArea, 0);
01334         }
01335       }
01336     }
01337   }
01338   else
01339   { // pass reflow to unknown frame child
01340     // aDesiredSize does not change
01341   }
01342   
01343   // recover the overflow area
01344   aDesiredSize.mOverflowArea = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
01345   for (nsIFrame* cell = mFrames.FirstChild(); cell; cell = cell->GetNextSibling()) {
01346     ConsiderChildOverflow(aDesiredSize.mOverflowArea, cell);
01347   }
01348   FinishAndStoreOverflow(&aDesiredSize);
01349   // When returning whether we're complete we need to look at each of our cell
01350   // frames. If any of them has a continuing frame, then we're not complete. We
01351   // can't just return the status of the cell frame we just reflowed...
01352   aStatus = NS_FRAME_COMPLETE;
01353   if (mNextInFlow) {
01354     for (nsIFrame* cell = mFrames.FirstChild(); cell;
01355          cell = cell->GetNextSibling()) {
01356       nsIFrame* contFrame = cell->GetNextInFlow();
01357       if (contFrame) {
01358         aStatus =  NS_FRAME_NOT_COMPLETE;
01359         break;
01360       }
01361     }
01362   }
01363   return rv;
01364 }
01365 
01366 
01370 NS_METHOD
01371 nsTableRowFrame::Reflow(nsPresContext*          aPresContext,
01372                         nsHTMLReflowMetrics&     aDesiredSize,
01373                         const nsHTMLReflowState& aReflowState,
01374                         nsReflowStatus&          aStatus)
01375 {
01376   DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame", aReflowState.reason);
01377   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
01378 #if defined DEBUG_TABLE_REFLOW_TIMING
01379   nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
01380 #endif
01381   nsresult rv = NS_OK;
01382 
01383   nsTableFrame* tableFrame = nsnull;
01384   rv = nsTableFrame::GetTableFrame(this, tableFrame);
01385   if (!tableFrame) return NS_ERROR_NULL_POINTER;
01386 
01387   const nsStyleVisibility* rowVis = GetStyleVisibility();
01388   PRBool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
01389   if (collapseRow) {
01390     tableFrame->SetNeedToCollapseRows(PR_TRUE);
01391   }
01392 
01393   // see if a special height reflow needs to occur due to having a pct height
01394   if (!NeedSpecialReflow()) 
01395     nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
01396 
01397   switch (aReflowState.reason) {
01398   case eReflowReason_Initial:
01399     rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
01400     break;
01401 
01402   case eReflowReason_Resize:
01403   case eReflowReason_StyleChange: 
01404   case eReflowReason_Dirty:
01405     rv = ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus, PR_FALSE);
01406     break;
01407 
01408   case eReflowReason_Incremental:
01409     rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus);
01410     break;
01411   default:
01412     NS_ASSERTION(PR_FALSE , "we should handle this reflow reason");
01413     rv = NS_ERROR_NOT_IMPLEMENTED;
01414     break;
01415   }
01416 
01417   // just set our width to what was available. The table will calculate the width and not use our value.
01418   aDesiredSize.width = aReflowState.availableWidth;
01419 
01420   if (aReflowState.mFlags.mSpecialHeightReflow) {
01421     SetNeedSpecialReflow(PR_FALSE);
01422   }
01423 
01424 #if defined DEBUG_TABLE_REFLOW_TIMING
01425   nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus);
01426 #endif
01427   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
01428   return rv;
01429 }
01430 
01436 nscoord 
01437 nsTableRowFrame::ReflowCellFrame(nsPresContext*          aPresContext,
01438                                  const nsHTMLReflowState& aReflowState,
01439                                  nsTableCellFrame*        aCellFrame,
01440                                  nscoord                  aAvailableHeight,
01441                                  nsReflowStatus&          aStatus)
01442 {
01443   nsTableFrame* tableFrame = nsnull;
01444   nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(0);
01445 
01446   // Reflow the cell frame with the specified height. Use the existing width
01447   nsSize cellSize = aCellFrame->GetSize();
01448   
01449   nsSize  availSize(cellSize.width, aAvailableHeight);
01450   PRBool borderCollapse = ((nsTableFrame*)tableFrame->GetFirstInFlow())->IsBorderCollapse();
01451   GET_PIXELS_TO_TWIPS(aPresContext, p2t);
01452   nsTableCellReflowState cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
01453                                          eReflowReason_Resize);
01454   InitChildReflowState(*aPresContext, availSize, borderCollapse, p2t, cellReflowState);
01455 
01456   nsHTMLReflowMetrics desiredSize(PR_FALSE);
01457 
01458   ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
01459               0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
01460   PRBool fullyComplete = NS_FRAME_IS_COMPLETE(aStatus) && !NS_FRAME_IS_TRUNCATED(aStatus);
01461 
01462   aCellFrame->SetSize(
01463     nsSize(cellSize.width, fullyComplete ? aAvailableHeight : desiredSize.height));
01464 
01465   // XXX What happens if this cell has 'vertical-align: baseline' ?
01466   // XXX Why is it assumed that the cell's ascent hasn't changed ?
01467   if (fullyComplete) {
01468     aCellFrame->VerticallyAlignChild(aReflowState, mMaxCellAscent);
01469   }
01470   aCellFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
01471 
01472   return desiredSize.height;
01473 }
01474 
01479 void 
01480 nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
01481                                  nsTableCellFrame* aPrevSibling)
01482 {
01483   mFrames.InsertFrame(nsnull, aPrevSibling, aFrame);
01484   aFrame->SetParent(this);
01485 }
01486 
01487 void 
01488 nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
01489                                  PRInt32           aColIndex)
01490 {
01491   // Find the cell frame where col index < aColIndex
01492   nsTableCellFrame* priorCell = nsnull;
01493   for (nsIFrame* child = mFrames.FirstChild(); child;
01494        child = child->GetNextSibling()) {
01495     if (!IS_TABLE_CELL(child->GetType())) {
01496       nsTableCellFrame* cellFrame = (nsTableCellFrame*)child;
01497       PRInt32 colIndex;
01498       cellFrame->GetColIndex(colIndex);
01499       if (colIndex < aColIndex) {
01500         priorCell = cellFrame;
01501       }
01502       else break;
01503     }
01504   }
01505   InsertCellFrame(aFrame, priorCell);
01506 }
01507 
01508 void 
01509 nsTableRowFrame::RemoveCellFrame(nsTableCellFrame* aFrame)
01510 {
01511   if (!mFrames.RemoveFrame(aFrame))
01512     NS_ASSERTION(PR_FALSE, "frame not in list");
01513 }
01514 
01515 nsIAtom*
01516 nsTableRowFrame::GetType() const
01517 {
01518   return nsLayoutAtoms::tableRowFrame;
01519 }
01520 
01521 nsTableRowFrame*  
01522 nsTableRowFrame::GetNextRow() const
01523 {
01524   nsIFrame* childFrame = GetNextSibling();
01525   while (childFrame) {
01526     if (nsLayoutAtoms::tableRowFrame == childFrame->GetType()) {
01527       return (nsTableRowFrame*)childFrame;
01528     }
01529     childFrame = childFrame->GetNextSibling();
01530   }
01531   return nsnull;
01532 }
01533 
01534 void 
01535 nsTableRowFrame::SetUnpaginatedHeight(nsPresContext* aPresContext,
01536                                       nscoord         aValue)
01537 {
01538   NS_ASSERTION(!mPrevInFlow, "program error");
01539   // Get the property 
01540   nscoord* value = (nscoord*)nsTableFrame::GetProperty(this, nsLayoutAtoms::rowUnpaginatedHeightProperty, PR_TRUE);
01541   if (value) {
01542     *value = aValue;
01543   }
01544 }
01545 
01546 nscoord
01547 nsTableRowFrame::GetUnpaginatedHeight(nsPresContext* aPresContext)
01548 {
01549   // See if the property is set
01550   nscoord* value = (nscoord*)nsTableFrame::GetProperty(GetFirstInFlow(), nsLayoutAtoms::rowUnpaginatedHeightProperty);
01551   if (value) 
01552     return *value;
01553   else 
01554     return 0;
01555 }
01556 
01557 void nsTableRowFrame::SetContinuousBCBorderWidth(PRUint8     aForSide,
01558                                                  BCPixelSize aPixelValue)
01559 {
01560   switch (aForSide) {
01561     case NS_SIDE_RIGHT:
01562       mRightContBorderWidth = aPixelValue;
01563       return;
01564     case NS_SIDE_TOP:
01565       mTopContBorderWidth = aPixelValue;
01566       return;
01567     case NS_SIDE_LEFT:
01568       mLeftContBorderWidth = aPixelValue;
01569       return;
01570     default:
01571       NS_ERROR("invalid NS_SIDE arg");
01572   }
01573 }
01574 
01575 /* ----- global methods ----- */
01576 
01577 nsresult 
01578 NS_NewTableRowFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
01579 {
01580   NS_PRECONDITION(aNewFrame, "null OUT ptr");
01581   if (nsnull == aNewFrame) {
01582     return NS_ERROR_NULL_POINTER;
01583   }
01584   nsTableRowFrame* it = new (aPresShell) nsTableRowFrame;
01585   if (nsnull == it) {
01586     return NS_ERROR_OUT_OF_MEMORY;
01587   }
01588   *aNewFrame = it;
01589   return NS_OK;
01590 }
01591 
01592 #ifdef DEBUG
01593 NS_IMETHODIMP
01594 nsTableRowFrame::GetFrameName(nsAString& aResult) const
01595 {
01596   return MakeFrameName(NS_LITERAL_STRING("TableRow"), aResult);
01597 }
01598 #endif