2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-05-30 02:08:19 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-05-30 02:08:19 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-30 02:08:19 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-05-30 02:08:19 +04:00
|
|
|
#ifndef nsTableColFrame_h__
|
|
|
|
#define nsTableColFrame_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
|
1999-04-13 05:15:16 +04:00
|
|
|
class nsVoidArray;
|
1999-08-19 23:52:37 +04:00
|
|
|
class nsTableCellFrame;
|
1999-04-13 05:15:16 +04:00
|
|
|
|
1999-07-28 12:09:02 +04: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 09:38:59 +03:00
|
|
|
#define NUM_WIDTHS 10
|
1999-07-28 12:09:02 +04: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 09:38:59 +03:00
|
|
|
#define FINAL 9 // width after the table has been balanced, considering all of the others
|
2001-11-30 18:05:51 +03:00
|
|
|
|
1999-07-28 12:09:02 +04: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-14 01:56:31 +03: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 18:05:51 +03:00
|
|
|
eColAnonymousCell = 3 // the result of a cell alone
|
1999-12-14 01:56:31 +03:00
|
|
|
};
|
|
|
|
|
1998-05-30 02:08:19 +04:00
|
|
|
class nsTableColFrame : public nsFrame {
|
|
|
|
public:
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1998-07-22 07:53:43 +04: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
|
|
|
|
};
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsTableColType GetType() const;
|
1999-12-14 03:27:33 +03:00
|
|
|
void SetType(nsTableColType aType);
|
1998-09-15 21:58:24 +04:00
|
|
|
|
|
|
|
/** instantiate a new instance of nsTableColFrame.
|
|
|
|
* @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
|
|
|
|
*
|
|
|
|
* @return NS_OK if the frame was properly allocated, otherwise an error code
|
|
|
|
*/
|
|
|
|
friend nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableColFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
|
1998-05-30 02:08:19 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsStyleCoord GetStyleWidth() const;
|
|
|
|
|
|
|
|
PRInt32 GetColIndex() const;
|
|
|
|
|
|
|
|
void SetColIndex (PRInt32 aColIndex);
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableColFrame* GetNextCol() const;
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-05-30 02:08:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags = 0);
|
1998-05-30 02:08:19 +04:00
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-05-30 02:08:19 +04:00
|
|
|
|
1999-10-02 04:02:54 +04:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableColFrame
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
1998-11-19 20:22:29 +03:00
|
|
|
|
1998-06-11 04:13:18 +04:00
|
|
|
/** return the number of the columns the col represents. always >= 0 */
|
1999-01-29 21:49:32 +03:00
|
|
|
virtual PRInt32 GetSpan ();
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** convenience method, calls into cellmap */
|
|
|
|
nsVoidArray * GetCells();
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord GetWidth(PRUint32 aWidthType);
|
1999-08-19 23:52:37 +04:00
|
|
|
void SetWidth(PRUint32 aWidthType,
|
|
|
|
nscoord aWidth);
|
1999-07-28 12:09:02 +04:00
|
|
|
nscoord GetMinWidth();
|
|
|
|
nscoord GetDesWidth();
|
|
|
|
nscoord GetFixWidth();
|
|
|
|
nscoord GetPctWidth();
|
1999-05-27 02:22:23 +04:00
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
void SetConstraint(nsColConstraint aConstraint);
|
1999-07-28 12:09:02 +04:00
|
|
|
nsColConstraint GetConstraint() const;
|
1998-11-16 09:46:00 +03:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** convenience method, calls into cellmap */
|
|
|
|
PRInt32 Count() const;
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
/** Return true if this col was constructed implicitly due to cells needing a col.
|
|
|
|
* Return false if this col was constructed due to content having display type of table-col
|
|
|
|
*/
|
|
|
|
PRBool IsAnonymous();
|
2001-03-13 09:38:59 +03:00
|
|
|
void SetIsAnonymous(PRBool aValue);
|
1999-07-28 12:09:02 +04:00
|
|
|
|
1999-08-21 10:38:07 +04:00
|
|
|
void ResetSizingInfo();
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nscoord GetLeftBorderWidth(float* aPixelsToTwips = nsnull);
|
|
|
|
void SetLeftBorderWidth(nscoord aWidth);
|
|
|
|
nscoord GetRightBorderWidth(float* aPixelsToTwips = nsnull);
|
|
|
|
void SetRightBorderWidth(nscoord aWidth);
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
void Dump(PRInt32 aIndent);
|
|
|
|
|
1998-05-30 02:08:19 +04:00
|
|
|
protected:
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableColFrame();
|
1999-07-28 12:09:02 +04:00
|
|
|
~nsTableColFrame();
|
1998-05-30 02:08:19 +04:00
|
|
|
|
2001-11-30 18:05:51 +03:00
|
|
|
// the starting index of the column (starting at 0) that this col object represents //
|
2002-02-19 18:48:28 +03:00
|
|
|
PRUint32 mColIndex: 16;
|
|
|
|
PRUint32 mLeftBorderWidth: 8; // stored as pixels
|
|
|
|
PRUint32 mRightBorderWidth: 8; // stored as pixels
|
|
|
|
// Widths including MIN_CON, DES_CON, FIX_CON, MIN_ADJ, DES_ADJ, FIX_ADJ, PCT, PCT_ADJ, MIN_PRO, FINAL
|
2001-11-30 18:05:51 +03: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 09:19:32 +04:00
|
|
|
nscoord mWidths[NUM_WIDTHS];
|
1998-05-30 02:08:19 +04:00
|
|
|
};
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
inline PRInt32 nsTableColFrame::GetColIndex() const
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
|
|
|
return mColIndex;
|
|
|
|
}
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
inline void nsTableColFrame::SetColIndex (PRInt32 aColIndex)
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nscoord nsTableColFrame::GetLeftBorderWidth(float* aPixelsToTwips)
|
|
|
|
{
|
|
|
|
nscoord width = (aPixelsToTwips) ? NSToCoordRound(*aPixelsToTwips * mLeftBorderWidth) : mLeftBorderWidth;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void nsTableColFrame::SetLeftBorderWidth(nscoord aWidth)
|
|
|
|
{
|
|
|
|
mLeftBorderWidth = aWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nscoord nsTableColFrame::GetRightBorderWidth(float* aPixelsToTwips)
|
|
|
|
{
|
|
|
|
nscoord width = (aPixelsToTwips) ? NSToCoordRound(*aPixelsToTwips * mRightBorderWidth) : mRightBorderWidth;
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void nsTableColFrame::SetRightBorderWidth(nscoord aWidth)
|
|
|
|
{
|
|
|
|
mRightBorderWidth = aWidth;
|
|
|
|
}
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1998-05-30 02:08:19 +04:00
|
|
|
#endif
|
|
|
|
|