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"
|
|
|
|
#include "nsContainerFrame.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
|
|
|
|
*/
|
|
|
|
class nsTableCellFrame : public nsContainerFrame
|
|
|
|
{
|
|
|
|
public:
|
1998-06-11 04:13:18 +04:00
|
|
|
|
|
|
|
void Init(PRInt32 aRowSpan, PRInt32 aColSpan, PRInt32 aColIndex);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent);
|
|
|
|
|
1998-06-24 03:23:21 +04:00
|
|
|
// nsISupports
|
|
|
|
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect);
|
|
|
|
|
1998-05-25 21:31:49 +04:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
|
|
|
nsReflowMetrics& aDesiredSize,
|
|
|
|
const nsReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsContainerFrame
|
|
|
|
*/
|
1998-05-07 04:08:20 +04:00
|
|
|
NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext,
|
|
|
|
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 */
|
|
|
|
virtual void SetDesiredSize(const nsReflowMetrics & aDesiredSize);
|
|
|
|
|
|
|
|
/** 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 GetMaxElementSize();
|
|
|
|
|
|
|
|
/** set the MaxElement size returned by this frame during its last reflow.
|
|
|
|
* should never be called with a null MaxElementSize
|
|
|
|
*/
|
|
|
|
virtual void SetMaxElementSize(const nsSize & aMaxElementSize);
|
|
|
|
|
|
|
|
/** 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 */
|
|
|
|
virtual void SetPass1DesiredSize(const nsReflowMetrics & aDesiredSize);
|
|
|
|
|
|
|
|
/** 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-04-14 00:24:54 +04:00
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
/** Get the TableFrame that contains this cell frame */
|
1998-05-22 03:43:18 +04:00
|
|
|
virtual nsTableFrame* GetTableFrame();
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
// For DEBUGGING Purposes Only, to be removed
|
1998-05-22 03:43:18 +04:00
|
|
|
NS_IMETHOD MoveTo(nscoord aX, nscoord aY);
|
|
|
|
NS_IMETHOD SizeTo(nscoord aWidth, nscoord aHeight);
|
|
|
|
|
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-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/** protected constructor.
|
|
|
|
* @see NewFrame
|
|
|
|
*/
|
|
|
|
nsTableCellFrame(nsIContent* aContent,
|
|
|
|
nsIFrame* aParentFrame);
|
|
|
|
|
1998-05-22 04:05:22 +04:00
|
|
|
/** Create a psuedo-frame for this cell. Handles continuing frames as needed.
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
virtual void CreatePsuedoFrame(nsIPresContext* aPresContext);
|
|
|
|
|
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 MapTextAttributes(nsIPresContext* aPresContext);
|
|
|
|
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
|
|
|
|
|
|
|
protected:
|
|
|
|
/** the number of rows spanned by this cell */
|
|
|
|
int mRowSpan;
|
|
|
|
|
|
|
|
/** the number of columns spanned by this cell */
|
|
|
|
int mColSpan;
|
|
|
|
|
|
|
|
/** 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-06-11 04:13:18 +04:00
|
|
|
inline void nsTableCellFrame::Init(PRInt32 aRowSpan, PRInt32 aColSpan, PRInt32 aColIndex)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0<aRowSpan, "bad row span arg");
|
|
|
|
NS_PRECONDITION(0<aColSpan, "bad col span arg");
|
|
|
|
NS_PRECONDITION(0<=aColIndex, "bad col index arg");
|
|
|
|
mRowSpan = aRowSpan;
|
|
|
|
mColSpan = aColSpan;
|
|
|
|
mColIndex = aColIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline PRInt32 nsTableCellFrame::GetRowSpan()
|
|
|
|
{ return mRowSpan;}
|
|
|
|
|
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::GetColSpan()
|
|
|
|
{ return mColSpan;}
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetDesiredSize(const nsReflowMetrics & aDesiredSize)
|
|
|
|
{
|
|
|
|
mDesiredSize.width = aDesiredSize.width;
|
|
|
|
mDesiredSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsSize nsTableCellFrame::GetMaxElementSize()
|
|
|
|
{ return mMaxElementSize; }
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetMaxElementSize(const nsSize & aMaxElementSize)
|
|
|
|
{
|
|
|
|
mMaxElementSize.width = aMaxElementSize.width;
|
|
|
|
mMaxElementSize.height = aMaxElementSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsSize nsTableCellFrame::GetPass1DesiredSize()
|
|
|
|
{ return mPass1DesiredSize; }
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetPass1DesiredSize(const nsReflowMetrics & aDesiredSize)
|
|
|
|
{
|
|
|
|
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-04-14 00:24:54 +04:00
|
|
|
#endif
|