2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-05-29 22:08:19 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1998-05-29 22:08:19 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +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-05-29 22:08:19 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-05-29 22:08:19 +00:00
|
|
|
#ifndef nsTableColFrame_h__
|
|
|
|
#define nsTableColFrame_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsContainerFrame.h"
|
2004-03-09 06:48:35 +00:00
|
|
|
#include "nsTablePainter.h"
|
1998-05-29 22:08:19 +00:00
|
|
|
|
1999-04-13 01:15:16 +00:00
|
|
|
class nsVoidArray;
|
1999-08-19 19:52:37 +00:00
|
|
|
class nsTableCellFrame;
|
1999-04-13 01:15:16 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
// this is used to index arrays of widths in nsColFrame and to group important widths
|
|
|
|
// for calculations. It is important that the order: min, desired, fixed be maintained
|
|
|
|
// for each category (con, adj).
|
|
|
|
#define WIDTH_NOT_SET -1
|
2001-03-13 06:38:59 +00:00
|
|
|
#define NUM_WIDTHS 10
|
1999-07-28 08:09:02 +00:00
|
|
|
#define NUM_MAJOR_WIDTHS 3 // MIN, DES, FIX
|
|
|
|
#define MIN_CON 0 // minimum width required of the content + padding
|
|
|
|
#define DES_CON 1 // desired width of the content + padding
|
|
|
|
#define FIX 2 // fixed width either from the content or cell, col, etc. + padding
|
|
|
|
#define MIN_ADJ 3 // minimum width + padding due to col spans
|
|
|
|
#define DES_ADJ 4 // desired width + padding due to col spans
|
|
|
|
#define FIX_ADJ 5 // fixed width + padding due to col spans
|
|
|
|
#define PCT 6 // percent width of cell or col
|
|
|
|
#define PCT_ADJ 7 // percent width of cell or col from percent colspan
|
|
|
|
#define MIN_PRO 8 // desired width due to proportional <col>s or cols attribute
|
2001-03-13 06:38:59 +00:00
|
|
|
#define FINAL 9 // width after the table has been balanced, considering all of the others
|
2001-11-30 15:05:51 +00:00
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
enum nsColConstraint {
|
|
|
|
eNoConstraint = 0,
|
|
|
|
ePixelConstraint = 1, // pixel width
|
|
|
|
ePercentConstraint = 2, // percent width
|
|
|
|
eProportionConstraint = 3, // 1*, 2*, etc. cols attribute assigns 1*
|
|
|
|
e0ProportionConstraint = 4 // 0*, means to force to min width
|
|
|
|
};
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
enum nsTableColType {
|
|
|
|
eColContent = 0, // there is real col content associated
|
|
|
|
eColAnonymousCol = 1, // the result of a span on a col
|
|
|
|
eColAnonymousColGroup = 2, // the result of a span on a col group
|
2001-11-30 15:05:51 +00:00
|
|
|
eColAnonymousCell = 3 // the result of a cell alone
|
1999-12-13 22:56:31 +00:00
|
|
|
};
|
|
|
|
|
1998-05-29 22:08:19 +00:00
|
|
|
class nsTableColFrame : public nsFrame {
|
|
|
|
public:
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1998-07-22 03:53:43 +00:00
|
|
|
enum {eWIDTH_SOURCE_NONE =0, // no cell has contributed to the width style
|
|
|
|
eWIDTH_SOURCE_CELL =1, // a cell specified a width
|
|
|
|
eWIDTH_SOURCE_CELL_WITH_SPAN=2 // a cell implicitly specified a width via colspan
|
|
|
|
};
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsTableColType GetColType() const;
|
|
|
|
void SetColType(nsTableColType aType);
|
1998-09-15 17:58:24 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
/** instantiate a new instance of nsTableRowFrame.
|
|
|
|
* @param aPresShell the pres shell for this frame
|
1998-09-15 17:58:24 +00:00
|
|
|
*
|
2005-11-04 02:38:33 +00:00
|
|
|
* @return the frame that was created
|
1998-09-15 17:58:24 +00:00
|
|
|
*/
|
2006-03-26 21:30:36 +00:00
|
|
|
friend nsIFrame* NS_NewTableColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
1998-05-29 22:08:19 +00:00
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
nsStyleCoord GetStyleWidth() const;
|
|
|
|
|
|
|
|
PRInt32 GetColIndex() const;
|
|
|
|
|
|
|
|
void SetColIndex (PRInt32 aColIndex);
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
nsTableColFrame* GetNextCol() const;
|
|
|
|
|
2006-03-09 18:55:21 +00:00
|
|
|
NS_IMETHOD Init(nsIContent* aContent,
|
2001-02-23 12:35:34 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-05-29 22:08:19 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
/**
|
|
|
|
* Table columns never paint anything, nor receive events.
|
|
|
|
*/
|
|
|
|
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) { return NS_OK; }
|
|
|
|
|
1999-10-02 00:02:54 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableColFrame
|
|
|
|
*/
|
2003-10-31 20:19:18 +00:00
|
|
|
virtual nsIAtom* GetType() const;
|
1999-10-02 00:02:54 +00:00
|
|
|
|
1999-09-01 01:02:16 +00:00
|
|
|
#ifdef DEBUG
|
2001-11-14 01:33:42 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
1998-11-19 17:22:29 +00:00
|
|
|
|
1998-06-11 00:13:18 +00:00
|
|
|
/** return the number of the columns the col represents. always >= 0 */
|
1999-01-29 18:49:32 +00:00
|
|
|
virtual PRInt32 GetSpan ();
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
/** convenience method, calls into cellmap */
|
|
|
|
nsVoidArray * GetCells();
|
|
|
|
|
1999-07-28 08:09:02 +00:00
|
|
|
nscoord GetWidth(PRUint32 aWidthType);
|
1999-08-19 19:52:37 +00:00
|
|
|
void SetWidth(PRUint32 aWidthType,
|
|
|
|
nscoord aWidth);
|
1999-07-28 08:09:02 +00:00
|
|
|
nscoord GetMinWidth();
|
|
|
|
nscoord GetDesWidth();
|
|
|
|
nscoord GetFixWidth();
|
|
|
|
nscoord GetPctWidth();
|
1999-05-26 22:22:23 +00:00
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
void SetConstraint(nsColConstraint aConstraint);
|
1999-07-28 08:09:02 +00:00
|
|
|
nsColConstraint GetConstraint() const;
|
1998-11-16 06:46:00 +00:00
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
/** convenience method, calls into cellmap */
|
|
|
|
PRInt32 Count() const;
|
|
|
|
|
1999-08-21 06:38:07 +00:00
|
|
|
void ResetSizingInfo();
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
nscoord GetLeftBorderWidth(float* aPixelsToTwips = nsnull);
|
2004-03-09 06:48:35 +00:00
|
|
|
void SetLeftBorderWidth(BCPixelSize aWidth);
|
2002-02-19 15:48:28 +00:00
|
|
|
nscoord GetRightBorderWidth(float* aPixelsToTwips = nsnull);
|
2004-03-09 06:48:35 +00:00
|
|
|
void SetRightBorderWidth(BCPixelSize aWidth);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets inner border widths before collapsing with cell borders
|
|
|
|
* Caller must get left border from previous column or from table
|
|
|
|
* GetContinuousBCBorderWidth will not overwrite aBorder.left
|
|
|
|
* see nsTablePainter about continuous borders
|
|
|
|
*
|
|
|
|
* @return outer right border width (left inner for next column)
|
|
|
|
*/
|
|
|
|
nscoord GetContinuousBCBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder);
|
|
|
|
/**
|
|
|
|
* Set full border widths before collapsing with cell borders
|
|
|
|
* @param aForSide - side to set; only valid for top, right, and bottom
|
|
|
|
*/
|
|
|
|
void SetContinuousBCBorderWidth(PRUint8 aForSide,
|
|
|
|
BCPixelSize aPixelValue);
|
2004-09-04 16:02:50 +00:00
|
|
|
#ifdef DEBUG
|
1999-07-28 08:09:02 +00:00
|
|
|
void Dump(PRInt32 aIndent);
|
2004-09-04 16:02:50 +00:00
|
|
|
#endif
|
1999-07-28 08:09:02 +00:00
|
|
|
|
1998-05-29 22:08:19 +00:00
|
|
|
protected:
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTableColFrame(nsStyleContext* aContext);
|
1999-07-28 08:09:02 +00:00
|
|
|
~nsTableColFrame();
|
1998-05-29 22:08:19 +00:00
|
|
|
|
2005-09-12 13:44:15 +00:00
|
|
|
// the index of the column with respect to the whole tabble (starting at 0)
|
|
|
|
// it should never be smaller then the start column index of the parent
|
|
|
|
// colgroup
|
2002-02-19 15:48:28 +00:00
|
|
|
PRUint32 mColIndex: 16;
|
2004-03-09 06:48:35 +00:00
|
|
|
|
2005-04-07 18:04:38 +00:00
|
|
|
// border width in pixels of the inner half of the border only
|
2004-03-09 06:48:35 +00:00
|
|
|
BCPixelSize mLeftBorderWidth;
|
|
|
|
BCPixelSize mRightBorderWidth;
|
|
|
|
BCPixelSize mTopContBorderWidth;
|
|
|
|
BCPixelSize mRightContBorderWidth;
|
|
|
|
BCPixelSize mBottomContBorderWidth;
|
2002-02-19 15:48:28 +00:00
|
|
|
// Widths including MIN_CON, DES_CON, FIX_CON, MIN_ADJ, DES_ADJ, FIX_ADJ, PCT, PCT_ADJ, MIN_PRO, FINAL
|
2001-11-30 15:05:51 +00:00
|
|
|
// Widths including MIN_CON, DES_CON, FIX_CON, MIN_ADJ, DES_ADJ, FIX_ADJ, PCT, PCT_ADJ, MIN_PRO, FINAL
|
|
|
|
// XXX these could be stored as pixels and converted to twips for a savings of 10 x 2 bytes.
|
1999-10-04 05:19:32 +00:00
|
|
|
nscoord mWidths[NUM_WIDTHS];
|
1998-05-29 22:08:19 +00:00
|
|
|
};
|
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
inline PRInt32 nsTableColFrame::GetColIndex() const
|
2004-03-09 06:48:35 +00:00
|
|
|
{
|
2002-02-19 15:48:28 +00:00
|
|
|
return mColIndex;
|
|
|
|
}
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1999-12-13 22:56:31 +00:00
|
|
|
inline void nsTableColFrame::SetColIndex (PRInt32 aColIndex)
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nscoord nsTableColFrame::GetLeftBorderWidth(float* aPixelsToTwips)
|
|
|
|
{
|
|
|
|
nscoord width = (aPixelsToTwips) ? NSToCoordRound(*aPixelsToTwips * mLeftBorderWidth) : mLeftBorderWidth;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
inline void nsTableColFrame::SetLeftBorderWidth(BCPixelSize aWidth)
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
|
|
|
mLeftBorderWidth = aWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nscoord nsTableColFrame::GetRightBorderWidth(float* aPixelsToTwips)
|
|
|
|
{
|
|
|
|
nscoord width = (aPixelsToTwips) ? NSToCoordRound(*aPixelsToTwips * mRightBorderWidth) : mRightBorderWidth;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
inline void nsTableColFrame::SetRightBorderWidth(BCPixelSize aWidth)
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
|
|
|
mRightBorderWidth = aWidth;
|
|
|
|
}
|
1998-06-11 00:13:18 +00:00
|
|
|
|
2004-03-09 06:48:35 +00:00
|
|
|
inline nscoord
|
|
|
|
nsTableColFrame::GetContinuousBCBorderWidth(float aPixelsToTwips,
|
|
|
|
nsMargin& aBorder)
|
|
|
|
{
|
|
|
|
aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips,
|
|
|
|
mTopContBorderWidth);
|
|
|
|
aBorder.right = BC_BORDER_LEFT_HALF_COORD(aPixelsToTwips,
|
|
|
|
mRightContBorderWidth);
|
|
|
|
aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips,
|
|
|
|
mBottomContBorderWidth);
|
|
|
|
return BC_BORDER_RIGHT_HALF_COORD(aPixelsToTwips, mRightContBorderWidth);
|
|
|
|
}
|
|
|
|
|
1998-05-29 22:08:19 +00:00
|
|
|
#endif
|
|
|
|
|