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 nsTableCellFrame_h__
|
|
|
|
#define nsTableCellFrame_h__
|
|
|
|
|
|
|
|
#include "nscore.h"
|
1998-10-20 21:45:07 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-05-22 03:43:18 +04:00
|
|
|
#include "nsTableFrame.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-05-13 02:28:01 +04:00
|
|
|
struct nsStyleSpacing;
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
/* eb42f7b0-079e-11d2-8f37-006008159b0c */
|
|
|
|
#define NS_TABLECELLFRAME_CID \
|
|
|
|
{0xeb42f7b0, 0x079e, 0x11d2, {0x8f, 0x37, 0x00, 0x60, 0x08, 0x15, 0x9b, 0x0c}}
|
|
|
|
|
|
|
|
extern const nsIID kTableCellFrameCID;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* nsTableCellFrame
|
|
|
|
* data structure to maintain information about a single table cell's frame
|
|
|
|
*
|
|
|
|
* @author sclark
|
|
|
|
*/
|
1998-10-20 21:45:07 +04:00
|
|
|
class nsTableCellFrame : public nsHTMLContainerFrame
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
public:
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
void InitCellFrame(PRInt32 aColIndex);
|
|
|
|
|
|
|
|
/** instantiate a new instance of nsTableCellFrame.
|
|
|
|
* @param aResult the new object is returned in this out-param
|
|
|
|
* @param aContent the table object to map
|
|
|
|
* @param aParent the parent of the new frame
|
|
|
|
*
|
|
|
|
* @return NS_OK if the frame was properly allocated, otherwise an error code
|
|
|
|
*/
|
|
|
|
friend nsresult
|
|
|
|
NS_NewTableCellFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame,
|
|
|
|
nsIFrame*& aResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
// nsISupports
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
NS_IMETHOD Init(nsIPresContext& aPresContext, nsIFrame* aChildList);
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
|
1998-07-15 06:53:09 +04:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-05-25 21:31:49 +04:00
|
|
|
nsReflowStatus& aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsContainerFrame
|
|
|
|
*/
|
1998-07-15 07:23:23 +04:00
|
|
|
NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext,
|
1998-05-07 04:08:20 +04:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aStyleContext,
|
|
|
|
nsIFrame*& aContinuingFrame);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
void VerticallyAlignChild(nsIPresContext* aPresContext);
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** return the mapped cell's row span. Always >= 1. */
|
1998-04-14 00:24:54 +04:00
|
|
|
virtual PRInt32 GetRowSpan();
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
// there is no set row index because row index depends on the cell's parent row only
|
|
|
|
|
|
|
|
/** return the mapped cell's row index (starting at 0 for the first row) */
|
|
|
|
virtual PRInt32 GetRowIndex();
|
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** return the mapped cell's col span. Always >= 1. */
|
|
|
|
virtual PRInt32 GetColSpan();
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-04-23 21:29:07 +04:00
|
|
|
/** return the mapped cell's column index (starting at 0 for the first column) */
|
|
|
|
virtual PRInt32 GetColIndex();
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** set the index of the column belonging to this cell */
|
|
|
|
// XXX should be removed, use cell map?
|
1998-06-17 20:38:24 +04:00
|
|
|
virtual void SetColIndex (int aColIndex);
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** return the available width given to this frame during its last reflow */
|
1998-07-02 21:40:56 +04:00
|
|
|
virtual nscoord GetPriorAvailWidth();
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** set the available width given to this frame during its last reflow */
|
1998-07-02 21:40:56 +04:00
|
|
|
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** return the desired size returned by this frame during its last reflow */
|
|
|
|
virtual nsSize GetDesiredSize();
|
|
|
|
|
|
|
|
/** set the desired size returned by this frame during its last reflow */
|
1998-10-01 08:46:11 +04:00
|
|
|
virtual void SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/** return the desired size returned by this frame during its last reflow */
|
|
|
|
virtual nsSize GetPass1DesiredSize();
|
|
|
|
|
|
|
|
/** set the desired size returned by this frame during its last reflow */
|
1998-10-01 08:46:11 +04:00
|
|
|
virtual void SetPass1DesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/** return the MaxElement size returned by this frame during its last reflow
|
|
|
|
* not counting reflows where MaxElementSize is not requested.
|
|
|
|
* That is, the cell frame will always remember the last non-null MaxElementSize
|
|
|
|
*/
|
|
|
|
virtual nsSize GetPass1MaxElementSize();
|
|
|
|
|
|
|
|
/** set the MaxElement size returned by this frame during its last reflow.
|
|
|
|
* should never be called with a null MaxElementSize
|
|
|
|
*/
|
|
|
|
virtual void SetPass1MaxElementSize(const nsSize & aMaxElementSize);
|
1998-07-07 05:06:51 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
void RecalcLayoutData(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4]);
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
NS_IMETHOD GetMargin(nsMargin& aMargin);
|
|
|
|
|
|
|
|
|
|
|
|
/** destructor */
|
|
|
|
virtual ~nsTableCellFrame();
|
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
protected:
|
|
|
|
/** implement abstract method on nsHTMLContainerFrame */
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
// All these methods are support methods for RecalcLayoutData
|
|
|
|
nsIFrame* GetFrameAt(nsVoidArray* aList, PRInt32 aIndex);
|
|
|
|
|
|
|
|
nscoord GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const;
|
|
|
|
|
|
|
|
nscoord GetBorderWidth(nsIFrame* aFrame, PRUint8 aEdge) const;
|
|
|
|
|
|
|
|
nscoord GetPadding(nsIFrame* aFrame, PRUint8 aEdge) const;
|
|
|
|
|
|
|
|
PRUint8 GetOpposingEdge(PRUint8 aEdge);
|
|
|
|
|
|
|
|
nsIFrame* CompareCellBorders(nsIFrame* aFrame1,
|
|
|
|
PRUint8 aEdge1,
|
|
|
|
nsIFrame* aFrame2,
|
|
|
|
PRUint8 aEdge2);
|
|
|
|
|
|
|
|
|
|
|
|
nsIFrame* FindHighestPrecedentBorder(nsVoidArray* aList,
|
|
|
|
PRUint8 aEdge);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nsIFrame* FindInnerBorder( nsVoidArray* aList,
|
|
|
|
PRUint8 aEdge);
|
|
|
|
|
|
|
|
nsIFrame* FindOuterBorder( nsTableFrame* aTableFrame,
|
|
|
|
PRUint8 aEdge);
|
|
|
|
|
|
|
|
nsIFrame* FindBorderFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aCellList,
|
|
|
|
PRUint8 aEdge);
|
|
|
|
|
|
|
|
void CalculateBorders(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4]);
|
|
|
|
|
|
|
|
nscoord FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge);
|
|
|
|
|
|
|
|
|
|
|
|
void CalculateMargins(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4]);
|
|
|
|
|
1998-09-03 01:59:54 +04:00
|
|
|
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/** protected constructor.
|
|
|
|
* @see NewFrame
|
|
|
|
*/
|
|
|
|
nsTableCellFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame);
|
|
|
|
|
1998-05-02 00:44:55 +04:00
|
|
|
// Subclass hook for style post processing
|
1998-05-27 03:17:29 +04:00
|
|
|
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
1998-05-02 00:44:55 +04:00
|
|
|
void MapBorderMarginPadding(nsIPresContext* aPresContext);
|
1998-05-27 00:57:24 +04:00
|
|
|
void MapHTMLBorderStyle(nsIPresContext* aPresContext,nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
|
1998-05-22 03:43:18 +04:00
|
|
|
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1998-10-30 10:57:44 +03:00
|
|
|
NS_IMETHOD IR_StyleChanged(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
|
|
|
|
1998-06-11 04:13:18 +04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/** the starting column for this cell */
|
|
|
|
int mColIndex;
|
|
|
|
|
1998-07-02 21:40:56 +04:00
|
|
|
/** the available width we were given in our previous reflow */
|
|
|
|
nscoord mPriorAvailWidth;
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** these are the last computed desired and max element sizes */
|
|
|
|
nsSize mDesiredSize;
|
|
|
|
nsSize mMaxElementSize;
|
|
|
|
|
|
|
|
/** these are the Pass 1 unconstrained desired and max element sizes */
|
|
|
|
nsSize mPass1DesiredSize;
|
|
|
|
nsSize mPass1MaxElementSize;
|
1998-07-07 05:06:51 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
nsresult mCalculated;
|
|
|
|
nsMargin mMargin;
|
|
|
|
nsIFrame* mBorderFrame[4]; // the frame whose border is used
|
1998-06-17 20:38:24 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
inline void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex)
|
1998-06-11 04:13:18 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(0<=aColIndex, "bad col index arg");
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
inline PRInt32 nsTableCellFrame::GetRowIndex()
|
|
|
|
{
|
|
|
|
nsTableRowFrame * row;
|
|
|
|
GetContentParent((nsIFrame *&)row);
|
|
|
|
if (nsnull!=row)
|
|
|
|
return row->GetRowIndex();
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-06-11 04:13:18 +04:00
|
|
|
inline PRInt32 nsTableCellFrame::GetColIndex()
|
|
|
|
{ return mColIndex;}
|
|
|
|
|
1998-06-17 20:38:24 +04:00
|
|
|
inline void nsTableCellFrame::SetColIndex (int aColIndex)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(0<=aColIndex, "illegal negative column index.");
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
1998-07-02 21:40:56 +04:00
|
|
|
inline nscoord nsTableCellFrame::GetPriorAvailWidth()
|
|
|
|
{ return mPriorAvailWidth;}
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
|
|
|
{ mPriorAvailWidth = aPriorAvailWidth;}
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
inline nsSize nsTableCellFrame::GetDesiredSize()
|
|
|
|
{ return mDesiredSize; }
|
|
|
|
|
1998-10-01 08:46:11 +04:00
|
|
|
inline void nsTableCellFrame::SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
|
|
|
mDesiredSize.width = aDesiredSize.width;
|
|
|
|
mDesiredSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsSize nsTableCellFrame::GetPass1DesiredSize()
|
|
|
|
{ return mPass1DesiredSize; }
|
|
|
|
|
1998-10-01 08:46:11 +04:00
|
|
|
inline void nsTableCellFrame::SetPass1DesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
|
|
|
mPass1DesiredSize.width = aDesiredSize.width;
|
|
|
|
mPass1DesiredSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsSize nsTableCellFrame::GetPass1MaxElementSize()
|
|
|
|
{ return mPass1MaxElementSize; }
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetPass1MaxElementSize(const nsSize & aMaxElementSize)
|
|
|
|
{
|
|
|
|
mPass1MaxElementSize.width = aMaxElementSize.width;
|
|
|
|
mPass1MaxElementSize.height = aMaxElementSize.height;
|
|
|
|
}
|
1998-07-07 05:06:51 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
inline void nsTableCellFrame::CalculateBorders(nsTableFrame* aTableFrame,
|
|
|
|
nsVoidArray* aBoundaryCells[4])
|
1998-07-07 05:06:51 +04:00
|
|
|
{
|
1998-07-11 04:00:31 +04:00
|
|
|
for (PRInt32 edge = 0; edge < 4; edge++)
|
|
|
|
mBorderFrame[edge] = FindBorderFrame(aTableFrame, aBoundaryCells[edge], edge);
|
1998-07-07 05:06:51 +04:00
|
|
|
}
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
inline NS_METHOD nsTableCellFrame::GetMargin(nsMargin& aMargin)
|
|
|
|
{
|
|
|
|
if (mCalculated == NS_OK)
|
|
|
|
{
|
|
|
|
aMargin = mMargin;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
|
1998-10-15 02:23:26 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|