2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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-04-14 00:24:54 +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-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifndef nsCellMap_h__
|
|
|
|
#define nsCellMap_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
1998-07-11 04:47:29 +04:00
|
|
|
#include "celldata.h"
|
1998-09-15 21:58:24 +04:00
|
|
|
#include "nsVoidArray.h"
|
2006-12-07 05:32:57 +03:00
|
|
|
#include "nsTPtrArray.h"
|
2002-02-19 18:48:28 +03:00
|
|
|
#include "nsRect.h"
|
|
|
|
|
2004-03-03 20:45:50 +03:00
|
|
|
#undef DEBUG_TABLE_CELLMAP
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
class nsTableColFrame;
|
|
|
|
class nsTableCellFrame;
|
2000-01-13 08:29:38 +03:00
|
|
|
class nsTableRowGroupFrame;
|
|
|
|
class nsTableFrame;
|
|
|
|
class nsCellMap;
|
2006-12-07 05:32:57 +03:00
|
|
|
class nsPresContext;
|
2007-01-22 07:32:33 +03:00
|
|
|
class nsCellMapColumnIterator;
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
struct nsColInfo
|
|
|
|
{
|
|
|
|
PRInt32 mNumCellsOrig; // number of cells originating in the col
|
|
|
|
PRInt32 mNumCellsSpan; // number of cells spanning into the col via colspans (not rowspans)
|
2006-10-20 11:37:24 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsColInfo();
|
|
|
|
nsColInfo(PRInt32 aNumCellsOrig,
|
|
|
|
PRInt32 aNumCellsSpan);
|
|
|
|
};
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
enum Corner
|
|
|
|
{
|
|
|
|
eTopLeft = 0,
|
|
|
|
eTopRight = 1,
|
|
|
|
eBottomRight = 2,
|
|
|
|
eBottomLeft = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BCInfo
|
|
|
|
{
|
|
|
|
nsVoidArray mRightBorders;
|
|
|
|
nsVoidArray mBottomBorders;
|
|
|
|
BCData mLowerRightCorner;
|
|
|
|
};
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
class nsTableCellMap
|
|
|
|
{
|
|
|
|
public:
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableCellMap(nsTableFrame& aTableFrame,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aBorderCollapse);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
/** destructor
|
|
|
|
* NOT VIRTUAL BECAUSE THIS CLASS SHOULD **NEVER** BE SUBCLASSED
|
2006-01-14 00:08:17 +03:00
|
|
|
*/
|
2000-01-13 08:29:38 +03:00
|
|
|
~nsTableCellMap();
|
|
|
|
|
|
|
|
void RemoveGroupCellMap(nsTableRowGroupFrame* aRowGroup);
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2000-09-14 10:49:47 +04:00
|
|
|
void InsertGroupCellMap(nsTableRowGroupFrame& aNewRowGroup,
|
|
|
|
nsTableRowGroupFrame*& aPrevRowGroup);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2007-01-22 07:35:25 +03:00
|
|
|
/**
|
|
|
|
* Get the nsCellMap for the given row group. If aStartHint is non-null,
|
|
|
|
* will start looking with that cellmap and only fall back to starting at the
|
|
|
|
* beginning of the list if that doesn't find us the right nsCellMap.
|
|
|
|
* Otherwise, just start at the beginning.
|
|
|
|
*
|
|
|
|
* aRowGroup must not be null.
|
|
|
|
*/
|
|
|
|
nsCellMap* GetMapFor(const nsTableRowGroupFrame* aRowGroup,
|
|
|
|
nsCellMap* aStartHint) const;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2006-06-22 08:19:36 +04:00
|
|
|
/** synchronize the cellmaps with the rowgroups again **/
|
|
|
|
void Synchronize(nsTableFrame* aTableFrame);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
nsTableCellFrame* GetCellFrame(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
CellData& aData,
|
|
|
|
PRBool aUseRowIfOverlap) const;
|
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
/** return the CellData for the cell at (aRowIndex, aColIndex) */
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* GetDataAt(PRInt32 aRowIndex,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 aColIndex) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
// this function creates a col if needed
|
2000-01-13 08:29:38 +03:00
|
|
|
nsColInfo* GetColInfoAt(PRInt32 aColIndex);
|
|
|
|
|
|
|
|
/** append the cellFrame at the end of the row at aRowIndex and return the col index
|
|
|
|
*/
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* AppendCell(nsTableCellFrame& aCellFrame,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aRebuildIfNecessary,
|
|
|
|
nsRect& aDamageArea);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
void InsertCells(nsVoidArray& aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aColIndexBefore,
|
|
|
|
nsRect& aDamageArea);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
void RemoveCell(nsTableCellFrame* aCellFrame,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aRowIndex,
|
|
|
|
nsRect& aDamageArea);
|
2006-06-28 22:56:10 +04:00
|
|
|
/** Remove the previously gathered column information */
|
|
|
|
void ClearCols();
|
2004-01-18 13:28:40 +03:00
|
|
|
void InsertRows(nsTableRowGroupFrame& aRowGroup,
|
2000-01-13 08:29:38 +03:00
|
|
|
nsVoidArray& aRows,
|
|
|
|
PRInt32 aFirstRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aConsiderSpans,
|
|
|
|
nsRect& aDamageArea);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
void RemoveRows(PRInt32 aFirstRowIndex,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRInt32 aNumRowsToRemove,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aConsiderSpans,
|
|
|
|
nsRect& aDamageArea);
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
|
|
|
|
|
2004-04-13 10:21:16 +04:00
|
|
|
/** indicate whether the row has more than one cell that either originates
|
|
|
|
* or is spanned from the rows above
|
|
|
|
*/
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool HasMoreThanOneCell(PRInt32 aRowIndex) const;
|
2004-04-13 10:21:16 +04:00
|
|
|
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 GetEffectiveRowSpan(PRInt32 aRowIndex,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 aColIndex) const;
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 GetEffectiveColSpan(PRInt32 aRowIndex,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 aColIndex) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
/** return the total number of columns in the table represented by this CellMap */
|
|
|
|
PRInt32 GetColCount() const;
|
|
|
|
|
|
|
|
/** return the actual number of rows in the table represented by this CellMap */
|
|
|
|
PRInt32 GetRowCount() const;
|
|
|
|
|
|
|
|
nsTableCellFrame* GetCellInfoAt(PRInt32 aRowX,
|
|
|
|
PRInt32 aColX,
|
|
|
|
PRBool* aOriginates = nsnull,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32* aColSpan = nsnull) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
void AddColsAtEnd(PRUint32 aNumCols);
|
2001-05-17 16:40:27 +04:00
|
|
|
void RemoveColsAtEnd();
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool RowIsSpannedInto(PRInt32 aRowIndex, PRInt32 aNumEffCols) const;
|
|
|
|
PRBool RowHasSpanningCells(PRInt32 aRowIndex, PRInt32 aNumEffCols) const;
|
2006-06-28 22:56:10 +04:00
|
|
|
void RebuildConsideringCells(nsCellMap* aCellMap,
|
|
|
|
nsVoidArray* aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRBool aInsert,
|
|
|
|
nsRect& aDamageArea);
|
2006-12-07 05:32:57 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Rebuild due to rows being inserted or deleted with cells spanning
|
|
|
|
* into or out of the rows. This function can only handle insertion
|
|
|
|
* or deletion but NOT both. So either aRowsToInsert must be null
|
|
|
|
* or aNumRowsToRemove must be 0.
|
|
|
|
*
|
|
|
|
* // XXXbz are both allowed to happen? That'd be a no-op...
|
|
|
|
*/
|
2006-06-28 22:56:10 +04:00
|
|
|
void RebuildConsideringRows(nsCellMap* aCellMap,
|
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
nsVoidArray* aRowsToInsert,
|
2006-12-07 05:32:57 +03:00
|
|
|
PRInt32 aNumRowsToRemove,
|
2006-06-28 22:56:10 +04:00
|
|
|
nsRect& aDamageArea);
|
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
public:
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool ColIsSpannedInto(PRInt32 aColIndex) const;
|
|
|
|
PRBool ColHasSpanningCells(PRInt32 aColIndex) const;
|
|
|
|
|
|
|
|
void ExpandZeroColSpans();
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
BCData* GetBCData(PRUint8 aSide,
|
|
|
|
nsCellMap& aCellMap,
|
|
|
|
PRUint32 aYPos,
|
|
|
|
PRUint32 aXPos,
|
|
|
|
PRBool aIsLowerRight = PR_FALSE);
|
|
|
|
|
|
|
|
void SetBCBorderEdge(PRUint8 aEdge,
|
|
|
|
nsCellMap& aCellMap,
|
|
|
|
PRUint32 aCellMapStart,
|
|
|
|
PRUint32 aYPos,
|
|
|
|
PRUint32 aXPos,
|
|
|
|
PRUint32 aLength,
|
|
|
|
BCBorderOwner aOwner,
|
|
|
|
nscoord aSize,
|
|
|
|
PRBool aChanged);
|
|
|
|
|
|
|
|
void SetBCBorderCorner(Corner aCorner,
|
|
|
|
nsCellMap& aCellMap,
|
|
|
|
PRUint32 aCellMapStart,
|
|
|
|
PRUint32 aYPos,
|
|
|
|
PRUint32 aXPos,
|
|
|
|
PRUint8 aOwner,
|
|
|
|
nscoord aSubSize,
|
|
|
|
PRBool aBevel,
|
|
|
|
PRBool aIsBottomRight = PR_FALSE);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
/** dump a representation of the cell map to stdout for debugging */
|
|
|
|
#ifdef NS_DEBUG
|
2001-11-20 03:58:53 +03:00
|
|
|
void Dump(char* aString = nsnull) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2002-02-19 18:48:28 +03:00
|
|
|
BCData* GetRightMostBorder(PRInt32 aRowIndex);
|
|
|
|
BCData* GetBottomMostBorder(PRInt32 aColIndex);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
friend class nsCellMap;
|
2002-02-19 18:48:28 +03:00
|
|
|
friend class BCMapCellIterator;
|
|
|
|
friend class BCMapBorderIterator;
|
2007-01-22 07:32:33 +03:00
|
|
|
friend class nsCellMapColumnIterator;
|
|
|
|
|
2005-12-16 22:10:56 +03:00
|
|
|
/** Insert a row group cellmap after aPrevMap, if aPrefMap is null insert it
|
|
|
|
* at the beginning, the ordering of the cellmap corresponds to the ordering of
|
|
|
|
* rowgroups once OrderRowGroups has been called
|
|
|
|
*/
|
2000-01-13 08:29:38 +03:00
|
|
|
void InsertGroupCellMap(nsCellMap* aPrevMap,
|
|
|
|
nsCellMap& aNewMap);
|
2002-02-19 18:48:28 +03:00
|
|
|
void DeleteRightBottomBorders();
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableFrame& mTableFrame;
|
2001-09-07 01:11:44 +04:00
|
|
|
nsAutoVoidArray mCols;
|
2002-02-19 18:48:28 +03:00
|
|
|
nsCellMap* mFirstMap;
|
|
|
|
// border collapsing info
|
|
|
|
BCInfo* mBCInfo;
|
2000-01-13 08:29:38 +03:00
|
|
|
};
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** nsCellMap is a support class for nsTablePart.
|
|
|
|
* It maintains an Rows x Columns grid onto which the cells of the table are mapped.
|
|
|
|
* This makes processing of rowspan and colspan attributes much easier.
|
|
|
|
* Each cell is represented by a CellData object.
|
|
|
|
*
|
|
|
|
* @see CellData
|
1998-09-01 01:23:28 +04:00
|
|
|
* @see nsTableFrame::AddCellToMap
|
1998-06-17 20:38:24 +04:00
|
|
|
* @see nsTableFrame::GrowCellMap
|
|
|
|
* @see nsTableFrame::BuildCellIntoMap
|
1998-04-15 01:45:28 +04:00
|
|
|
*
|
2006-12-07 05:32:57 +03:00
|
|
|
* mRows is an array of rows. Each row is an array of cells. a cell
|
|
|
|
* can be null.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
class nsCellMap
|
|
|
|
{
|
|
|
|
public:
|
1998-09-01 01:23:28 +04:00
|
|
|
/** constructor
|
2006-01-14 00:08:17 +03:00
|
|
|
* @param aRowGroupFrame the row group frame this is a cellmap for
|
|
|
|
* @param aIsBC whether the table is doing border-collapse
|
|
|
|
*/
|
|
|
|
nsCellMap(nsTableRowGroupFrame& aRowGroupFrame, PRBool aIsBC);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/** destructor
|
|
|
|
* NOT VIRTUAL BECAUSE THIS CLASS SHOULD **NEVER** BE SUBCLASSED
|
2006-01-14 00:08:17 +03:00
|
|
|
*/
|
1998-04-14 00:24:54 +04:00
|
|
|
~nsCellMap();
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
nsCellMap* GetNextSibling() const;
|
|
|
|
void SetNextSibling(nsCellMap* aSibling);
|
|
|
|
|
|
|
|
nsTableRowGroupFrame* GetRowGroup() const;
|
|
|
|
|
|
|
|
nsTableCellFrame* GetCellFrame(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
CellData& aData,
|
|
|
|
PRBool aUseRowSpanIfOverlap) const;
|
|
|
|
|
2003-01-18 17:02:52 +03:00
|
|
|
/** append the cellFrame at an empty or dead cell or finally at the end of
|
|
|
|
* the row at aRowIndex and return a pointer to the celldata entry in the
|
|
|
|
* cellmap
|
|
|
|
*
|
|
|
|
* @param aMap - reference to the table cell map
|
|
|
|
* @param aCellFrame - a pointer to the cellframe which will be appended
|
|
|
|
* to the row
|
|
|
|
* @param aRowIndex - to this row the celldata entry will be added
|
|
|
|
* @param aRebuildIfNecessay - if a cell spans into a row below it might be
|
|
|
|
* necesserary to rebuild the cellmap as this rowspan
|
|
|
|
* might overlap another cell.
|
|
|
|
* @param aDamageArea - area in cellmap coordinates which have been updated.
|
|
|
|
* @param aColToBeginSearch - if not null contains the column number where
|
|
|
|
* the search for a empty or dead cell in the
|
|
|
|
* row should start
|
|
|
|
* @return - a pointer to the celldata entry inserted into
|
|
|
|
* the cellmap
|
1999-07-28 12:09:02 +04:00
|
|
|
*/
|
2002-02-19 18:48:28 +03:00
|
|
|
CellData* AppendCell(nsTableCellMap& aMap,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aRebuildIfNecessary,
|
2003-01-18 17:02:52 +03:00
|
|
|
nsRect& aDamageArea,
|
|
|
|
PRInt32* aBeginSearchAtCol = nsnull);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
/** Function to be called when a cell is added at a location which is spanned
|
|
|
|
* to by a zero colspan. We handle this situation by collapsing the zero
|
|
|
|
* colspan, since there is really no good way to deal with it (trying to
|
|
|
|
* increase the number of columns to hold the new cell would just mean the
|
|
|
|
* zero colspan needs to expand).
|
|
|
|
|
|
|
|
* @param aMap - reference to the table cell map
|
|
|
|
* @param aOrigData - zero colspanned cell that will be collapsed
|
|
|
|
* @param aRowIndex - row where the first collision appears
|
|
|
|
* @param aColIndex - column where the first collision appears
|
|
|
|
**/
|
|
|
|
void CollapseZeroColSpan(nsTableCellMap& aMap,
|
|
|
|
CellData* aOrigData,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void InsertCells(nsTableCellMap& aMap,
|
|
|
|
nsVoidArray& aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aColIndexBefore,
|
|
|
|
nsRect& aDamageArea);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void RemoveCell(nsTableCellMap& aMap,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aRowIndex,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
void InsertRows(nsTableCellMap& aMap,
|
2000-01-13 08:29:38 +03:00
|
|
|
nsVoidArray& aRows,
|
|
|
|
PRInt32 aFirstRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aConsiderSpans,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
void RemoveRows(nsTableCellMap& aMap,
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 aFirstRowIndex,
|
|
|
|
PRInt32 aNumRowsToRemove,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aConsiderSpans,
|
|
|
|
nsRect& aDamageArea);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
PRInt32 GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const;
|
|
|
|
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
|
1999-02-11 09:22:33 +03:00
|
|
|
|
2001-03-29 01:25:13 +04:00
|
|
|
/** return the number of rows in the table represented by this CellMap */
|
|
|
|
PRInt32 GetRowCount(PRBool aConsiderDeadRowSpanRows = PR_FALSE) const;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
nsTableCellFrame* GetCellInfoAt(const nsTableCellMap& aMap,
|
|
|
|
PRInt32 aRowX,
|
|
|
|
PRInt32 aColX,
|
|
|
|
PRBool* aOriginates = nsnull,
|
|
|
|
PRInt32* aColSpan = nsnull) const;
|
1998-09-19 02:37:14 +04:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool RowIsSpannedInto(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aNumEffCols) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool RowHasSpanningCells(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aNumEffCols) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool ColHasSpanningCells(PRInt32 aColIndex) const;
|
|
|
|
|
|
|
|
void ExpandZeroColSpans(nsTableCellMap& aMap);
|
1999-08-19 23:52:37 +04:00
|
|
|
|
2004-04-13 10:21:16 +04:00
|
|
|
/** indicate whether the row has more than one cell that either originates
|
|
|
|
* or is spanned from the rows above
|
|
|
|
*/
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool HasMoreThanOneCell(PRInt32 aRowIndex) const;
|
2004-04-13 10:21:16 +04:00
|
|
|
|
2007-01-01 21:18:53 +03:00
|
|
|
/* Get the rowspan for a cell starting at aRowIndex and aColIndex.
|
|
|
|
* If aGetEffective is true the size will not exceed the last content based
|
|
|
|
* row. Cells can have a specified rowspan that extends below the last
|
|
|
|
* content based row. This is legitimate considering incr. reflow where the
|
|
|
|
* content rows will arive later.
|
|
|
|
*/
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 GetRowSpan(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
2007-01-01 21:18:53 +03:00
|
|
|
PRBool aGetEffective) const;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 GetEffectiveColSpan(const nsTableCellMap& aMap,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRBool& aIsZeroColSpan) const;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
typedef nsTPtrArray<CellData> CellDataArray;
|
|
|
|
|
1998-09-19 02:37:14 +04:00
|
|
|
/** dump a representation of the cell map to stdout for debugging */
|
1999-07-28 12:09:02 +04:00
|
|
|
#ifdef NS_DEBUG
|
2002-02-19 18:48:28 +03:00
|
|
|
void Dump(PRBool aIsBorderCollapse) const;
|
1999-07-28 12:09:02 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
2000-01-13 08:29:38 +03:00
|
|
|
friend class nsTableCellMap;
|
2002-02-19 18:48:28 +03:00
|
|
|
friend class BCMapCellIterator;
|
|
|
|
friend class BCMapBorderIterator;
|
|
|
|
friend class nsTableFrame;
|
2007-01-22 07:32:33 +03:00
|
|
|
friend class nsCellMapColumnIterator;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
/**
|
|
|
|
* Increase the number of rows in this cellmap by aNumRows. Put the
|
|
|
|
* new rows at aRowIndex. If aRowIndex is -1, put them at the end.
|
|
|
|
*/
|
2000-01-13 08:29:38 +03:00
|
|
|
PRBool Grow(nsTableCellMap& aMap,
|
|
|
|
PRInt32 aNumRows,
|
|
|
|
PRInt32 aRowIndex = -1);
|
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
void GrowRow(CellDataArray& aRow,
|
|
|
|
PRInt32 aNumCols);
|
1999-07-28 12:09:02 +04:00
|
|
|
|
|
|
|
/** assign aCellData to the cell at (aRow,aColumn) */
|
2002-02-19 18:48:28 +03:00
|
|
|
void SetDataAt(nsTableCellMap& aMap,
|
|
|
|
CellData& aCellData,
|
|
|
|
PRInt32 aMapRowIndex,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 aColIndex);
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
CellData* GetDataAt(PRInt32 aMapRowIndex,
|
|
|
|
PRInt32 aColIndex) const;
|
1999-07-28 12:09:02 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 GetNumCellsIn(PRInt32 aColIndex) const;
|
|
|
|
|
2004-01-18 13:28:40 +03:00
|
|
|
void ExpandWithRows(nsTableCellMap& aMap,
|
2000-01-13 08:29:38 +03:00
|
|
|
nsVoidArray& aRowFrames,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
nsRect& aDamageArea);
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void ExpandWithCells(nsTableCellMap& aMap,
|
|
|
|
nsVoidArray& aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRInt32 aRowSpan,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aRowSpanIsZero,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void ShrinkWithoutRows(nsTableCellMap& aMap,
|
|
|
|
PRInt32 aFirstRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aNumRowsToRemove,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void ShrinkWithoutCell(nsTableCellMap& aMap,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
1999-12-14 01:56:31 +03:00
|
|
|
PRInt32 aRowIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aColIndex,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
/**
|
|
|
|
* Rebuild due to rows being inserted or deleted with cells spanning
|
|
|
|
* into or out of the rows. This function can only handle insertion
|
|
|
|
* or deletion but NOT both. So either aRowsToInsert must be null
|
|
|
|
* or aNumRowsToRemove must be 0.
|
|
|
|
*
|
|
|
|
* // XXXbz are both allowed to happen? That'd be a no-op...
|
|
|
|
*/
|
2004-01-18 13:28:40 +03:00
|
|
|
void RebuildConsideringRows(nsTableCellMap& aMap,
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
nsVoidArray* aRowsToInsert,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRInt32 aNumRowsToRemove,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void RebuildConsideringCells(nsTableCellMap& aMap,
|
2006-06-28 22:56:10 +04:00
|
|
|
PRInt32 aNumOrigCols,
|
2000-01-13 08:29:38 +03:00
|
|
|
nsVoidArray* aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
2002-02-19 18:48:28 +03:00
|
|
|
PRBool aInsert,
|
|
|
|
nsRect& aDamageArea);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool CellsSpanOut(nsVoidArray& aNewRows) const;
|
2006-08-02 15:57:48 +04:00
|
|
|
|
|
|
|
/** If a cell spans out of the area defined by aStartRowIndex, aEndRowIndex
|
|
|
|
* and aStartColIndex, aEndColIndex the cellmap changes are more severe so
|
|
|
|
* the corresponding routines needs to be called. This is also necessary if
|
|
|
|
* cells outside spans into this region.
|
|
|
|
* @aStartRowIndex - y start index
|
|
|
|
* @aEndRowIndex - y end index
|
|
|
|
* @param aStartColIndex - x start index
|
|
|
|
* @param aEndColIndex - x end index
|
|
|
|
* @return - true if a cell span crosses the border of the
|
|
|
|
region
|
|
|
|
*/
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool CellsSpanInOrOut(PRInt32 aStartRowIndex,
|
|
|
|
PRInt32 aEndRowIndex,
|
|
|
|
PRInt32 aStartColIndex,
|
|
|
|
PRInt32 aEndColIndex) const;
|
2000-01-13 08:29:38 +03:00
|
|
|
|
|
|
|
void ExpandForZeroSpan(nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aNumColsInTable);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
PRBool CreateEmptyRow(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aNumCols);
|
2000-01-04 08:31:56 +03:00
|
|
|
|
2006-10-20 11:37:24 +04:00
|
|
|
PRInt32 GetRowSpanForNewCell(nsTableCellFrame* aCellFrameToAdd,
|
2000-02-01 06:23:29 +03:00
|
|
|
PRInt32 aRowIndex,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool& aIsZeroRowSpan) const;
|
2000-02-01 06:23:29 +03:00
|
|
|
|
|
|
|
PRInt32 GetColSpanForNewCell(nsTableCellFrame& aCellFrameToAdd,
|
2006-10-20 11:37:24 +04:00
|
|
|
PRBool& aIsZeroColSpan) const;
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
PRBool IsZeroColSpan(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex) const;
|
2000-01-04 08:31:56 +03:00
|
|
|
|
2006-01-14 00:08:17 +03:00
|
|
|
// Destroy a CellData struct. This will handle the case of aData
|
|
|
|
// actually being a BCCellData properly.
|
|
|
|
void DestroyCellData(CellData* aData);
|
|
|
|
// Allocate a CellData struct. This will handle needing to create a
|
|
|
|
// BCCellData properly.
|
|
|
|
// @param aOrigCell the originating cell to pass to the celldata constructor
|
|
|
|
CellData* AllocCellData(nsTableCellFrame* aOrigCell);
|
|
|
|
|
2006-12-07 05:32:57 +03:00
|
|
|
/** an array containing, for each row, the CellDatas for the cells
|
2006-12-26 17:04:20 +03:00
|
|
|
* in that row. It can be larger than mContentRowCount due to row spans
|
2006-12-07 05:32:57 +03:00
|
|
|
* extending beyond the table */
|
|
|
|
// XXXbz once we have auto TArrays, we should probably use them here.
|
|
|
|
nsTArray<CellDataArray> mRows;
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2006-08-02 15:57:48 +04:00
|
|
|
/** the number of rows in the table (content) which is not indentical to the
|
|
|
|
* number of rows in the cell map due to row spans extending beyond the end
|
|
|
|
* of thetable (dead rows) or empty tr tags
|
|
|
|
*/
|
2006-12-26 17:04:20 +03:00
|
|
|
PRInt32 mContentRowCount;
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
// the row group that corresponds to this map
|
|
|
|
nsTableRowGroupFrame* mRowGroupFrame;
|
|
|
|
|
|
|
|
// the next row group cell map
|
|
|
|
nsCellMap* mNextSibling;
|
|
|
|
|
2006-01-14 00:08:17 +03:00
|
|
|
// Whether this is a BC cellmap or not
|
|
|
|
PRBool mIsBC;
|
2006-12-07 05:32:57 +03:00
|
|
|
|
|
|
|
// Prescontext to deallocate and allocate celldata
|
|
|
|
nsCOMPtr<nsPresContext> mPresContext;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2007-01-22 07:32:33 +03:00
|
|
|
/**
|
|
|
|
* A class for iterating the cells in a given column. Must be given a
|
|
|
|
* non-null nsTableCellMap and a column number valid for that cellmap.
|
|
|
|
*/
|
|
|
|
class nsCellMapColumnIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsCellMapColumnIterator(const nsTableCellMap* aMap, PRInt32 aCol) :
|
2007-01-24 23:18:04 +03:00
|
|
|
mMap(aMap), mCurMap(aMap->mFirstMap), mRow(0),
|
|
|
|
mCurMapRow(0), mCol(aCol), mFoundCells(0)
|
2007-01-22 07:32:33 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aMap, "Must have map");
|
|
|
|
NS_PRECONDITION(mCol < aMap->GetColCount(), "Invalid column");
|
|
|
|
mOrigCells = aMap->GetNumCellsOriginatingInCol(mCol);
|
|
|
|
if (mCurMap) {
|
2007-01-24 23:23:08 +03:00
|
|
|
mCurMapContentRowCount = mCurMap->GetRowCount();
|
|
|
|
if (mCurMapContentRowCount == 0 && mOrigCells > 0) {
|
2007-01-24 23:18:04 +03:00
|
|
|
// This row group is useless; advance!
|
|
|
|
AdvanceRowGroup();
|
|
|
|
}
|
2007-01-22 07:32:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableCellFrame* GetNextFrame(PRInt32* aRow, PRInt32* aColSpan);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void AdvanceRowGroup();
|
|
|
|
|
|
|
|
// Advance the row; aIncrement is considered to be a cell's rowspan,
|
|
|
|
// so if 0 is passed in we'll advance to the next rowgroup.
|
|
|
|
void IncrementRow(PRInt32 aIncrement);
|
|
|
|
|
|
|
|
const nsTableCellMap* mMap;
|
|
|
|
const nsCellMap* mCurMap;
|
2007-01-24 23:18:04 +03:00
|
|
|
|
|
|
|
// mRow is the row in the entire nsTableCellMap where we are right now. This
|
|
|
|
// must be passable to nsTableCellMap::GetDataAt, so must be a _content_ row
|
|
|
|
// index.
|
2007-01-22 07:32:33 +03:00
|
|
|
PRUint32 mRow;
|
2007-01-24 23:18:04 +03:00
|
|
|
|
|
|
|
// In steady-state mCurMapRow is the row in our current nsCellMap
|
|
|
|
// that we'll use the next time GetNextFrame() is called. Due to
|
|
|
|
// the way we skip over rowspans, the entry in mCurMapRow and mCol
|
|
|
|
// is either null, dead, originating, or a colspan. In particular,
|
|
|
|
// it cannot be a rowspan or overlap entry.
|
|
|
|
PRUint32 mCurMapRow;
|
2007-01-22 07:32:33 +03:00
|
|
|
const PRInt32 mCol;
|
|
|
|
PRUint32 mOrigCells;
|
|
|
|
PRUint32 mFoundCells;
|
2007-01-24 23:23:08 +03:00
|
|
|
PRUint32 mCurMapContentRowCount;
|
2007-01-22 07:32:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/* ----- inline methods ----- */
|
2000-01-13 08:29:38 +03:00
|
|
|
inline PRInt32 nsTableCellMap::GetColCount() const
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
return mCols.Count();
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
inline nsCellMap* nsCellMap::GetNextSibling() const
|
1998-06-08 23:57:04 +04:00
|
|
|
{
|
2000-01-13 08:29:38 +03:00
|
|
|
return mNextSibling;
|
1998-06-08 23:57:04 +04:00
|
|
|
}
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
inline void nsCellMap::SetNextSibling(nsCellMap* aSibling)
|
|
|
|
{
|
|
|
|
mNextSibling = aSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsTableRowGroupFrame* nsCellMap::GetRowGroup() const
|
|
|
|
{
|
|
|
|
return mRowGroupFrame;
|
1998-06-08 23:57:04 +04:00
|
|
|
}
|
|
|
|
|
2001-03-29 01:25:13 +04:00
|
|
|
inline PRInt32 nsCellMap::GetRowCount(PRBool aConsiderDeadRowSpanRows) const
|
1998-06-08 23:57:04 +04:00
|
|
|
{
|
2006-12-26 17:04:20 +03:00
|
|
|
PRInt32 rowCount = (aConsiderDeadRowSpanRows) ? mRows.Length() : mContentRowCount;
|
2001-03-29 01:25:13 +04:00
|
|
|
return rowCount;
|
1998-06-08 23:57:04 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// nsColInfo
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
inline nsColInfo::nsColInfo()
|
|
|
|
:mNumCellsOrig(0), mNumCellsSpan(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
inline nsColInfo::nsColInfo(PRInt32 aNumCellsOrig,
|
|
|
|
PRInt32 aNumCellsSpan)
|
|
|
|
:mNumCellsOrig(aNumCellsOrig), mNumCellsSpan(aNumCellsSpan)
|
|
|
|
{}
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif
|