1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-13 20:24:54 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
|
|
|
#ifndef nsTableRowFrame_h__
|
|
|
|
#define nsTableRowFrame_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
1998-10-20 17:45:07 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-21 23:43:18 +00:00
|
|
|
class nsTableFrame;
|
1998-06-05 02:36:25 +00:00
|
|
|
class nsTableCellFrame;
|
1999-08-28 00:43:53 +00:00
|
|
|
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
class nsReflowTimer;
|
|
|
|
#endif
|
|
|
|
|
1999-10-31 03:15:52 +00:00
|
|
|
#define NS_TABLE_MAX_ROW_INDEX (1<<19)
|
1999-10-23 23:08:30 +00:00
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/**
|
1998-04-14 21:45:28 +00:00
|
|
|
* nsTableRowFrame is the frame that maps table rows
|
|
|
|
* (HTML tag TR). This class cannot be reused
|
|
|
|
* outside of an nsTableRowGroupFrame. It assumes that its parent is an nsTableRowGroupFrame,
|
|
|
|
* and its children are nsTableCellFrames.
|
|
|
|
*
|
|
|
|
* @see nsTableFrame
|
|
|
|
* @see nsTableRowGroupFrame
|
|
|
|
* @see nsTableCellFrame
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
1998-10-20 17:45:07 +00:00
|
|
|
class nsTableRowFrame : public nsHTMLContainerFrame
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
public:
|
2001-01-25 15:55:51 +00:00
|
|
|
virtual ~nsTableRowFrame();
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1999-02-25 05:31:15 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-03 02:41:27 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
1998-04-14 21:45:28 +00:00
|
|
|
/** instantiate a new instance of nsTableRowFrame.
|
1998-09-15 17:58:24 +00:00
|
|
|
* @param aResult the new object is returned in this out-param
|
|
|
|
* @param aContent the table object to map
|
|
|
|
* @param aParent the parent of the new frame
|
1998-04-14 21:45:28 +00:00
|
|
|
*
|
|
|
|
* @return NS_OK if the frame was properly allocated, otherwise an error code
|
|
|
|
*/
|
1998-09-15 17:58:24 +00:00
|
|
|
friend nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
|
1998-09-16 17:19:20 +00:00
|
|
|
|
1998-04-14 21:45:28 +00:00
|
|
|
/** @see nsIFrame::Paint */
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-14 21:45:28 +00:00
|
|
|
|
|
|
|
/** ask all children to paint themselves, without clipping (for cells with rowspan>1)
|
|
|
|
* @see nsIFrame::Paint
|
|
|
|
*/
|
1999-11-24 06:03:41 +00:00
|
|
|
virtual void PaintChildren(nsIPresContext* aPresContext,
|
1998-04-13 20:24:54 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsIFrame** aFrame);
|
2000-03-22 02:43:08 +00:00
|
|
|
|
1998-05-25 17:31:49 +00:00
|
|
|
/** calls Reflow for all of its child cells.
|
1998-04-14 21:45:28 +00:00
|
|
|
* Cells with rowspan=1 are all set to the same height and stacked horizontally.
|
|
|
|
* <P> Cells are not split unless absolutely necessary.
|
|
|
|
* <P> Cells are resized in nsTableFrame::BalanceColumnWidths
|
|
|
|
* and nsTableFrame::ShrinkWrapChildren
|
|
|
|
*
|
|
|
|
* @param aDesiredSize width set to width of the sum of the cells, height set to
|
|
|
|
* height of cells with rowspan=1.
|
|
|
|
*
|
1998-05-25 17:31:49 +00:00
|
|
|
* @see nsIFrame::Reflow
|
1998-04-14 21:45:28 +00:00
|
|
|
* @see nsTableFrame::BalanceColumnWidths
|
|
|
|
* @see nsTableFrame::ShrinkWrapChildren
|
|
|
|
*/
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2001-03-13 06:38:59 +00:00
|
|
|
nsReflowStatus& aStatus);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
virtual void DidResize(nsIPresContext* aPresContext,
|
1998-11-20 01:01:25 +00:00
|
|
|
const nsHTMLReflowState& aReflowState);
|
1998-07-02 20:35:23 +00:00
|
|
|
|
1999-02-24 05:54:31 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableRowFrame
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1999-09-01 01:02:16 +00:00
|
|
|
#ifdef DEBUG
|
1999-11-01 22:12:45 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer,
|
|
|
|
PRUint32* aResult) const;
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
2000-05-25 22:40:21 +00:00
|
|
|
|
|
|
|
void SetTallestCell(nscoord aHeight,
|
2000-06-05 08:25:11 +00:00
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aDescent,
|
2000-05-25 22:40:21 +00:00
|
|
|
nsTableFrame* aTableFrame = nsnull,
|
|
|
|
nsTableCellFrame* aCellFrame = nsnull);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-08-24 05:03:18 +00:00
|
|
|
void ResetTallestCell(nscoord aRowStyleHeight);
|
2000-05-25 22:40:21 +00:00
|
|
|
|
|
|
|
// calculate the tallest child when the previous tallest child gets shorter
|
|
|
|
void CalcTallestCell();
|
1998-04-13 20:24:54 +00:00
|
|
|
|
|
|
|
/** returns the tallest child in this row (ignoring any cell with rowspans) */
|
2000-05-25 22:40:21 +00:00
|
|
|
nscoord GetTallestCell() const;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-06-05 08:25:11 +00:00
|
|
|
// Support for cells with 'vertical-align: baseline'.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the max-ascent amongst all the cells that have
|
2000-07-28 09:19:26 +00:00
|
|
|
* 'vertical-align: baseline', *including* cells with rowspans.
|
2000-06-05 08:25:11 +00:00
|
|
|
* returns 0 if we don't have any cell with 'vertical-align: baseline'
|
|
|
|
*/
|
|
|
|
nscoord GetMaxCellAscent() const;
|
|
|
|
|
|
|
|
#if 0 // nobody uses this
|
|
|
|
/**
|
|
|
|
* returns the max-descent amongst all the cells that have
|
2000-07-28 09:19:26 +00:00
|
|
|
* 'vertical-align: baseline', *ignoring* any cell with rowspans.
|
2000-06-05 08:25:11 +00:00
|
|
|
* returns 0 if we don't have any cell with 'vertical-align: baseline'
|
|
|
|
*/
|
|
|
|
nscoord GetMaxCellDescent() const;
|
|
|
|
#endif
|
|
|
|
|
1998-06-17 16:38:24 +00:00
|
|
|
/** returns the ordinal position of this row in its table */
|
|
|
|
virtual PRInt32 GetRowIndex() const;
|
|
|
|
|
|
|
|
/** set this row's starting row index */
|
1998-12-16 04:31:38 +00:00
|
|
|
void SetRowIndex (int aRowIndex);
|
1998-06-17 16:38:24 +00:00
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
virtual PRBool Contains(nsIPresContext* aPresContext, const nsPoint& aPoint);
|
1998-11-07 00:36:37 +00:00
|
|
|
|
2001-04-16 14:51:52 +00:00
|
|
|
/** used by row group frame code */
|
|
|
|
nscoord ReflowCellFrame(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord aAvailableHeight,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
void InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
nsTableCellFrame* aPrevSibling);
|
1999-02-22 03:28:00 +00:00
|
|
|
|
2001-04-16 14:51:52 +00:00
|
|
|
void InsertCellFrame(nsTableCellFrame* aFrame,
|
|
|
|
PRInt32 aColIndex);
|
|
|
|
|
|
|
|
void RemoveCellFrame(nsTableCellFrame* aFrame);
|
|
|
|
|
2000-02-03 14:04:49 +00:00
|
|
|
nsresult CalculateCellActualSize(nsIFrame* aRowFrame,
|
|
|
|
nscoord& aDesiredWidth,
|
|
|
|
nscoord& aDesiredHeight,
|
|
|
|
nscoord aAvailWidth);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
|
|
|
|
1998-04-14 21:45:28 +00:00
|
|
|
/** protected constructor.
|
|
|
|
* @see NewFrame
|
|
|
|
*/
|
1998-12-03 06:31:43 +00:00
|
|
|
nsTableRowFrame();
|
1998-04-23 17:29:07 +00:00
|
|
|
|
1998-10-20 17:45:07 +00:00
|
|
|
/** implement abstract method on nsHTMLContainerFrame */
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
1998-10-14 16:32:45 +00:00
|
|
|
/** Incremental Reflow attempts to do column balancing with the minimum number of reflow
|
|
|
|
* commands to child elements. This is done by processing the reflow command,
|
|
|
|
* rebalancing column widths (if necessary), then comparing the resulting column widths
|
|
|
|
* to the prior column widths and reflowing only those cells that require a reflow.
|
|
|
|
*
|
|
|
|
* @see Reflow
|
|
|
|
*/
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
NS_IMETHOD IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame);
|
|
|
|
|
|
|
|
NS_IMETHOD IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
|
|
|
NS_IMETHOD IR_StyleChanged(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus);
|
1999-08-03 02:41:27 +00:00
|
|
|
|
1998-06-24 19:13:19 +00:00
|
|
|
// row-specific methods
|
|
|
|
|
1998-07-24 00:43:09 +00:00
|
|
|
void GetMinRowSpan(nsTableFrame *aTableFrame);
|
1998-06-24 19:13:19 +00:00
|
|
|
|
1998-07-24 00:43:09 +00:00
|
|
|
void FixMinCellHeight(nsTableFrame *aTableFrame);
|
1998-06-24 19:13:19 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord ComputeCellXOffset(const nsHTMLReflowState& aState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsMargin& aKidMargin) const;
|
1998-04-23 17:29:07 +00:00
|
|
|
/**
|
2001-03-13 06:38:59 +00:00
|
|
|
* Called for incremental/dirty and resize reflows. If aDirtyOnly is true then
|
|
|
|
* only reflow dirty cells.
|
1998-04-23 17:29:07 +00:00
|
|
|
*/
|
2001-03-13 06:38:59 +00:00
|
|
|
NS_IMETHOD ReflowChildren(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
PRBool aDirtyOnly = PR_FALSE);
|
1999-08-21 20:16:32 +00:00
|
|
|
|
1999-10-23 23:08:30 +00:00
|
|
|
public:
|
|
|
|
struct RowBits {
|
1999-10-31 03:15:52 +00:00
|
|
|
int mRowIndex:20;
|
1999-10-23 23:08:30 +00:00
|
|
|
unsigned mMinRowSpan:12; // the smallest row span among all my child cells
|
|
|
|
};
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
private:
|
1999-10-23 23:08:30 +00:00
|
|
|
union {
|
|
|
|
PRUint32 mAllBits;
|
|
|
|
RowBits mBits;
|
|
|
|
};
|
1998-05-21 23:43:18 +00:00
|
|
|
nscoord mTallestCell; // not my height, but the height of my tallest child
|
2000-06-05 08:25:11 +00:00
|
|
|
|
|
|
|
// max-ascent and max-descent amongst all cells that have 'vertical-align: baseline'
|
|
|
|
nscoord mMaxCellAscent; // does include cells with rowspan > 1
|
|
|
|
nscoord mMaxCellDescent; // does *not* include cells with rowspan > 1
|
2001-01-25 15:55:51 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
public:
|
|
|
|
nsReflowTimer* mTimer;
|
|
|
|
#endif
|
1998-04-13 20:24:54 +00:00
|
|
|
};
|
|
|
|
|
1998-06-17 16:38:24 +00:00
|
|
|
inline PRInt32 nsTableRowFrame::GetRowIndex() const
|
|
|
|
{
|
1999-10-23 23:08:30 +00:00
|
|
|
return PRInt32(mBits.mRowIndex);
|
1998-06-17 16:38:24 +00:00
|
|
|
}
|
|
|
|
|
1998-12-16 04:31:38 +00:00
|
|
|
inline void nsTableRowFrame::SetRowIndex (int aRowIndex)
|
|
|
|
{
|
1999-10-31 03:15:52 +00:00
|
|
|
NS_PRECONDITION(aRowIndex < NS_TABLE_MAX_ROW_INDEX, "unexpected row index");
|
|
|
|
mBits.mRowIndex = aRowIndex;
|
1998-12-16 04:31:38 +00:00
|
|
|
}
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
#endif
|