1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
#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"
|
1998-10-15 11:46:16 +04:00
|
|
|
#include "nsIFrameReflow.h" // for nsReflowReason enum
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
class nsCellMap;
|
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;
|
1998-04-30 21:57:09 +04:00
|
|
|
class nsITableLayoutStrategy;
|
1998-05-27 00:57:24 +04:00
|
|
|
class nsHTMLValue;
|
1998-06-05 06:36:25 +04:00
|
|
|
class ColumnInfoCache;
|
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
|
|
|
|
|
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
|
|
|
*/
|
1998-10-20 21:45:07 +04:00
|
|
|
class nsTableFrame : public nsHTMLContainerFrame
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
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-05-12 02:03:29 +04:00
|
|
|
NS_NewTableFrame(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
|
|
|
|
*/
|
1998-12-05 08:27:21 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @see nsIFrame::DeleteFrame */
|
1998-12-04 06:14:28 +03:00
|
|
|
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
|
|
|
|
|
1999-03-01 09:40:24 +03: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.
|
|
|
|
*/
|
1998-12-02 19:45:20 +03:00
|
|
|
PRBool IsNested(const nsHTMLReflowState& aReflowState, const nsStylePosition *& aPosition) const;
|
1998-09-01 01:23:28 +04:00
|
|
|
|
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
|
1998-10-14 20:32:45 +04:00
|
|
|
static NS_METHOD GetTableFrame(nsIFrame *aSourceFrame, nsTableFrame *& aTableFrame);
|
1998-09-24 20:37:22 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/** helper method for getting the width of the table's containing block */
|
1998-10-21 00:05:44 +04:00
|
|
|
static nscoord GetTableContainerWidth(const nsHTMLReflowState& aReflowState);
|
1998-06-05 06:36:25 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** helper method for determining the width specification for a table frame
|
|
|
|
* within a specific reflow context.
|
|
|
|
*
|
|
|
|
* @param aTableFrame the table frame we're inspecting
|
|
|
|
* @param aTableStyle the style context for aTableFrame
|
|
|
|
* @param aReflowState the context within which we're to determine the table width info
|
|
|
|
* @param aSpecifiedTableWidth [OUT] if the table is not auto-width,
|
|
|
|
* aSpecifiedTableWidth iw set to the resolved width.
|
|
|
|
* @return PR_TRUE if the table is auto-width. value of aSpecifiedTableWidth is undefined.
|
|
|
|
* PR_FALSE if the table is not auto-width,
|
|
|
|
* and aSpecifiedTableWidth is set to the resolved width in twips.
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
static PRBool TableIsAutoWidth(nsTableFrame * aTableFrame,
|
|
|
|
nsIStyleContext * aTableStyle,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-21 00:05:44 +04:00
|
|
|
nscoord& aSpecifiedTableWidth);
|
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.
|
|
|
|
* Calls DidAppendRowGroup which calls nsTableRowFrame::InitChildren
|
|
|
|
* which finally calls back into this table frame to build the cell map.
|
|
|
|
* Also ensures we have the right number of column frames for the child list.
|
|
|
|
*
|
|
|
|
* @see nsIFrame::SetInitialChildList
|
|
|
|
*/
|
1998-11-10 09:05:32 +03:00
|
|
|
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_IMETHOD FirstChild(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-10-14 20:32:45 +04:00
|
|
|
/** complete the append of aRowGroupFrame to the table
|
1999-01-27 22:29:24 +03:00
|
|
|
* this builds the cell map by calling nsTableRowFrame::InitChildren
|
|
|
|
* which calls back into this table frame to build the cell map.
|
|
|
|
* @param aRowGroupFrame the row group that was appended.
|
|
|
|
* note that this method is optimized for content appended, and doesn't
|
|
|
|
* work for random insertion of row groups. Random insertion must go
|
|
|
|
* through incremental reflow notifications.
|
1998-10-14 20:32:45 +04:00
|
|
|
*/
|
|
|
|
NS_IMETHOD DidAppendRowGroup(nsTableRowGroupFrame *aRowGroupFrame);
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** @see nsIFrame::Paint */
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
/** nsIFrame method overridden to handle table specifics
|
|
|
|
*/
|
|
|
|
NS_IMETHOD SetSelected(nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
|
|
|
|
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
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
1999-05-20 04:52:00 +04:00
|
|
|
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/** allow the cell and row attributes to effect the column frame
|
|
|
|
* currently, the only reason this exists is to support the HTML "rule"
|
|
|
|
* that a width attribute on a cell in the first column sets the column width.
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
virtual NS_METHOD SetColumnStyleFromCell(nsIPresContext & aPresContext,
|
1998-06-17 20:38:24 +04:00
|
|
|
nsTableCellFrame* aCellFrame,
|
|
|
|
nsTableRowFrame * aRowFrame);
|
|
|
|
|
1998-07-26 08:23:01 +04:00
|
|
|
/** the COLS attribute can be modified by any cell's width attribute.
|
|
|
|
* deal with it here. Must be called before any call to
|
|
|
|
* ColumnInfoCache::AddColumnInfo
|
|
|
|
*/
|
|
|
|
virtual void AdjustColumnsForCOLSAttribute();
|
|
|
|
|
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);
|
|
|
|
|
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-01-27 22:29:24 +03:00
|
|
|
/** @see nsIFrame::GetFrameName */
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1998-04-14 00:24:54 +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);
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/** get the border values for the row and column */
|
|
|
|
void GetTableBorderAt(nsMargin &aBorder, PRInt32 aRowIndex, PRInt32 aColIndex);
|
|
|
|
|
|
|
|
/** 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-12-09 09:37:18 +03:00
|
|
|
/** Calculate Layout Information */
|
1998-06-17 20:38:24 +04:00
|
|
|
void AppendLayoutData(nsVoidArray* aList, nsTableCellFrame* aTableCell);
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
// begin methods for collapsing borders
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
/** notification that top and bottom borders have been computed */
|
|
|
|
void DidComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
PRInt32 aEndRowIndex);
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
/** compute the left and right collapsed borders between aStartRowIndex and aEndRowIndex, inclusive */
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
PRInt32 aEndRowIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
|
|
|
|
/** compute the top and bottom collapsed borders between aStartRowIndex and aEndRowIndex, inclusive */
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aStartRowIndex,
|
|
|
|
PRInt32 aEndRowIndex);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** compute the left borders for the table objects intersecting at (aRowIndex, aColIndex) */
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeLeftBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex);
|
1999-01-27 22:29:24 +03:00
|
|
|
|
|
|
|
/** compute the right border for the table cell at (aRowIndex, aColIndex)
|
|
|
|
* and the appropriate border for that cell's right neighbor
|
|
|
|
* (the left border for a neighboring cell, or the right table edge)
|
|
|
|
*/
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeRightBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex);
|
1999-01-27 22:29:24 +03:00
|
|
|
|
|
|
|
/** compute the top borders for the table objects intersecting at (aRowIndex, aColIndex) */
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeTopBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex);
|
1999-01-27 22:29:24 +03:00
|
|
|
|
|
|
|
/** compute the bottom border for the table cell at (aRowIndex, aColIndex)
|
|
|
|
* and the appropriate border for that cell's bottom neighbor
|
|
|
|
* (the top border for a neighboring cell, or the bottom table edge)
|
|
|
|
*/
|
1998-12-21 21:54:23 +03:00
|
|
|
void ComputeBottomBorderForEdgeAt(nsIPresContext& aPresContext,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex);
|
1998-12-21 09:38:18 +03:00
|
|
|
|
|
|
|
/** at the time we initially compute collapsing borders, we don't yet have the
|
|
|
|
* column widths. So we set them as a post-process of the column balancing algorithm.
|
|
|
|
*/
|
|
|
|
void SetCollapsingBorderHorizontalEdgeLengths();
|
1998-12-16 20:05:14 +03:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @return the identifier representing the edge opposite from aEdge (left-right, top-bottom) */
|
1998-12-18 01:59:40 +03:00
|
|
|
PRUint8 GetOpposingEdge(PRUint8 aEdge);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** @return the computed width for aSide of aBorder */
|
1998-12-17 10:04:42 +03:00
|
|
|
nscoord GetWidthForSide(const nsMargin &aBorder, PRUint8 aSide);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** returns BORDER_PRECEDENT_LOWER if aStyle1 is lower precedent that aStyle2
|
|
|
|
* BORDER_PRECEDENT_HIGHER if aStyle1 is higher precedent that aStyle2
|
|
|
|
* BORDER_PRECEDENT_EQUAL if aStyle1 and aStyle2 have the same precedence
|
|
|
|
* (note, this is not necessarily the same as saying aStyle1==aStyle2)
|
|
|
|
* according to the CSS-2 collapsing borders for tables precedent rules.
|
|
|
|
*/
|
1998-12-17 10:04:42 +03:00
|
|
|
PRUint8 CompareBorderStyles(PRUint8 aStyle1, PRUint8 aStyle2);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** helper to set the length of an edge for aSide border of this table frame */
|
1998-12-21 09:38:18 +03:00
|
|
|
void SetBorderEdgeLength(PRUint8 aSide, PRInt32 aIndex, nscoord aLength);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** Compute the style, width, and color of an edge in a collapsed-border table.
|
|
|
|
* This method is the CSS2 border conflict resolution algorithm
|
|
|
|
* The spec says to resolve conflicts in this order:<br>
|
|
|
|
* 1. any border with the style HIDDEN wins<br>
|
|
|
|
* 2. the widest border with a style that is not NONE wins<br>
|
|
|
|
* 3. the border styles are ranked in this order, highest to lowest precedence:<br>
|
|
|
|
* double, solid, dashed, dotted, ridge, outset, groove, inset<br>
|
|
|
|
* 4. borders that are of equal width and style (differ only in color) have this precedence:<br>
|
|
|
|
* cell, row, rowgroup, col, colgroup, table<br>
|
|
|
|
* 5. if all border styles are NONE, then that's the computed border style.<br>
|
|
|
|
* This method assumes that the styles were added to aStyles in the reverse precedence order
|
|
|
|
* of their frame type, so that styles that come later in the list win over style
|
|
|
|
* earlier in the list if the tie-breaker gets down to #4.
|
|
|
|
* This method sets the out-param aBorder with the resolved border attributes
|
|
|
|
*
|
|
|
|
* @param aSide the side that is being compared
|
|
|
|
* @param aStyles the resolved styles of the table objects intersecting at aSide
|
|
|
|
* styles must be added to this list in reverse precedence order
|
|
|
|
* @param aBorder [OUT] the border edge that we're computing. Results of the computation
|
|
|
|
* are stored in aBorder: style, color, and width.
|
|
|
|
* @param aFlipLastSide an indication of what the bordering object is: another cell, or the table itself.
|
|
|
|
*/
|
1998-12-17 10:04:42 +03:00
|
|
|
void ComputeCollapsedBorderSegment(PRUint8 aSide,
|
|
|
|
nsVoidArray * aStyles,
|
1998-12-18 01:59:40 +03:00
|
|
|
nsBorderEdge& aBorder,
|
|
|
|
PRBool aFlipLastSide);
|
1998-12-17 10:04:42 +03:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
// end methods for collapsing borders
|
1998-12-17 10:04:42 +03:00
|
|
|
|
1998-12-21 21:54:23 +03:00
|
|
|
void RecalcLayoutData(nsIPresContext& aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-22 03:43:18 +04:00
|
|
|
// Get cell margin information
|
1998-06-17 20:38:24 +04:00
|
|
|
NS_IMETHOD GetCellMarginData(nsTableCellFrame* aKidFrame, nsMargin& aMargin);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-05 06:36:25 +04:00
|
|
|
/** get cached column information for a subset of the columns
|
|
|
|
*
|
|
|
|
* @param aType -- information is returned for the subset of columns with aType style
|
|
|
|
* @param aOutNumColumns -- out param, the number of columns matching aType
|
|
|
|
* @param aOutColumnIndexes -- out param, the indexes of the columns matching aType
|
|
|
|
*
|
|
|
|
* TODO : make aOutColumnIndexes safe
|
|
|
|
*/
|
|
|
|
void GetColumnsByType(const nsStyleUnit aType,
|
|
|
|
PRInt32& aOutNumColumns,
|
|
|
|
PRInt32 *& aOutColumnIndexes);
|
|
|
|
|
1998-06-24 23:13:19 +04:00
|
|
|
/** return the row span of a cell, taking into account row span magic at the bottom
|
|
|
|
* of a table.
|
1998-07-17 03:23:31 +04:00
|
|
|
*
|
|
|
|
* @param aRowIndex the row from which to measure effective row span
|
|
|
|
* @param aCell the cell
|
|
|
|
*
|
1998-06-24 23:13:19 +04:00
|
|
|
* @return the row span, correcting for row spans that extend beyond the bottom
|
|
|
|
* of the table.
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetEffectiveRowSpan(PRInt32 aRowIndex, nsTableCellFrame *aCell);
|
|
|
|
|
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 aColIndex the column from which to measure effective col span
|
|
|
|
* @param aCell the cell
|
|
|
|
*
|
|
|
|
* @return the col span, correcting for col spans that extend beyond the edge
|
|
|
|
* of the table.
|
|
|
|
*/
|
|
|
|
virtual PRInt32 GetEffectiveColSpan(PRInt32 aColIndex, nsTableCellFrame *aCell);
|
|
|
|
|
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();
|
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/** return the index of the next row that is not yet assigned.
|
|
|
|
* If no row is initialized, 0 is returned.
|
|
|
|
*/
|
|
|
|
PRInt32 GetNextAvailRowIndex() const;
|
|
|
|
|
|
|
|
/** return the index of the next column in aRowIndex after aColIndex
|
|
|
|
* that does not have a cell assigned to it.
|
|
|
|
* If aColIndex is past the end of the row, it is returned.
|
|
|
|
* If the row is not initialized, 0 is returned.
|
|
|
|
*/
|
|
|
|
PRInt32 GetNextAvailColIndex(PRInt32 aRowIndex, PRInt32 aColIndex) const;
|
|
|
|
|
|
|
|
/** build as much of the CellMap as possible from the info we have so far
|
|
|
|
*/
|
|
|
|
virtual void AddCellToTable (nsTableRowFrame *aRowFrame,
|
|
|
|
nsTableCellFrame *aCellFrame,
|
|
|
|
PRBool aAddRow);
|
|
|
|
|
|
|
|
virtual void AddColumnFrame (nsTableColFrame *aColFrame);
|
|
|
|
|
1999-02-04 02:54:32 +03:00
|
|
|
static PRBool IsFinalPass(const nsReflowState& aReflowState);
|
|
|
|
|
1999-06-15 05:19:18 +04:00
|
|
|
NS_METHOD GetBorderPlusMarginPadding(nsMargin& aResult);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
|
1998-04-15 01:45:28 +04:00
|
|
|
/** protected constructor.
|
|
|
|
* @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-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
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD ResizeReflowPass1(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-15 11:46:16 +04:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsTableRowGroupFrame * aStartingFrame,
|
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
|
|
|
NS_IMETHOD GetTableSpecifiedHeight(nscoord& aHeight, const nsHTMLReflowState& aReflowState);
|
|
|
|
virtual PRBool RowGroupsShouldBeConstrained() { return PR_FALSE; }
|
|
|
|
|
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
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD ResizeReflowPass2(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1998-10-15 11:46:16 +04:00
|
|
|
NS_IMETHOD IncrementalReflow(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_TargetIsChild(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_TargetIsMe(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a colgroup inserted notification
|
|
|
|
* @param aInsertedFrame the new colgroup frame
|
|
|
|
* @param aReplace PR_TRUE if aInsertedFrame is replacing an existing frame
|
|
|
|
* Not Yet Implemented.
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_ColGroupInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aInsertedFrame,
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool aReplace);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a colgroup appended notification. This method is optimized for append.
|
|
|
|
* @param aAppendedFrame the new colgroup frame
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_IMETHOD IR_ColGroupAppended(nsIPresContext& aPresContext,
|
1998-10-14 20:32:45 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aAppendedFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a colgroup removed notification.
|
|
|
|
* @param aDeletedFrame the colgroup frame to remove
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_ColGroupRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableColGroupFrame * aDeletedFrame);
|
1998-10-11 13:18:27 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a rowgroup inserted notification
|
|
|
|
* @param aInsertedFrame the new rowgroup frame
|
|
|
|
* @param aReplace PR_TRUE if aInsertedFrame is replacing an existing frame
|
|
|
|
* Not Yet Implemented.
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_RowGroupInserted(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aInsertedFrame,
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool aReplace);
|
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a rowgroup appended notification. This method is optimized for append.
|
|
|
|
* @param aAppendedFrame the new rowgroup frame
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-14 20:32:45 +04:00
|
|
|
NS_IMETHOD IR_RowGroupAppended(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aAppendedFrame);
|
1998-10-14 20:32:45 +04:00
|
|
|
|
1999-01-27 22:29:24 +03:00
|
|
|
/** process a rowgroup removed notification.
|
|
|
|
* @param aDeletedFrame the rowgroup frame to remove
|
|
|
|
* @see nsIFrameReflow::Reflow
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
NS_IMETHOD IR_RowGroupRemoved(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
1998-10-15 02:51:50 +04:00
|
|
|
nsTableRowGroupFrame * aDeletedFrame);
|
1998-10-30 10:57:44 +03:00
|
|
|
|
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.
|
|
|
|
*/
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_IMETHOD IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-10-11 13:18:27 +04: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,
|
|
|
|
nscoord aDeltaY);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1999-06-14 12:01:00 +04:00
|
|
|
NS_METHOD AdjustForCollapsingRowGroup(nsIFrame* aRowGroupFrame,
|
|
|
|
PRInt32& aRowX);
|
|
|
|
|
|
|
|
NS_METHOD CollapseRowGroup(nsIFrame* aRowGroupFrame,
|
|
|
|
const nscoord& aYTotalOffset,
|
|
|
|
nscoord& aYGroupOffset, PRInt32& aRowX);
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
NS_METHOD AdjustForCollapsingRows(nsIPresContext& aPresContext,
|
|
|
|
nscoord& aHeight);
|
|
|
|
|
|
|
|
NS_METHOD AdjustForCollapsingCols(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord ComputeDesiredHeight(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aDefaultHeight);
|
|
|
|
|
1999-06-15 03:42:16 +04:00
|
|
|
/** The following two functions are helpers for ComputeDesiredHeight
|
|
|
|
*/
|
|
|
|
void DistributeSpaceToCells(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame);
|
|
|
|
void DistributeSpaceToRows(nsIPresContext& aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aRowGroupFrame, const nscoord& aSumOfRowHeights,
|
|
|
|
const nscoord& aExcess, const nsStyleTable* aTableStyle,
|
|
|
|
nscoord& aExcessForRowGroup,
|
|
|
|
nscoord& aRowGroupYPos);
|
|
|
|
|
1998-11-20 04:01:25 +03:00
|
|
|
nscoord GetEffectiveContainerHeight(const nsHTMLReflowState& aReflowState);
|
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
void PlaceChild(nsIPresContext& aPresContext,
|
|
|
|
InnerTableReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
|
|
|
const nsRect& aKidRect,
|
|
|
|
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
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_IMETHOD ReflowMappedChildren(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
|
*/
|
1998-10-21 00:05:44 +04:00
|
|
|
NS_IMETHOD PullUpChildren(nsIPresContext& aPresContext,
|
|
|
|
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
|
|
|
*/
|
1998-10-11 13:18:27 +04: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. */
|
1998-10-11 13:18:27 +04:00
|
|
|
virtual void SetTableWidth(nsIPresContext& aPresContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/** given the new parent size, do I really need to do a reflow? */
|
1998-10-14 20:32:45 +04:00
|
|
|
virtual PRBool NeedsReflow(const nsHTMLReflowState& aReflowState,
|
|
|
|
const nsSize& aMaxSize);
|
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-15 02:51:50 +04:00
|
|
|
/** returns PR_TRUE if the cached column info is still valid */
|
|
|
|
virtual PRBool IsColumnCacheValid() const;
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
/** returns PR_TRUE if the cached column info is still valid */
|
|
|
|
virtual PRBool IsColumnWidthsValid() const;
|
|
|
|
|
1999-03-09 08:29:37 +03:00
|
|
|
nsIFrame* GetFirstBodyRowGroupFrame();
|
|
|
|
PRBool MoveOverflowToChildList();
|
|
|
|
void PushChildren(nsIFrame* aFromChild, nsIFrame* aPrevSibling);
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
public:
|
|
|
|
virtual void InvalidateFirstPassCache();
|
|
|
|
|
1998-10-15 02:51:50 +04:00
|
|
|
virtual void InvalidateColumnCache();
|
|
|
|
|
1998-10-16 01:07:37 +04:00
|
|
|
virtual void InvalidateColumnWidths();
|
|
|
|
|
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 */
|
1998-10-11 13:18:27 +04: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-06-17 20:38:24 +04:00
|
|
|
/** called whenever the number of columns changes, to increase the storage in mCellMap
|
|
|
|
*/
|
|
|
|
virtual void GrowCellMap(PRInt32 aColCount);
|
|
|
|
|
1998-10-14 20:32:45 +04:00
|
|
|
/** returns PR_TRUE if the cached pass 1 data is still valid */
|
|
|
|
virtual PRBool IsCellMapValid() const;
|
|
|
|
|
|
|
|
public:
|
1998-06-17 20:38:24 +04:00
|
|
|
/** ResetCellMap is called when the cell structure of the table is changed.
|
|
|
|
* Call with caution, only when changing the structure of the table such as
|
|
|
|
* inserting or removing rows, changing the rowspan or colspan attribute of a cell, etc.
|
|
|
|
*/
|
1998-10-14 20:32:45 +04:00
|
|
|
virtual void InvalidateCellMap();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/** iterates all child frames and creates a new cell map */
|
|
|
|
NS_IMETHOD ReBuildCellMap();
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-08-14 20:16:43 +04:00
|
|
|
/** Get the cell map for this table frame. It is not always mCellMap.
|
|
|
|
* Only the firstInFlow has a legit cell map
|
|
|
|
*/
|
1998-10-14 20:32:45 +04:00
|
|
|
virtual nsCellMap *GetCellMap() const;
|
1998-08-14 20:16:43 +04:00
|
|
|
|
1999-06-08 01:10:25 +04:00
|
|
|
void SetColumnDimensions(nscoord aHeight);
|
|
|
|
|
1998-11-06 00:42:46 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-11 04:00:31 +04:00
|
|
|
/** for debugging only
|
|
|
|
* prints out information about the cell map
|
|
|
|
*/
|
1998-07-24 20:51:16 +04:00
|
|
|
void DumpCellMap();
|
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
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/** sum the columns represented by all nsTableColGroup objects.
|
|
|
|
* if the cell map says there are more columns than this,
|
|
|
|
* add extra implicit columns to the content tree.
|
|
|
|
*/
|
1998-10-11 13:18:27 +04:00
|
|
|
virtual void EnsureColumns (nsIPresContext& aPresContext);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-01 01:23:28 +04:00
|
|
|
/** Set the min col span for every column in the table. Scans the whole table. */
|
|
|
|
virtual void SetMinColSpanForTable();
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-10-11 13:18:27 +04:00
|
|
|
virtual void BuildColumnCache(nsIPresContext& aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1999-06-15 03:42:16 +04:00
|
|
|
/** Helper for BuildColumnCache */
|
|
|
|
virtual void SetColumnStylesFromCells(nsIPresContext& aPresContext, nsIFrame* aRowGroupFrame);
|
|
|
|
|
1999-01-29 21:49:32 +03:00
|
|
|
virtual void CacheColFramesInCellMap();
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
/** called every time we discover we have a new cell to add to the table.
|
|
|
|
* This could be because we got actual cell content, because of rowspan/colspan attributes, etc.
|
|
|
|
* This method changes mCellMap as necessary to account for the new cell.
|
|
|
|
*
|
|
|
|
* @param aCell the content object created for the cell
|
|
|
|
* @param aRowIndex the row into which the cell is to be inserted
|
|
|
|
* @param aColIndex the col into which the cell is to be inserted
|
|
|
|
*/
|
|
|
|
virtual void BuildCellIntoMap (nsTableCellFrame *aCell, PRInt32 aRowIndex, PRInt32 aColIndex);
|
|
|
|
|
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 ();
|
|
|
|
|
1999-01-18 02:35:56 +03:00
|
|
|
/**
|
|
|
|
* Return aFrame's child if aFrame is an nsScrollFrame, otherwise return aFrame
|
|
|
|
*/
|
|
|
|
nsTableRowGroupFrame* GetRowGroupFrameFor(nsIFrame* aFrame, const nsStyleDisplay* aDisplay);
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
public: /* ----- Cell Map public methods ----- */
|
|
|
|
|
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
|
|
|
|
1998-09-19 02:37:14 +04:00
|
|
|
/** returns the number of columns in this table. */
|
1998-07-22 07:53:43 +04:00
|
|
|
virtual PRInt32 GetColCount();
|
|
|
|
|
1998-07-24 20:51:16 +04:00
|
|
|
/** adjust the col count for screwy table attributes.
|
|
|
|
* currently just handles excess colspan at end of table
|
|
|
|
*/
|
|
|
|
virtual void SetEffectiveColCount();
|
|
|
|
|
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-19 02:37:14 +04:00
|
|
|
/** returns PR_TRUE if the row at aRowIndex has any cells that are the result
|
|
|
|
* of a row-spanning cell above it.
|
|
|
|
* @see nsCellMap::RowIsSpannedInto
|
|
|
|
*/
|
|
|
|
PRBool RowIsSpannedInto(PRInt32 aRowIndex);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-09-19 02:37:14 +04:00
|
|
|
/** returns PR_TRUE if the row at aRowIndex has any cells that have a rowspan>1
|
|
|
|
* that originate in aRowIndex.
|
|
|
|
* @see nsCellMap::RowHasSpanningCells
|
|
|
|
*/
|
|
|
|
PRBool RowHasSpanningCells(PRInt32 aRowIndex);
|
|
|
|
|
|
|
|
/** returns PR_TRUE if the col at aColIndex has any cells that are the result
|
|
|
|
* of a col-spanning cell.
|
|
|
|
* @see nsCellMap::ColIsSpannedInto
|
|
|
|
*/
|
|
|
|
PRBool ColIsSpannedInto(PRInt32 aColIndex);
|
|
|
|
|
|
|
|
/** returns PR_TRUE if the row at aColIndex has any cells that have a colspan>1
|
|
|
|
* @see nsCellMap::ColHasSpanningCells
|
|
|
|
*/
|
|
|
|
PRBool ColHasSpanningCells(PRInt32 aColIndex);
|
1998-05-22 03:43:18 +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();
|
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
/** return the minimum width of the table. Return 0 if the min width is unknown. */
|
|
|
|
nscoord GetMinTableWidth();
|
|
|
|
|
|
|
|
/** return the maximum width of the table caption. Return 0 if the max width is unknown. */
|
|
|
|
nscoord GetMaxTableWidth();
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
void SetMaxElementSize(nsSize* aMaxElementSize);
|
|
|
|
|
1998-10-21 00:05:44 +04:00
|
|
|
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
|
|
|
PRBool RequiresPass1Layout();
|
|
|
|
|
1998-12-03 21:01:35 +03:00
|
|
|
public:
|
|
|
|
static nsIAtom* gColGroupAtom;
|
|
|
|
|
1999-02-04 01:35:03 +03:00
|
|
|
protected:
|
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
|
1998-10-11 13:18:27 +04:00
|
|
|
PRBool mColumnWidthsSet; // PR_TRUE if column widths have been set at least once
|
1998-10-16 01:07:37 +04:00
|
|
|
PRBool mColumnWidthsValid; // PR_TRUE if column width data is still legit, PR_FALSE if it needs to be recalculated
|
|
|
|
PRBool mFirstPassValid; // PR_TRUE if first pass data is still legit, PR_FALSE if it needs to be recalculated
|
|
|
|
PRBool mColumnCacheValid; // PR_TRUE if column cache info is still legit, PR_FALSE if it needs to be recalculated
|
|
|
|
PRBool mCellMapValid; // PR_TRUE if cell map data is still legit, PR_FALSE if it needs to be recalculated
|
1998-04-14 00:24:54 +04:00
|
|
|
PRBool mIsInvariantWidth; // PR_TRUE if table width cannot change
|
1999-01-18 02:35:56 +03:00
|
|
|
PRBool mHasScrollableRowGroup; // PR_TRUE if any section has overflow == "auto" or "scroll"
|
1998-06-17 20:38:24 +04:00
|
|
|
PRInt32 mColCount; // the number of columns in this table
|
1998-07-24 20:51:16 +04:00
|
|
|
PRInt32 mEffectiveColCount; // the number of columns in this table adjusted for weird table attributes
|
1998-06-17 20:38:24 +04:00
|
|
|
nsCellMap* mCellMap; // maintains the relationships between rows, cols, and cells
|
1998-10-10 01:53:07 +04:00
|
|
|
ColumnInfoCache *mColCache; // cached information about the table columns
|
|
|
|
nsITableLayoutStrategy * mTableLayoutStrategy; // the layout strategy for this frame
|
1999-01-16 01:52:05 +03:00
|
|
|
nsFrameList mColGroups; // the list of colgroup frames
|
1998-12-17 01:19:23 +03:00
|
|
|
|
1998-12-18 01:59:40 +03:00
|
|
|
nsBorderEdges mBorderEdges; // one list of border segments for each side of the table frame
|
1998-12-17 01:19:23 +03:00
|
|
|
// used only for the collapsing border model
|
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-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:
|
1999-05-04 23:15:56 +04:00
|
|
|
nsTableIterator(nsIFrame& aSource,
|
|
|
|
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
|
|
|
|
|
|
|
|