1998-04-13 20:24:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00: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-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00: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-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-13 20:24:54 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-13 20:24:54 +00:00
|
|
|
*/
|
|
|
|
#ifndef nsTableCellFrame_h__
|
|
|
|
#define nsTableCellFrame_h__
|
|
|
|
|
1999-02-11 01:16:28 +00:00
|
|
|
#include "nsITableCellLayout.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nscore.h"
|
1998-10-20 17:45:07 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-07-11 00:00:31 +00:00
|
|
|
#include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex
|
1998-12-21 06:38:18 +00:00
|
|
|
#include "nsIStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-05-12 22:28:01 +00:00
|
|
|
struct nsStyleSpacing;
|
1998-11-11 19:56:02 +00:00
|
|
|
class nsTableFrame;
|
|
|
|
class nsHTMLValue;
|
1998-06-23 23:23:21 +00:00
|
|
|
|
1999-10-15 03:14:59 +00:00
|
|
|
/**
|
|
|
|
* Additional frame-state bits
|
|
|
|
*/
|
|
|
|
#define NS_TABLE_CELL_FRAME_CONTENT_EMPTY 0x80000000
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/**
|
|
|
|
* nsTableCellFrame
|
|
|
|
* data structure to maintain information about a single table cell's frame
|
|
|
|
*
|
1999-02-11 01:16:28 +00:00
|
|
|
* NOTE: frames are not ref counted. We expose addref and release here
|
|
|
|
* so we can change that decsion in the future. Users of nsITableCellLayout
|
|
|
|
* should refcount correctly as if this object is being ref counted, though
|
|
|
|
* no actual support is under the hood.
|
|
|
|
*
|
1998-04-13 20:24:54 +00:00
|
|
|
* @author sclark
|
|
|
|
*/
|
1999-03-08 15:13:54 +00:00
|
|
|
class nsTableCellFrame : public nsHTMLContainerFrame, public nsITableCellLayout
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
|
|
|
public:
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1999-02-11 01:16:28 +00:00
|
|
|
// nsISupports
|
1999-03-06 03:56:24 +00:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-02-11 01:16:28 +00:00
|
|
|
|
1999-10-08 18:52:19 +00:00
|
|
|
// default constructor supplied by the compiler
|
1998-12-03 20:19:01 +00:00
|
|
|
|
1999-10-17 03:30:11 +00:00
|
|
|
~nsTableCellFrame();
|
|
|
|
|
1999-02-25 05:31:15 +00:00
|
|
|
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
1999-08-01 22:21:03 +00:00
|
|
|
// table cells contain an area frame which does most of the work, and
|
|
|
|
// so these functions should never be called. They assert and return
|
|
|
|
// NS_ERROR_NOT_IMPLEMENTED
|
|
|
|
NS_IMETHOD AppendFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList);
|
|
|
|
NS_IMETHOD InsertFrames(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
|
|
|
NS_IMETHOD RemoveFrame(nsIPresContext& aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
void InitCellFrame(PRInt32 aColIndex);
|
|
|
|
|
1998-12-21 06:38:18 +00:00
|
|
|
void SetBorderEdge(PRUint8 aSide,
|
|
|
|
PRInt32 aRowIndex,
|
|
|
|
PRInt32 aColIndex,
|
1998-12-21 18:54:23 +00:00
|
|
|
nsBorderEdge *border,
|
|
|
|
nscoord aOddAmountToAdd);
|
1998-12-21 06:38:18 +00:00
|
|
|
|
|
|
|
void SetBorderEdgeLength(PRUint8 aSide,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
nscoord aLength);
|
|
|
|
|
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
/** instantiate a new instance of nsTableCellFrame.
|
|
|
|
* @param aResult the new object is returned in this out-param
|
|
|
|
*
|
|
|
|
* @return NS_OK if the frame was properly allocated, otherwise an error code
|
|
|
|
*/
|
|
|
|
friend nsresult
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_NewTableCellFrame(nsIFrame** aResult);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_IMETHOD Paint(nsIPresContext& aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-17 01:41:24 +00:00
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread);
|
1999-06-01 23:04:13 +00:00
|
|
|
|
1998-07-15 02:53:09 +00:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext& aPresContext,
|
1998-10-01 04:46:11 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
1998-10-02 04:10:00 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-05-25 17:31:49 +00:00
|
|
|
nsReflowStatus& aStatus);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-24 05:54:31 +00:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableCellFrame
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1999-09-01 01:02:16 +00:00
|
|
|
#ifdef DEBUG
|
1999-11-01 22:12:45 +00:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1999-08-31 03:09:40 +00:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
1999-08-31 03:09:40 +00:00
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
virtual void VerticallyAlignChild(nsIPresContext* aPresContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1999-02-21 19:55:22 +00:00
|
|
|
/**
|
|
|
|
* return the cell's specified row span. this is what was specified in the
|
|
|
|
* content model or in the style info, and is always >= 1.
|
|
|
|
* to get the effective row span (the actual value that applies), use GetEffectiveRowSpan()
|
|
|
|
* @see nsTableFrame::GetEffectiveRowSpan()
|
|
|
|
*/
|
1998-04-13 20:24:54 +00:00
|
|
|
virtual PRInt32 GetRowSpan();
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
// there is no set row index because row index depends on the cell's parent row only
|
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
/*---------------- nsITableCellLayout methods ------------------------*/
|
|
|
|
|
1999-02-21 19:55:22 +00:00
|
|
|
/**
|
|
|
|
* return the cell's starting row index (starting at 0 for the first row).
|
|
|
|
* for continued cell frames the row index is that of the cell's first-in-flow
|
1999-08-04 02:04:45 +00:00
|
|
|
* and the column index (starting at 0 for the first column
|
1999-02-21 19:55:22 +00:00
|
|
|
*/
|
1999-08-04 02:04:45 +00:00
|
|
|
NS_IMETHOD GetCellIndexes(PRInt32 &aRowIndex, PRInt32 &aColIndex);
|
|
|
|
|
|
|
|
/** return the mapped cell's row index (starting at 0 for the first row) */
|
1999-08-19 19:52:37 +00:00
|
|
|
virtual nsresult GetRowIndex(PRInt32 &aRowIndex) const;
|
1998-07-11 00:00:31 +00:00
|
|
|
|
1999-02-21 19:55:22 +00:00
|
|
|
/**
|
|
|
|
* return the cell's specified col span. this is what was specified in the
|
|
|
|
* content model or in the style info, and is always >= 1.
|
|
|
|
* to get the effective col span (the actual value that applies), use GetEffectiveColSpan()
|
|
|
|
* @see nsTableFrame::GetEffectiveColSpan()
|
|
|
|
*/
|
1998-04-23 17:29:07 +00:00
|
|
|
virtual PRInt32 GetColSpan();
|
1998-07-11 00:00:31 +00:00
|
|
|
|
1999-02-21 19:55:22 +00:00
|
|
|
/** return the cell's column index (starting at 0 for the first column) */
|
1999-08-19 19:52:37 +00:00
|
|
|
virtual nsresult GetColIndex(PRInt32 &aColIndex) const;
|
1999-07-28 08:09:02 +00:00
|
|
|
virtual nsresult SetColIndex(PRInt32 aColIndex);
|
1998-04-23 17:29:07 +00:00
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
/** return the available width given to this frame during its last reflow */
|
1998-07-02 17:40:56 +00:00
|
|
|
virtual nscoord GetPriorAvailWidth();
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
/** set the available width given to this frame during its last reflow */
|
1998-07-02 17:40:56 +00:00
|
|
|
virtual void SetPriorAvailWidth(nscoord aPriorAvailWidth);
|
|
|
|
|
1998-07-11 00:00:31 +00: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 04:46:11 +00:00
|
|
|
virtual void SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
|
1998-07-11 00:00:31 +00:00
|
|
|
|
|
|
|
/** return the desired size returned by this frame during its last reflow */
|
1999-08-19 19:52:37 +00:00
|
|
|
virtual nsSize GetPass1DesiredSize() const;
|
1998-07-11 00:00:31 +00:00
|
|
|
|
|
|
|
/** set the desired size returned by this frame during its last reflow */
|
1998-10-01 04:46:11 +00:00
|
|
|
virtual void SetPass1DesiredSize(const nsHTMLReflowMetrics & aDesiredSize);
|
1998-07-11 00:00:31 +00: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
|
|
|
|
*/
|
1999-08-19 19:52:37 +00:00
|
|
|
virtual nsSize GetPass1MaxElementSize() const;
|
1998-07-11 00:00:31 +00:00
|
|
|
|
|
|
|
/** 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 01:06:51 +00:00
|
|
|
|
1998-12-10 19:57:42 +00:00
|
|
|
PRBool GetContentEmpty();
|
|
|
|
void SetContentEmpty(PRBool aContentEmpty);
|
|
|
|
|
1999-02-11 06:22:33 +00:00
|
|
|
// The collapse offset is (0,0) except for cells originating in a row/col which is collapsed
|
1999-10-22 02:06:22 +00:00
|
|
|
void SetCollapseOffsetX(nsIPresContext* aPresContext, nscoord aXOffset);
|
|
|
|
void SetCollapseOffsetY(nsIPresContext* aPresContext, nscoord aYOffset);
|
|
|
|
void GetCollapseOffset(nsIPresContext* aPresContext, nsPoint& aOffset);
|
1999-02-11 06:22:33 +00:00
|
|
|
|
1998-10-20 17:45:07 +00:00
|
|
|
protected:
|
|
|
|
/** implement abstract method on nsHTMLContainerFrame */
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
1999-06-01 23:04:13 +00:00
|
|
|
virtual PRBool ParentDisablesSelection() const; //override default behavior
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
// All these methods are support methods for RecalcLayoutData
|
|
|
|
nsIFrame* GetFrameAt(nsVoidArray* aList, PRInt32 aIndex);
|
|
|
|
|
|
|
|
nscoord GetMargin(nsIFrame* aFrame, PRUint8 aEdge) const;
|
|
|
|
|
1998-12-23 15:47:43 +00:00
|
|
|
//XXX: aTableFrame can be removed as soon as border-collapse inherits correctly
|
|
|
|
void GetCellBorder(nsMargin &aBorder, nsTableFrame *aTableFrame);
|
1998-07-11 00:00:31 +00:00
|
|
|
|
|
|
|
PRUint8 GetOpposingEdge(PRUint8 aEdge);
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
protected:
|
|
|
|
|
1998-05-01 20:44:55 +00:00
|
|
|
// Subclass hook for style post processing
|
1998-05-26 23:17:29 +00:00
|
|
|
NS_IMETHOD DidSetStyleContext(nsIPresContext* aPresContext);
|
1998-11-11 19:56:02 +00:00
|
|
|
|
1999-10-20 14:18:56 +00:00
|
|
|
void MapBorderPadding(nsIPresContext* aPresContext);
|
1998-11-11 19:56:02 +00:00
|
|
|
|
|
|
|
void MapHTMLBorderStyle(nsIPresContext* aPresContext,
|
1999-09-02 00:07:14 +00:00
|
|
|
nsStyleSpacing& aSpacingStyle,
|
1999-05-18 05:18:16 +00:00
|
|
|
nsTableFrame* aTableFrame);
|
1998-11-11 19:56:02 +00:00
|
|
|
|
1999-01-03 19:22:40 +00:00
|
|
|
void MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);
|
|
|
|
void MapHAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);
|
|
|
|
|
1998-05-21 23:43:18 +00:00
|
|
|
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
|
1998-06-11 00:13:18 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/** the starting column for this cell */
|
|
|
|
int mColIndex;
|
|
|
|
|
1998-07-02 17:40:56 +00:00
|
|
|
/** the available width we were given in our previous reflow */
|
|
|
|
nscoord mPriorAvailWidth;
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
/** these are the last computed desired and max element sizes */
|
|
|
|
nsSize mDesiredSize;
|
|
|
|
|
|
|
|
/** these are the Pass 1 unconstrained desired and max element sizes */
|
|
|
|
nsSize mPass1DesiredSize;
|
|
|
|
nsSize mPass1MaxElementSize;
|
1998-07-07 01:06:51 +00:00
|
|
|
|
1998-12-30 06:48:15 +00:00
|
|
|
public:
|
1999-10-17 03:30:11 +00:00
|
|
|
nsBorderEdges *mBorderEdges; // one list of border segments for each side of the table frame
|
1999-10-08 18:52:19 +00:00
|
|
|
// used only for the collapsing border model
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1998-12-21 06:38:18 +00:00
|
|
|
};
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
inline nsresult nsTableCellFrame::GetRowIndex(PRInt32 &aRowIndex) const
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
1999-02-21 19:55:22 +00:00
|
|
|
nsTableCellFrame* cell = (nsTableCellFrame*)GetFirstInFlow();
|
1999-02-11 01:16:28 +00:00
|
|
|
nsresult result;
|
1998-07-11 00:00:31 +00:00
|
|
|
nsTableRowFrame * row;
|
1999-02-21 19:55:22 +00:00
|
|
|
cell->GetParent((nsIFrame **)&row);
|
1998-07-11 00:00:31 +00:00
|
|
|
if (nsnull!=row)
|
1999-02-11 01:16:28 +00:00
|
|
|
{
|
|
|
|
aRowIndex = row->GetRowIndex();
|
|
|
|
result = NS_OK;
|
|
|
|
}
|
1998-07-11 00:00:31 +00:00
|
|
|
else
|
1999-02-11 01:16:28 +00:00
|
|
|
{
|
|
|
|
aRowIndex = 0;
|
|
|
|
result = NS_ERROR_NOT_INITIALIZED;
|
|
|
|
}
|
|
|
|
return result;
|
1998-07-11 00:00:31 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
inline nsresult nsTableCellFrame::GetColIndex(PRInt32 &aColIndex) const
|
1999-02-11 01:16:28 +00:00
|
|
|
{
|
|
|
|
aColIndex = mColIndex;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-11 00:13:18 +00:00
|
|
|
|
1998-07-02 17:40:56 +00:00
|
|
|
inline nscoord nsTableCellFrame::GetPriorAvailWidth()
|
|
|
|
{ return mPriorAvailWidth;}
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetPriorAvailWidth(nscoord aPriorAvailWidth)
|
|
|
|
{ mPriorAvailWidth = aPriorAvailWidth;}
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
inline nsSize nsTableCellFrame::GetDesiredSize()
|
|
|
|
{ return mDesiredSize; }
|
|
|
|
|
1998-10-01 04:46:11 +00:00
|
|
|
inline void nsTableCellFrame::SetDesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
|
|
|
mDesiredSize.width = aDesiredSize.width;
|
|
|
|
mDesiredSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
inline nsSize nsTableCellFrame::GetPass1DesiredSize() const
|
1998-07-11 00:00:31 +00:00
|
|
|
{ return mPass1DesiredSize; }
|
|
|
|
|
1998-10-01 04:46:11 +00:00
|
|
|
inline void nsTableCellFrame::SetPass1DesiredSize(const nsHTMLReflowMetrics & aDesiredSize)
|
1998-07-11 00:00:31 +00:00
|
|
|
{
|
|
|
|
mPass1DesiredSize.width = aDesiredSize.width;
|
|
|
|
mPass1DesiredSize.height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
inline nsSize nsTableCellFrame::GetPass1MaxElementSize() const
|
1998-07-11 00:00:31 +00:00
|
|
|
{ return mPass1MaxElementSize; }
|
|
|
|
|
1999-10-08 18:52:19 +00:00
|
|
|
inline PRBool nsTableCellFrame::GetContentEmpty()
|
|
|
|
{
|
1999-10-15 03:14:59 +00:00
|
|
|
return (mState & NS_TABLE_CELL_FRAME_CONTENT_EMPTY) ==
|
|
|
|
NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
1999-10-08 18:52:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetContentEmpty(PRBool aContentEmpty)
|
|
|
|
{
|
1999-10-15 03:14:59 +00:00
|
|
|
if (aContentEmpty) {
|
|
|
|
mState |= NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
|
|
|
}
|
1999-10-08 18:52:19 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 22:23:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1998-07-11 00:00:31 +00:00
|
|
|
|