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-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
|
|
|
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
|
|
|
|
*
|
2007-01-30 00:06:41 +00:00
|
|
|
* @see nsGkAtoms::tableColFrame
|
1999-10-02 00:02:54 +00:00
|
|
|
*/
|
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();
|
|
|
|
|
|
|
|
/** convenience method, calls into cellmap */
|
|
|
|
PRInt32 Count() const;
|
|
|
|
|
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
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// The largest min-width of the cells.
|
|
|
|
void ResetMinCoord() {
|
|
|
|
mMinCoord = 0;
|
|
|
|
}
|
|
|
|
void AddMinCoord(nscoord aMinCoord) {
|
|
|
|
if (aMinCoord > mMinCoord)
|
|
|
|
mMinCoord = aMinCoord;
|
|
|
|
// Needed in case mHasSpecifiedCoord is true.
|
|
|
|
if (aMinCoord > mPrefCoord)
|
|
|
|
mPrefCoord = aMinCoord;
|
|
|
|
}
|
|
|
|
nscoord GetMinCoord() {
|
|
|
|
return mMinCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The largest pref-width of the cells
|
|
|
|
void ResetPrefCoord() {
|
|
|
|
mPrefCoord = 0;
|
|
|
|
mHasSpecifiedCoord = PR_FALSE;
|
|
|
|
}
|
|
|
|
void AddPrefCoord(nscoord aPrefCoord, PRBool aHasSpecifiedCoord) {
|
|
|
|
if (aHasSpecifiedCoord) {
|
|
|
|
if (!mHasSpecifiedCoord) {
|
|
|
|
mPrefCoord = mMinCoord;
|
|
|
|
}
|
|
|
|
mHasSpecifiedCoord = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (aPrefCoord > mPrefCoord &&
|
|
|
|
(aHasSpecifiedCoord || !mHasSpecifiedCoord)) {
|
|
|
|
mPrefCoord = aPrefCoord;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nscoord GetPrefCoord() {
|
|
|
|
return mPrefCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Whether to expand greater than pref width more conservatively
|
|
|
|
// because the width was specified.
|
|
|
|
PRBool GetHasSpecifiedCoord() {
|
|
|
|
return mHasSpecifiedCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The largest specified percentage width of the cells.
|
|
|
|
void ResetPrefPercent() {
|
|
|
|
mPrefPercent = 0.0f;
|
|
|
|
}
|
|
|
|
void AddPrefPercent(float aPrefPercent) {
|
|
|
|
if (aPrefPercent > mPrefPercent)
|
|
|
|
mPrefPercent = aPrefPercent;
|
|
|
|
}
|
|
|
|
float GetPrefPercent() {
|
|
|
|
return mPrefPercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The largest min-width of the cells (for column-spanning cells).
|
|
|
|
void ResetSpanMinCoord() {
|
|
|
|
mSpanMinCoord = 0;
|
|
|
|
}
|
|
|
|
void AddSpanMinCoord(nscoord aSpanMinCoord) {
|
|
|
|
if (aSpanMinCoord > mSpanMinCoord)
|
|
|
|
mSpanMinCoord = aSpanMinCoord;
|
|
|
|
}
|
|
|
|
nscoord GetSpanMinCoord() {
|
|
|
|
return mSpanMinCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The largest pref-width of the column-spanning cells.
|
|
|
|
void ResetSpanPrefCoord() {
|
|
|
|
mSpanPrefCoord = 0;
|
|
|
|
}
|
|
|
|
void AddSpanPrefCoord(nscoord aSpanPrefCoord) {
|
|
|
|
if (aSpanPrefCoord > mSpanPrefCoord)
|
|
|
|
mSpanPrefCoord = aSpanPrefCoord;
|
|
|
|
}
|
|
|
|
nscoord GetSpanPrefCoord() {
|
|
|
|
return mSpanPrefCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The largest specified percentage width of the column-spanning cells.
|
|
|
|
void ResetSpanPrefPercent() {
|
|
|
|
mSpanPrefPercent = 0.0f;
|
|
|
|
}
|
|
|
|
void AddSpanPrefPercent(float aSpanPrefPercent) {
|
|
|
|
if (aSpanPrefPercent > mSpanPrefPercent)
|
|
|
|
mSpanPrefPercent = aSpanPrefPercent;
|
|
|
|
}
|
|
|
|
float GetSpanPrefPercent() {
|
|
|
|
return mSpanPrefPercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to adjust a column's pref percent so that the table's total
|
|
|
|
// never exceeeds 100% (by only allowing percentages to be used,
|
|
|
|
// starting at the first column, until they reach 100%).
|
|
|
|
void AdjustPrefPercent(float *aTableTotalPercent) {
|
|
|
|
float allowed = 1.0f - *aTableTotalPercent;
|
|
|
|
if (mPrefPercent > allowed)
|
|
|
|
mPrefPercent = allowed;
|
|
|
|
*aTableTotalPercent += mPrefPercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The final width of the column.
|
|
|
|
void ResetFinalWidth() {
|
|
|
|
mFinalWidth = nscoord_MIN; // so we detect that it changed
|
|
|
|
}
|
|
|
|
void SetFinalWidth(nscoord aFinalWidth) {
|
|
|
|
mFinalWidth = aFinalWidth;
|
|
|
|
}
|
|
|
|
nscoord GetFinalWidth() {
|
|
|
|
return mFinalWidth;
|
|
|
|
}
|
|
|
|
|
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;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
PRPackedBool mHasSpecifiedCoord;
|
|
|
|
nscoord mMinCoord;
|
|
|
|
nscoord mPrefCoord;
|
|
|
|
nscoord mSpanMinCoord; // XXX...
|
|
|
|
nscoord mSpanPrefCoord; // XXX...
|
|
|
|
float mPrefPercent;
|
|
|
|
float mSpanPrefPercent; // XXX...
|
|
|
|
// ...XXX the three members marked above could be allocated as part of
|
|
|
|
// a separate array allocated only during
|
|
|
|
// BasicTableLayoutStrategy::ComputeColumnIntrinsicWidths (and only
|
|
|
|
// when colspans were present).
|
|
|
|
nscoord mFinalWidth;
|
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
|
|
|
|
|