1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03: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-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
#ifndef nsTableFrame_h__
|
|
|
|
#define nsTableFrame_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
1998-12-17 01:19:23 +03:00
|
|
|
#include "nsVoidArray.h"
|
1998-10-20 21:45:07 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-06-05 10:09:09 +04:00
|
|
|
#include "nsStyleCoord.h"
|
1998-10-11 13:18:27 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-12-18 01:59:40 +03:00
|
|
|
#include "nsIStyleContext.h"
|
1999-08-01 02:11:50 +04:00
|
|
|
#include "nsITableLayout.h"
|
1999-12-14 03:24:33 +03:00
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
class nsTableCellMap;
|
1998-04-14 00:24:54 +04:00
|
|
|
class nsTableCellFrame;
|
1998-06-05 06:36:25 +04:00
|
|
|
class nsTableColFrame;
|
1998-07-02 02:22:28 +04:00
|
|
|
class nsTableRowGroupFrame;
|
1998-06-17 20:38:24 +04:00
|
|
|
class nsTableRowFrame;
|
1998-10-15 02:51:50 +04:00
|
|
|
class nsTableColGroupFrame;
|
1999-10-28 08:09:39 +04:00
|
|
|
class nsTableBorderCollapser;
|
1998-04-30 21:57:09 +04:00
|
|
|
class nsITableLayoutStrategy;
|
1998-05-27 00:57:24 +04:00
|
|
|
class nsHTMLValue;
|
1999-10-28 08:09:39 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
struct InnerTableReflowState;
|
1998-04-25 22:48:48 +04:00
|
|
|
struct nsStylePosition;
|
1998-05-27 00:57:24 +04:00
|
|
|
struct nsStyleSpacing;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
/**
|
|
|
|
* Child list name indices
|
|
|
|
* @see #GetAdditionalChildListName()
|
|
|
|
*/
|
|
|
|
#define NS_TABLE_FRAME_COLGROUP_LIST_INDEX 0
|
|
|
|
#define NS_TABLE_FRAME_LAST_LIST_INDEX NS_TABLE_FRAME_COLGROUP_LIST_INDEX
|
|
|
|
|
1999-08-24 16:01:31 +04:00
|
|
|
struct nsDebugTable
|
|
|
|
{
|
1999-08-27 08:29:05 +04:00
|
|
|
static PRBool gRflTableOuter;
|
1999-08-24 16:01:31 +04:00
|
|
|
static PRBool gRflTable;
|
|
|
|
static PRBool gRflRowGrp;
|
|
|
|
static PRBool gRflRow;
|
|
|
|
static PRBool gRflCell;
|
|
|
|
static PRBool gRflArea;
|
|
|
|
};
|
1998-07-07 01:00:11 +04:00
|
|
|
/* ============================================================================ */
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** nsTableFrame maps the inner portion of a table (everything except captions.)
|
1998-12-04 06:14:28 +03:00
|
|
|
* Used as a pseudo-frame within nsTableOuterFrame, it may also be used
|
|
|
|
* stand-alone as the top-level frame.
|
|
|
|
*
|
1999-01-27 22:29:24 +03:00
|
|
|
* The flowed child list contains row group frames. There is also an additional
|
1998-12-04 06:14:28 +03:00
|
|
|
* named child list:
|
|
|
|
* - "ColGroup-list" which contains the col group frames
|
1998-04-15 01:45:28 +04:00
|
|
|
*
|
1998-12-09 08:30:17 +03:00
|
|
|
* @see nsLayoutAtoms::colGroupList
|
1998-04-15 01:45:28 +04:00
|
|
|
*
|
|
|
|
* TODO: make methods virtual so nsTableFrame can be used as a base class in the future.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-08-01 02:11:50 +04:00
|
|
|
class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
1999-08-01 02:11:50 +04:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** nsTableOuterFrame has intimate knowledge of the inner table frame */
|
1998-04-14 00:24:54 +04:00
|
|
|
friend class nsTableOuterFrame;
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** instantiate a new instance of nsTableFrame.
|
1998-09-15 21:58:24 +04: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-15 01:45:28 +04:00
|
|
|
*
|
|
|
|
* @return NS_OK if the frame was properly allocated, otherwise an error code
|
|
|
|
*/
|
1998-09-15 21:58:24 +04:00
|
|
|
friend nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** sets defaults for table-specific style.
|
|
|
|
* @see nsIFrame::Init
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1998-12-05 08:27:21 +03:00
|
|
|
nsIContent* aContent,
|
1999-01-14 08:16:23 +03:00
|
|
|
nsIFrame* aParent,
|
1999-02-25 06:27:57 +03:00
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
1998-12-05 08:27:21 +03:00
|
|
|
|
|
|
|
|
2000-09-01 05:29:50 +04:00
|
|
|
static nscoord RoundToPixel(nscoord aValue,
|
|
|
|
float aPixelToTwips);
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
NS_IMETHOD IsPercentageBase(PRBool& aBase) const;
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
static nsresult AddTableDirtyReflowCommand(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aTableFrame);
|
|
|
|
/*
|
|
|
|
* Notification that aAttribute has changed for content inside a table (cell, row, etc)
|
|
|
|
*/
|
|
|
|
void AttributeChangedFor(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIAtom* aAttribute);
|
|
|
|
|
1999-07-22 06:24:52 +04:00
|
|
|
/** @see nsIFrame::Destroy */
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
|
1998-12-04 06:14:28 +03:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-19 07:51:25 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
1998-09-24 20:37:22 +04:00
|
|
|
/** helper method to find the table parent of any table frame object */
|
1999-01-27 22:29:24 +03:00
|
|
|
// TODO: today, this depends on display types. This should be changed to rely
|
|
|
|
// on stronger criteria, like an inner table frame atom
|
1999-12-14 01:56:31 +03:00
|
|
|
static NS_METHOD GetTableFrame(nsIFrame* aSourceFrame,
|
|
|
|
nsTableFrame*& aTableFrame);
|
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
// calculate the width of aFrame including its border and padding given
|
|
|
|
// given its reflow state.
|
2000-01-13 08:29:38 +03:00
|
|
|
nscoord CalcBorderBoxWidth(const nsHTMLReflowState& aReflowState);
|
2000-01-03 01:55:48 +03:00
|
|
|
|
|
|
|
// calculate the height of aFrame including its border and padding given
|
|
|
|
// its reflow state.
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord CalcBorderBoxHeight(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState);
|
2000-01-03 01:55:48 +03:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// Return the closest sibling of aPriorChildFrame (including aPriroChildFrame)
|
|
|
|
// of type aChildType.
|
2000-01-22 04:16:50 +03:00
|
|
|
static nsIFrame* GetFrameAtOrBefore(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame* aPriorChildFrame,
|
|
|
|
nsIAtom* aChildType);
|
2000-01-03 01:55:48 +03:00
|
|
|
PRBool IsAutoWidth();
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @return PR_TRUE if aDisplayType represents a rowgroup of any sort
|
1998-10-11 13:18:27 +04:00
|
|
|
* (header, footer, or body)
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
PRBool IsRowGroup(PRInt32 aDisplayType) const;
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** Initialize the table frame with a set of children.
|
|
|
|
* @see nsIFrame::SetInitialChildList
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList);
|
1998-09-16 21:19:20 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** return the first child belonging to the list aListName.
|
|
|
|
* @see nsIFrame::FirstChild
|
|
|
|
*/
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_IMETHOD FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const;
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @see nsIFrame::GetAdditionalChildListName */
|
1998-12-03 21:01:35 +03:00
|
|
|
NS_IMETHOD GetAdditionalChildListName(PRInt32 aIndex,
|
1999-02-10 05:25:01 +03:00
|
|
|
nsIAtom** aListName) const;
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** @see nsIFrame::Paint */
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
/** nsIFrame method overridden to handle table specifics
|
|
|
|
*/
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread);
|
1999-05-20 04:52:00 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** inner tables are reflowed in two steps.
|
|
|
|
* <pre>
|
|
|
|
* if mFirstPassValid is false, this is our first time through since content was last changed
|
|
|
|
* set pass to 1
|
|
|
|
* do pass 1
|
|
|
|
* get min/max info for all cells in an infinite space
|
|
|
|
* do column balancing
|
|
|
|
* set mFirstPassValid to true
|
|
|
|
* do pass 2
|
1998-05-25 21:31:49 +04:00
|
|
|
* use column widths to Reflow cells
|
1998-04-15 01:45:28 +04:00
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @see ResizeReflowPass1
|
|
|
|
* @see ResizeReflowPass2
|
|
|
|
* @see BalanceColumnWidths
|
1999-01-27 22:29:24 +03:00
|
|
|
* @see nsIFrameReflow::Reflow
|
1998-04-15 01:45:28 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsReflowStatus& aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-09-13 02:48:35 +04:00
|
|
|
NS_IMETHOD GetParentStyleContextProvider(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame** aProviderFrame,
|
|
|
|
nsContextProviderRelationship& aRelationship);
|
1999-05-20 04:52:00 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/** return the column frame corresponding to the given column index
|
|
|
|
* there are two ways to do this, depending on whether we have cached
|
|
|
|
* column information yet.
|
|
|
|
*/
|
|
|
|
NS_METHOD GetColumnFrame(PRInt32 aColIndex, nsTableColFrame *&aColFrame);
|
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
static nsMargin GetPadding(const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsTableCellFrame* aCellFrame);
|
|
|
|
|
|
|
|
static nsMargin GetPadding(const nsSize& aBasis,
|
|
|
|
const nsTableCellFrame* aCellFrame);
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsFrameList& GetColGroups();
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
/** return PR_TRUE if the column width information has been set */
|
|
|
|
PRBool IsColumnWidthsSet();
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableFrame
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
1998-12-23 18:47:43 +03:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @see nsIFrame::GetFrameName */
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& 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
|
1999-08-31 07:09:40 +04:00
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/** get the max border thickness for each edge */
|
1998-12-21 22:20:37 +03:00
|
|
|
void GetTableBorder(nsMargin &aBorder);
|
|
|
|
|
1999-10-28 08:09:39 +04:00
|
|
|
void SetBorderEdgeLength(PRUint8 aSide,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nscoord aLength);
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/** get the border values for the row and column */
|
1999-10-28 08:09:39 +04:00
|
|
|
void GetTableBorderAt(PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
nsMargin &aBorder);
|
1998-12-23 18:47:43 +03:00
|
|
|
|
|
|
|
/** get the max border thickness for each edge encompassed by the row group */
|
|
|
|
void GetTableBorderForRowGroup(nsTableRowGroupFrame * aRowGroupFrame, nsMargin &aBorder);
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** return the width of the column at aColIndex */
|
1998-05-30 02:08:19 +04:00
|
|
|
virtual PRInt32 GetColumnWidth(PRInt32 aColIndex);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** set the width of the column at aColIndex to aWidth */
|
1998-06-05 22:11:20 +04:00
|
|
|
virtual void SetColumnWidth(PRInt32 aColIndex, nscoord aWidth);
|
1998-07-17 03:23:31 +04:00
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
/** helper to get the border collapse style value */
|
|
|
|
virtual PRUint8 GetBorderCollapseStyle();
|
1998-12-05 08:27:21 +03:00
|
|
|
|
1998-12-09 09:37:18 +03:00
|
|
|
/** helper to get the cell spacing X style value */
|
|
|
|
virtual nscoord GetCellSpacingX();
|
|
|
|
|
|
|
|
/** helper to get the cell spacing Y style value */
|
|
|
|
virtual nscoord GetCellSpacingY();
|
|
|
|
|
|
|
|
/** helper to get the cell padding style value */
|
1998-12-05 08:27:21 +03:00
|
|
|
virtual nscoord GetCellPadding();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 23:13:19 +04:00
|
|
|
/** return the row span of a cell, taking into account row span magic at the bottom
|
2000-02-01 06:23:29 +03:00
|
|
|
* of a table. The row span equals the number of rows spanned by aCell starting at
|
|
|
|
* aStartRowIndex, and can be smaller if aStartRowIndex is greater than the row
|
|
|
|
* index in which aCell originates.
|
1998-07-17 03:23:31 +04:00
|
|
|
*
|
2000-02-01 06:23:29 +03:00
|
|
|
* @param aStartRowIndex the cell
|
|
|
|
* @param aCell the cell
|
1998-07-17 03:23:31 +04:00
|
|
|
*
|
1998-06-24 23:13:19 +04:00
|
|
|
* @return the row span, correcting for row spans that extend beyond the bottom
|
|
|
|
* of the table.
|
|
|
|
*/
|
2000-02-01 06:23:29 +03:00
|
|
|
virtual PRInt32 GetEffectiveRowSpan(PRInt32 aStartRowIndex,
|
|
|
|
const nsTableCellFrame& aCell) const;
|
|
|
|
virtual PRInt32 GetEffectiveRowSpan(const nsTableCellFrame& aCell) const;
|
1998-06-24 23:13:19 +04:00
|
|
|
|
1998-07-17 03:23:31 +04:00
|
|
|
/** return the col span of a cell, taking into account col span magic at the edge
|
|
|
|
* of a table.
|
|
|
|
*
|
|
|
|
* @param aCell the cell
|
|
|
|
*
|
|
|
|
* @return the col span, correcting for col spans that extend beyond the edge
|
|
|
|
* of the table.
|
|
|
|
*/
|
2000-01-15 23:10:00 +03:00
|
|
|
virtual PRInt32 GetEffectiveColSpan(const nsTableCellFrame& aCell) const;
|
1998-07-17 03:23:31 +04:00
|
|
|
|
1998-07-22 07:53:43 +04:00
|
|
|
/** return the value of the COLS attribute, adjusted for the
|
|
|
|
* actual number of columns in the table
|
|
|
|
*/
|
1998-08-26 21:26:38 +04:00
|
|
|
PRInt32 GetEffectiveCOLSAttribute();
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
/** return the column frame associated with aColIndex */
|
|
|
|
nsTableColFrame* GetColFrame(PRInt32 aColIndex) const;
|
|
|
|
|
|
|
|
void InsertCol(nsIPresContext& aPresContext,
|
|
|
|
nsTableColFrame& aColFrame,
|
|
|
|
PRInt32 aColIndex);
|
|
|
|
|
|
|
|
nsTableColGroupFrame* CreateAnonymousColGroupFrame(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupType aType);
|
|
|
|
|
|
|
|
PRInt32 DestroyAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aNumFrames);
|
|
|
|
|
|
|
|
void CreateAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aNumColsToAdd,
|
|
|
|
nsTableColType aColType,
|
|
|
|
PRBool aDoAppend,
|
|
|
|
nsIFrame* aPrevCol = nsnull);
|
|
|
|
|
|
|
|
void CreateAnonymousColFrames(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupFrame& aColGroupFrame,
|
|
|
|
PRInt32 aNumColsToAdd,
|
|
|
|
nsTableColType aColType,
|
|
|
|
PRBool aAddToColGroupAndTable,
|
|
|
|
nsIFrame* aPrevCol,
|
|
|
|
nsIFrame** aFirstNewFrame);
|
|
|
|
|
|
|
|
/** empty the column frame cache */
|
|
|
|
void ClearColCache();
|
|
|
|
|
|
|
|
virtual PRInt32 AppendCell(nsIPresContext& aPresContext,
|
|
|
|
nsTableCellFrame& aCellFrame,
|
|
|
|
PRInt32 aRowIndex);
|
|
|
|
|
|
|
|
virtual void InsertCells(nsIPresContext& aPresContext,
|
|
|
|
nsVoidArray& aCellFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndexBefore);
|
|
|
|
|
|
|
|
virtual void RemoveCell(nsIPresContext& aPresContext,
|
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
PRInt32 aRowIndex);
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
void AppendRows(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
2000-09-14 10:49:47 +04:00
|
|
|
PRInt32 aRowIndex,
|
2000-01-13 08:29:38 +03:00
|
|
|
nsVoidArray& aRowFrames);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 InsertRow(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
|
|
|
nsIFrame& aFrame,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aConsiderSpans);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
PRInt32 InsertRows(nsIPresContext& aPresContext,
|
|
|
|
nsTableRowGroupFrame& aRowGroupFrame,
|
|
|
|
nsVoidArray& aFrames,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRBool aConsiderSpans);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
virtual void RemoveRows(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aFirstRowFrame,
|
|
|
|
PRInt32 aNumRowsToRemove,
|
|
|
|
PRBool aConsiderSpans);
|
|
|
|
|
|
|
|
void AppendRowGroups(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aFirstRowGroupFrame);
|
|
|
|
|
|
|
|
void InsertRowGroups(nsIPresContext& aPresContext,
|
|
|
|
nsIFrame* aFirstRowGroupFrame,
|
2000-09-14 10:49:47 +04:00
|
|
|
nsIFrame* aLastRowGroupFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
void InsertColGroups(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
nsIFrame* aFirstFrame,
|
|
|
|
nsIFrame* aLastFrame = nsnull);
|
|
|
|
|
|
|
|
virtual void RemoveCol(nsIPresContext& aPresContext,
|
|
|
|
nsTableColGroupFrame* aColGroupFrame,
|
|
|
|
PRInt32 aColIndex,
|
|
|
|
PRBool aRemoveFromCache,
|
|
|
|
PRBool aRemoveFromCellMap);
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
static PRBool IsFinalPass(const nsHTMLReflowState& aReflowState);
|
1999-02-04 02:54:32 +03:00
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
nsTableCellFrame* GetCellInfoAt(PRInt32 aRowX,
|
|
|
|
PRInt32 aColX,
|
|
|
|
PRBool* aOriginates = nsnull,
|
|
|
|
PRInt32* aColSpan = nsnull);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
PRInt32 GetNumCellsOriginatingInCol(PRInt32 aColIndex) const;
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2000-09-09 05:46:44 +04:00
|
|
|
PRBool HasCellSpanningPctCol() const;
|
|
|
|
void SetHasCellSpanningPctCol(PRBool aValue);
|
1999-10-04 09:19:32 +04:00
|
|
|
|
2000-01-03 01:55:48 +03:00
|
|
|
static void DebugReflow(char* aMessage,
|
|
|
|
const nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState* aState,
|
|
|
|
const nsHTMLReflowMetrics* aMetrics,
|
|
|
|
const nsReflowStatus aStatus = NS_FRAME_COMPLETE);
|
1999-08-19 23:52:37 +04:00
|
|
|
|
|
|
|
static void DebugGetIndent(const nsIFrame* aFrame,
|
|
|
|
char* aBuf);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
/** protected constructor.
|
1998-04-15 01:45:28 +04:00
|
|
|
* @see NewFrame
|
|
|
|
*/
|
1998-12-03 09:31:43 +03:00
|
|
|
nsTableFrame();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** destructor, responsible for mColumnLayoutData and mColumnWidths */
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual ~nsTableFrame();
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
/** implement abstract method on nsHTMLContainerFrame */
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
virtual PRBool ParentDisablesSelection() const; //override default behavior
|
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
/** helper method for determining if this is a nested table or not
|
|
|
|
* @param aReflowState The reflow state for this inner table frame
|
|
|
|
* @param aPosition [OUT] The position style struct for the parent table, if nested.
|
|
|
|
* If not nested, undefined.
|
|
|
|
* @return PR_TRUE if this table is nested inside another table.
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
PRBool IsNested(const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsStylePosition*& aPosition) const;
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
// Sets the starting column index for aColGroupFrame and the siblings frames that
|
|
|
|
// follow
|
|
|
|
void SetStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame,
|
|
|
|
PRInt32 aIndex);
|
|
|
|
|
|
|
|
// Calculate the starting column index to use for the specified col group frame
|
|
|
|
PRInt32 CalculateStartingColumnIndexFor(nsTableColGroupFrame* aColGroupFrame);
|
1999-07-28 12:09:02 +04:00
|
|
|
|
1999-06-15 05:19:18 +04:00
|
|
|
public:
|
1998-04-15 01:45:28 +04:00
|
|
|
/** first pass of ResizeReflow.
|
|
|
|
* lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and
|
|
|
|
* a non-null aMaxElementSize so we get all the metrics we need to do column balancing.
|
|
|
|
* Pass 1 only needs to be executed once no matter how many times the table is resized,
|
|
|
|
* as long as content and style don't change. This is managed in the member variable mFirstPassIsValid.
|
|
|
|
* The layout information for each cell is cached in mColumLayoutData.
|
1998-10-15 11:46:16 +04:00
|
|
|
* Incremental layout can take advantage of aStartingFrame to pick up where a previous
|
|
|
|
* ResizeReflowPass1 left off.
|
1998-04-15 01:45:28 +04:00
|
|
|
*
|
1999-01-27 22:29:24 +03:00
|
|
|
* @see nsIFrameReflow::Reflow
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD ResizeReflowPass1(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-15 11:46:16 +04:00
|
|
|
nsReflowStatus& aStatus,
|
1998-10-20 03:43:06 +04:00
|
|
|
nsReflowReason aReason,
|
|
|
|
PRBool aDoSiblings);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-06-23 07:02:21 +04:00
|
|
|
virtual PRBool RowGroupsShouldBeConstrained() { return PR_FALSE; }
|
|
|
|
|
1999-08-19 07:51:25 +04:00
|
|
|
/** do I need to do a reflow? */
|
|
|
|
virtual PRBool NeedsReflow(const nsHTMLReflowState& aReflowState);
|
|
|
|
|
1999-06-15 05:19:18 +04:00
|
|
|
protected:
|
1998-04-15 01:45:28 +04:00
|
|
|
/** second pass of ResizeReflow.
|
|
|
|
* lays out all table content with aMaxSize(computed_table_width, given_table_height)
|
|
|
|
* Pass 2 is executed every time the table needs to resize. An optimization is included
|
|
|
|
* so that if the table doesn't need to actually be resized, no work is done (see NeedsReflow).
|
|
|
|
*
|
1999-01-27 22:29:24 +03:00
|
|
|
* @see nsIFrameReflow::Reflow
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD ResizeReflowPass2(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
// begin incremental reflow methods
|
1999-06-15 05:19:18 +04:00
|
|
|
|
1998-10-11 13:18:27 +04: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.
|
1999-01-27 22:29:24 +03:00
|
|
|
* All incremental reflows go through this method.
|
1998-10-11 13:18:27 +04:00
|
|
|
*
|
|
|
|
* @see Reflow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD IncrementalReflow(nsIPresContext* aPresContext,
|
1998-10-15 11:46:16 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-11 13:18:27 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-15 11:46:16 +04:00
|
|
|
nsReflowStatus& aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process an incremental reflow command targeted at a child of this frame.
|
|
|
|
* @param aNextFrame the next frame in the reflow target chain
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD IR_TargetIsChild(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame * aNextFrame);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process an incremental reflow command targeted at this frame.
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD IR_TargetIsMe(nsIPresContext* aPresContext,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a style chnaged notification.
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
* TODO: needs to be optimized for which attribute was actually changed.
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD IR_StyleChanged(nsIPresContext* aPresContext,
|
1998-10-30 10:57:44 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD AdjustSiblingsAfterReflow(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
1998-10-11 13:18:27 +04:00
|
|
|
nsIFrame* aKidFrame,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsSize* aMaxElementSize,
|
1998-10-11 13:18:27 +04:00
|
|
|
nscoord aDeltaY);
|
1999-08-19 07:51:25 +04:00
|
|
|
|
|
|
|
nsresult RecoverState(InnerTableReflowState& aReflowState,
|
1999-08-31 02:30:32 +04:00
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
nsSize* aMaxElementSize);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1999-12-16 04:51:06 +03:00
|
|
|
NS_METHOD CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aRowGroupFrame,
|
|
|
|
const nscoord& aYTotalOffset,
|
|
|
|
nscoord& aYGroupOffset, PRInt32& aRowX);
|
1999-06-14 12:01:00 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD AdjustForCollapsingRows(nsIPresContext* aPresContext,
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord& aHeight);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD AdjustForCollapsingCols(nsIPresContext* aPresContext,
|
1999-02-11 09:22:33 +03:00
|
|
|
nscoord& aWidth);
|
1999-01-27 22:29:24 +03:00
|
|
|
// end incremental reflow methods
|
1998-07-07 01:39:23 +04:00
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/** return the desired width of this table accounting for the current
|
|
|
|
* reflow state, and for the table attributes and parent
|
|
|
|
*/
|
1998-10-02 08:10:00 +04:00
|
|
|
nscoord ComputeDesiredWidth(const nsHTMLReflowState& aReflowState) const;
|
1998-09-01 01:23:28 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** return the desired height of this table accounting for the current
|
|
|
|
* reflow state, and for the table attributes and parent
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
nscoord ComputeDesiredHeight(nsIPresContext* aPresContext,
|
1998-11-20 04:01:25 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aDefaultHeight);
|
|
|
|
|
1999-06-15 03:42:16 +04:00
|
|
|
/** The following two functions are helpers for ComputeDesiredHeight
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
void DistributeSpaceToCells(nsIPresContext* aPresContext,
|
1999-06-15 03:42:16 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsIFrame* aRowGroupFrame);
|
|
|
|
void DistributeSpaceToRows(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame,
|
|
|
|
nscoord aSumOfRowHeights,
|
|
|
|
nscoord aExcess,
|
|
|
|
nscoord& aExcessForRowGroup,
|
|
|
|
nscoord& aRowGroupYPos);
|
1998-11-20 04:01:25 +03:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
void PlaceChild(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
1999-11-19 18:33:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsSize* aMaxElementSize,
|
|
|
|
nsSize& aKidMaxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/**
|
|
|
|
* Reflow the frames we've already created
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current inline state
|
1998-04-15 01:45:28 +04:00
|
|
|
* @return true if we successfully reflowed all the mapped children and false
|
|
|
|
* otherwise, e.g. we pushed children to the next in flow
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD ReflowMappedChildren(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-04-15 01:45:28 +04:00
|
|
|
/**
|
|
|
|
* Try and pull-up frames from our next-in-flow
|
|
|
|
*
|
|
|
|
* @param aPresContext presentation context to use
|
1998-10-21 00:05:44 +04:00
|
|
|
* @param aReflowState current reflow state
|
1998-04-15 01:45:28 +04:00
|
|
|
* @return true if we successfully pulled-up all the children and false
|
|
|
|
* otherwise, e.g. child didn't fit
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD PullUpChildren(nsIPresContext* aPresContext,
|
1998-10-21 00:05:44 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** assign widths for each column, taking into account the table content, the effective style,
|
|
|
|
* the layout constraints, and the compatibility mode. Sets mColumnWidths as a side effect.
|
|
|
|
* @param aPresContext the presentation context
|
|
|
|
* @param aTableStyle the resolved style for the table
|
|
|
|
* @param aMaxSize the height and width constraints
|
|
|
|
* @param aMaxElementSize the min size of the largest indivisible object
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
virtual void BalanceColumnWidths(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsSize& aMaxSize,
|
|
|
|
nsSize* aMaxElementSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** sets the width of the table according to the computed widths of each column. */
|
2000-02-12 04:55:40 +03:00
|
|
|
virtual void SetTableWidth(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** returns PR_TRUE if the cached pass 1 data is still valid */
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual PRBool IsFirstPassValid() const;
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
/** returns PR_TRUE if the cached column info is still valid */
|
|
|
|
virtual PRBool IsColumnWidthsValid() const;
|
2000-01-11 18:55:31 +03:00
|
|
|
|
|
|
|
/** returns PR_TRUE if the cached pass1 maximum width is still valid */
|
|
|
|
virtual PRBool IsMaximumWidthValid() const;
|
1998-10-16 01:07:37 +04:00
|
|
|
|
1999-03-09 08:29:37 +03:00
|
|
|
nsIFrame* GetFirstBodyRowGroupFrame();
|
1999-10-21 09:11:43 +04:00
|
|
|
PRBool MoveOverflowToChildList(nsIPresContext* aPresContext);
|
|
|
|
void PushChildren(nsIPresContext *aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling);
|
1999-03-09 08:29:37 +03:00
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
public:
|
2000-09-14 10:49:47 +04:00
|
|
|
// put the children frames in the display order (e.g. thead before tbody before tfoot)
|
|
|
|
// and put the non row group frames at the end. Also return the number of row group frames.
|
|
|
|
void OrderRowGroups(nsVoidArray& aChildren,
|
|
|
|
PRUint32& aNumRowGroups,
|
|
|
|
nsIFrame** aFirstBody = nsnull);
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
// Returns PR_TRUE if there are any cells above the row at
|
|
|
|
// aRowIndex and spanning into the row at aRowIndex
|
1999-08-20 00:36:52 +04:00
|
|
|
PRBool RowIsSpannedInto(PRInt32 aRowIndex);
|
1999-08-19 23:52:37 +04:00
|
|
|
|
|
|
|
// Returns PR_TRUE if there is a cell originating in aRowIndex
|
|
|
|
// which spans into the next row
|
|
|
|
PRBool RowHasSpanningCells(PRInt32 aRowIndex);
|
|
|
|
|
|
|
|
// Returns PR_TRUE if there are any cells to the left of the column at
|
|
|
|
// aColIndex and spanning into the column at aColIndex
|
|
|
|
PRBool ColIsSpannedInto(PRInt32 aColIndex);
|
|
|
|
|
|
|
|
// Returns PR_TRUE if there is a cell originating in aColIndex
|
|
|
|
// which spans into the next col
|
|
|
|
PRBool ColHasSpanningCells(PRInt32 aColIndex);
|
|
|
|
|
|
|
|
// Returns PR_TRUE if the style width change, aPrevStyleWidth, for aCellFrame
|
|
|
|
// could require the columns to be rebalanced. This method can be used to
|
|
|
|
// determine if an incremental reflow on aCellFrame is necessary as the result
|
|
|
|
// of the style width change. If aConsiderMinWidth is PR_TRUE, then potential
|
|
|
|
// changes to aCellFrame's min width is considered (however, if considered,
|
|
|
|
// the function will always return PR_TRUE if the layout strategy is Basic).
|
|
|
|
PRBool ColumnsCanBeInvalidatedBy(nsStyleCoord* aPrevStyleWidth,
|
1999-08-21 03:27:54 +04:00
|
|
|
const nsTableCellFrame& aCellFrame) const;
|
1999-08-19 23:52:37 +04:00
|
|
|
|
|
|
|
// Returns PR_TRUE if potential width changes to aCellFrame could require the
|
|
|
|
// columns to be rebalanced. This method can be used after an incremental reflow
|
|
|
|
// of aCellFrame to determine if a pass1 reflow on aCellFrame is necessary. If
|
|
|
|
// aConsiderMinWidth is PR_TRUE, then potential changes to aCellFrame's min width
|
|
|
|
// is considered (however, if considered, the function will always return PR_TRUE
|
|
|
|
// if the layout strategy is Basic).
|
|
|
|
PRBool ColumnsCanBeInvalidatedBy(const nsTableCellFrame& aCellFrame,
|
|
|
|
PRBool aConsiderMinWidth = PR_FALSE) const;
|
|
|
|
|
|
|
|
// Returns PR_TRUE if changes to aCellFrame's pass1 min and desired (max) sizes
|
1999-08-21 03:27:54 +04:00
|
|
|
// don't require the columns to be rebalanced. This method can be used after a
|
1999-08-19 23:52:37 +04:00
|
|
|
// pass1 reflow of aCellFrame to determine if the columns need rebalancing.
|
|
|
|
// aPrevCellMin and aPrevCellDes are the values aCellFrame had before the last
|
|
|
|
// pass1 reflow.
|
|
|
|
PRBool ColumnsAreValidFor(const nsTableCellFrame& aCellFrame,
|
|
|
|
nscoord aPrevCellMin,
|
|
|
|
nscoord aPrevCellDes) const;
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
virtual void InvalidateFirstPassCache();
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
virtual void InvalidateColumnWidths();
|
|
|
|
|
2000-01-11 18:55:31 +03:00
|
|
|
virtual void InvalidateMaximumWidth();
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
protected:
|
1998-05-02 00:44:55 +04:00
|
|
|
|
1998-05-27 00:57:24 +04:00
|
|
|
/** Support methods for DidSetStyleContext */
|
1999-11-24 09:03:41 +03:00
|
|
|
void MapBorderMarginPadding(nsIPresContext* aPresContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
void MapHTMLBorderStyle(nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
|
|
|
|
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
public:
|
1999-07-28 12:09:02 +04:00
|
|
|
/** Get the cell map for this table frame. It is not always mCellMap.
|
|
|
|
* Only the firstInFlow has a legit cell map
|
|
|
|
*/
|
2000-01-13 08:29:38 +03:00
|
|
|
virtual nsTableCellMap* GetCellMap() const;
|
1998-10-14 20:32:45 +04:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
void AdjustRowIndices(nsIPresContext* aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aAdjustment);
|
1999-08-30 04:01:09 +04:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
NS_IMETHOD AdjustRowIndices(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aRowGroup,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 anAdjustment);
|
1999-08-30 04:01:09 +04:00
|
|
|
|
1999-09-02 04:07:14 +04:00
|
|
|
// Return PR_TRUE if rules=groups is set for the table content
|
|
|
|
PRBool HasGroupRules() const;
|
|
|
|
|
|
|
|
// Remove cell borders which aren't bordering row and/or col groups
|
1999-11-24 09:03:41 +03:00
|
|
|
void ProcessGroupRules(nsIPresContext* aPresContext);
|
1999-09-02 04:07:14 +04:00
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
nsVoidArray& GetColCache();
|
|
|
|
|
2000-01-13 08:29:38 +03:00
|
|
|
/**
|
|
|
|
* Return aFrame's child if aFrame is an nsScrollFrame, otherwise return aFrame
|
|
|
|
*/
|
|
|
|
nsTableRowGroupFrame* GetRowGroupFrame(nsIFrame* aFrame,
|
|
|
|
nsIAtom* aFrameTypeIn = nsnull);
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
protected:
|
1998-06-17 20:38:24 +04:00
|
|
|
|
2000-02-12 04:55:40 +03:00
|
|
|
void SetColumnDimensions(nsIPresContext* aPresContext,
|
|
|
|
nscoord aHeight,
|
|
|
|
const nsMargin& aReflowState);
|
1999-06-08 01:10:25 +04:00
|
|
|
|
1998-11-06 00:42:46 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-11 04:00:31 +04:00
|
|
|
/** for debugging only
|
|
|
|
* prints out info about the table layout state, printing columns and their cells
|
|
|
|
*/
|
1998-07-24 20:51:16 +04:00
|
|
|
void ListColumnLayoutData(FILE* out, PRInt32 aIndent);
|
1998-11-06 00:42:46 +03:00
|
|
|
#endif
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/** return the number of columns as specified by the input.
|
|
|
|
* has 2 side effects:<br>
|
|
|
|
* calls SetStartColumnIndex on each nsTableColumn<br>
|
|
|
|
* sets mSpecifiedColCount.<br>
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetSpecifiedColumnCount ();
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
PRInt32 CollectRows(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsVoidArray& aCollection);
|
1999-01-18 02:35:56 +03:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
public: /* ----- Cell Map public methods ----- */
|
|
|
|
|
2000-09-14 10:49:47 +04:00
|
|
|
PRInt32 GetStartRowIndex(nsTableRowGroupFrame& aRowGroupFrame);
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/** returns the number of rows in this table.
|
|
|
|
* if mCellMap has been created, it is asked for the number of rows.<br>
|
|
|
|
* otherwise, the content is enumerated and the rows are counted.
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
virtual PRInt32 GetRowCount() const;
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
/** returns the number of columns in this table after redundant columns have been removed
|
1998-07-24 20:51:16 +04:00
|
|
|
*/
|
1999-07-28 12:09:02 +04:00
|
|
|
virtual PRInt32 GetColCount();
|
1998-07-24 20:51:16 +04:00
|
|
|
|
1998-09-19 02:37:14 +04:00
|
|
|
/** return the column frame at colIndex.
|
|
|
|
* returns nsnull if the col frame has not yet been allocated, or if aColIndex is out of range
|
|
|
|
*/
|
1998-07-11 04:00:31 +04:00
|
|
|
nsTableColFrame * GetColFrame(PRInt32 aColIndex);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-19 02:37:14 +04:00
|
|
|
/** return the cell frame at aRowIndex, aColIndex.
|
|
|
|
* returns nsnull if the cell frame has not yet been allocated,
|
|
|
|
* or if aRowIndex or aColIndex is out of range
|
|
|
|
*/
|
|
|
|
nsTableCellFrame * GetCellFrameAt(PRInt32 aRowIndex, PRInt32 aColIndex);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
/** return the minimum width of the table caption. Return 0 if there is no caption. */
|
|
|
|
nscoord GetMinCaptionWidth();
|
|
|
|
|
2000-05-10 04:54:00 +04:00
|
|
|
/** return the minimum content width of the table (excludes borders and padding).
|
1999-07-28 12:09:02 +04:00
|
|
|
Return 0 if the min width is unknown. */
|
2000-05-10 04:54:00 +04:00
|
|
|
nscoord GetMinTableWidth();
|
1998-10-08 19:34:48 +04:00
|
|
|
|
1999-07-28 12:09:02 +04:00
|
|
|
/** return the maximum content width of the table (excludes borders and padding).
|
|
|
|
Return 0 if the max width is unknown. */
|
2000-09-11 04:02:04 +04:00
|
|
|
nscoord GetMaxTableWidth(const nsHTMLReflowState& aReflowState);
|
1998-10-08 19:34:48 +04:00
|
|
|
|
1998-10-09 23:59:45 +04:00
|
|
|
/** compute the max-element-size for the table
|
|
|
|
* @param aMaxElementSize [OUT] width field set to the min legal width of the table
|
|
|
|
*/
|
2000-02-12 04:55:40 +03:00
|
|
|
void SetMaxElementSize(nsSize* aMaxElementSize,
|
|
|
|
const nsMargin& aPadding);
|
1998-10-09 23:59:45 +04:00
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
2000-11-15 17:59:47 +03:00
|
|
|
virtual PRBool IsAutoLayout();
|
1998-10-21 00:05:44 +04:00
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
// compute the height of the table to be used as the basis for
|
|
|
|
// percentage height cells
|
2000-04-29 01:05:31 +04:00
|
|
|
void ComputePercentBasisForRows(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState);
|
1999-08-26 01:49:18 +04:00
|
|
|
|
|
|
|
nscoord GetPercentBasisForRows();
|
1999-08-07 09:40:09 +04:00
|
|
|
|
2000-07-06 17:37:28 +04:00
|
|
|
nscoord GetPreferredWidth() const;
|
|
|
|
void SetPreferredWidth(nscoord aWidth);
|
|
|
|
|
1999-08-01 02:11:50 +04:00
|
|
|
/*---------------- nsITableLayout methods ------------------------*/
|
1999-08-01 20:20:14 +04:00
|
|
|
|
|
|
|
/** Get the cell and associated data for a table cell from the frame's cellmap */
|
1999-08-01 02:11:50 +04:00
|
|
|
NS_IMETHOD GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
2000-01-26 17:56:06 +03:00
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
1999-08-01 02:11:50 +04:00
|
|
|
PRBool& aIsSelected);
|
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
/** Get the number of rows and column for a table from the frame's cellmap
|
|
|
|
* Some rows may not have enough cells (the number returned is the maximum possible),
|
|
|
|
* which displays as a ragged-right edge table
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetTableSize(PRInt32& aRowCount, PRInt32& aColCount);
|
|
|
|
|
|
|
|
/*------------end of nsITableLayout methods -----------------------*/
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
public:
|
|
|
|
static nsIAtom* gColGroupAtom;
|
2000-01-22 04:16:50 +03:00
|
|
|
void Dump(nsIPresContext* aPresContext,
|
|
|
|
PRBool aDumpRows,
|
|
|
|
PRBool aDumpCols,
|
|
|
|
PRBool aDumpCellMap);
|
1999-12-14 01:56:31 +03:00
|
|
|
|
|
|
|
nsVoidArray mColFrames; // XXX temporarily public
|
1998-12-03 21:01:35 +03:00
|
|
|
|
1999-02-04 01:35:03 +03:00
|
|
|
protected:
|
2000-01-22 04:16:50 +03:00
|
|
|
void DumpRowGroup(nsIPresContext* aPresContext, nsIFrame* aChildFrame);
|
1998-05-20 03:11:28 +04:00
|
|
|
void DebugPrintCount() const; // Debugging routine
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-10-10 01:53:07 +04:00
|
|
|
// data members
|
1998-04-14 00:24:54 +04:00
|
|
|
PRInt32 *mColumnWidths; // widths of each column
|
1998-10-10 01:53:07 +04:00
|
|
|
PRInt32 mColumnWidthsLength; // the number of column lengths this frame has allocated
|
1999-10-05 03:48:05 +04:00
|
|
|
|
|
|
|
struct TableBits {
|
|
|
|
unsigned mColumnWidthsSet:1; // PR_TRUE if column widths have been set at least once
|
|
|
|
unsigned mColumnWidthsValid:1; // PR_TRUE if column width data is still legit, PR_FALSE if it needs to be recalculated
|
|
|
|
unsigned mFirstPassValid:1; // PR_TRUE if first pass data is still legit, PR_FALSE if it needs to be recalculated
|
|
|
|
unsigned mIsInvariantWidth:1; // PR_TRUE if table width cannot change
|
2000-09-09 05:46:44 +04:00
|
|
|
unsigned mCellSpansPctCol:1;
|
2000-01-11 18:55:31 +03:00
|
|
|
unsigned mMaximumWidthValid:1;
|
1999-12-14 01:56:31 +03:00
|
|
|
int : 26; // unused
|
1999-10-05 03:48:05 +04:00
|
|
|
} mBits;
|
|
|
|
|
2000-07-06 17:37:28 +04:00
|
|
|
nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
|
|
|
|
nsITableLayoutStrategy* mTableLayoutStrategy;// the layout strategy for this frame
|
|
|
|
nsFrameList mColGroups; // the list of colgroup frames
|
1998-12-17 01:19:23 +03:00
|
|
|
|
2000-07-06 17:37:28 +04:00
|
|
|
nsTableBorderCollapser* mBorderCollapser; // one list of border segments for each side of the table frame
|
|
|
|
// used only for the collapsing border model
|
|
|
|
nscoord mPercentBasisForRows;
|
|
|
|
nscoord mPreferredWidth;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
1998-09-30 03:15:01 +04:00
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
inline PRBool nsTableFrame::IsRowGroup(PRInt32 aDisplayType) const
|
1998-10-11 13:18:27 +04:00
|
|
|
{
|
|
|
|
return PRBool((NS_STYLE_DISPLAY_TABLE_HEADER_GROUP == aDisplayType) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == aDisplayType) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == aDisplayType));
|
|
|
|
}
|
1998-10-15 02:12:06 +04:00
|
|
|
|
1999-08-26 01:49:18 +04:00
|
|
|
inline nscoord nsTableFrame::GetPercentBasisForRows()
|
|
|
|
{
|
|
|
|
return mPercentBasisForRows;
|
|
|
|
}
|
|
|
|
|
2000-09-09 05:46:44 +04:00
|
|
|
inline PRBool nsTableFrame::HasCellSpanningPctCol() const
|
1999-10-04 09:19:32 +04:00
|
|
|
{
|
2000-09-09 05:46:44 +04:00
|
|
|
return (PRBool)mBits.mCellSpansPctCol;
|
1999-10-04 09:19:32 +04:00
|
|
|
}
|
|
|
|
|
2000-09-09 05:46:44 +04:00
|
|
|
inline void nsTableFrame::SetHasCellSpanningPctCol(PRBool aValue)
|
1999-10-04 09:19:32 +04:00
|
|
|
{
|
2000-09-09 05:46:44 +04:00
|
|
|
mBits.mCellSpansPctCol = (unsigned)aValue;
|
1999-10-04 09:19:32 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
inline nsFrameList& nsTableFrame::GetColGroups()
|
|
|
|
{
|
|
|
|
return mColGroups;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsVoidArray& nsTableFrame::GetColCache()
|
|
|
|
{
|
|
|
|
return mColFrames;
|
|
|
|
}
|
|
|
|
|
2000-07-06 17:37:28 +04:00
|
|
|
inline nscoord nsTableFrame::GetPreferredWidth() const
|
|
|
|
{
|
|
|
|
return mPreferredWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void nsTableFrame::SetPreferredWidth(nscoord aWidth)
|
|
|
|
{
|
|
|
|
mPreferredWidth = aWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-04 23:15:56 +04:00
|
|
|
enum nsTableIteration {
|
|
|
|
eTableLTR = 0,
|
|
|
|
eTableRTL = 1,
|
|
|
|
eTableDIR = 2
|
|
|
|
};
|
|
|
|
|
1999-04-22 07:51:58 +04:00
|
|
|
class nsTableIterator
|
|
|
|
{
|
|
|
|
public:
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableIterator(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame& aSource,
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIteration aType);
|
|
|
|
nsTableIterator(nsFrameList& aSource,
|
|
|
|
nsTableIteration aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
nsIFrame* First();
|
|
|
|
nsIFrame* Next();
|
|
|
|
PRBool IsLeftToRight();
|
|
|
|
PRInt32 Count();
|
|
|
|
|
|
|
|
protected:
|
1999-05-04 23:15:56 +04:00
|
|
|
void Init(nsIFrame* aFirstChild,
|
|
|
|
nsTableIteration aType);
|
1999-04-22 07:51:58 +04:00
|
|
|
PRBool mLeftToRight;
|
|
|
|
nsIFrame* mFirstListChild;
|
|
|
|
nsIFrame* mFirstChild;
|
|
|
|
nsIFrame* mCurrentChild;
|
|
|
|
PRInt32 mCount;
|
|
|
|
};
|
|
|
|
|
1998-10-15 02:12:06 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
|
|
|
|
|