1998-04-14 00:24:54 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-04-14 00:24:54 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
|
|
|
#ifndef nsTableCellFrame_h__
|
|
|
|
#define nsTableCellFrame_h__
|
|
|
|
|
1999-02-11 04:16:28 +03:00
|
|
|
#include "nsITableCellLayout.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nscore.h"
|
1998-10-20 21:45:07 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-07-11 04:00:31 +04:00
|
|
|
#include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex
|
1998-12-21 09:38:18 +03:00
|
|
|
#include "nsIStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-11-11 22:56:02 +03:00
|
|
|
class nsTableFrame;
|
|
|
|
class nsHTMLValue;
|
1998-06-24 03:23:21 +04:00
|
|
|
|
1999-10-15 07:14:59 +04:00
|
|
|
/**
|
|
|
|
* Additional frame-state bits
|
|
|
|
*/
|
|
|
|
#define NS_TABLE_CELL_FRAME_CONTENT_EMPTY 0x80000000
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/**
|
|
|
|
* nsTableCellFrame
|
|
|
|
* data structure to maintain information about a single table cell's frame
|
|
|
|
*
|
1999-02-11 04:16:28 +03: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-14 00:24:54 +04:00
|
|
|
* @author sclark
|
|
|
|
*/
|
1999-03-08 18:13:54 +03:00
|
|
|
class nsTableCellFrame : public nsHTMLContainerFrame, public nsITableCellLayout
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
|
|
|
public:
|
1998-06-11 04:13:18 +04:00
|
|
|
|
1999-02-11 04:16:28 +03:00
|
|
|
// nsISupports
|
1999-03-06 06:56:24 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
1999-02-11 04:16:28 +03:00
|
|
|
|
1999-10-08 22:52:19 +04:00
|
|
|
// default constructor supplied by the compiler
|
1998-12-03 23:19:01 +03:00
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
nsTableCellFrame();
|
1999-10-17 07:30:11 +04:00
|
|
|
~nsTableCellFrame();
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
1999-02-25 08:31:15 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow);
|
|
|
|
|
2000-01-04 08:31:56 +03:00
|
|
|
NS_IMETHOD AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint);
|
|
|
|
|
1999-08-02 02:21:03 +04: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
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD AppendFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD InsertFrames(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList);
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-02 02:21:03 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame);
|
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
void InitCellFrame(PRInt32 aColIndex);
|
|
|
|
|
1998-12-21 09:38:18 +03:00
|
|
|
|
1998-09-15 21:58:24 +04: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-12-05 02:49:50 +03:00
|
|
|
NS_NewTableCellFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer);
|
1998-04-17 05:41:24 +04:00
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHOD SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread);
|
1999-06-02 03:04:13 +04:00
|
|
|
|
1999-11-24 09:03:41 +03: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
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
/**
|
|
|
|
* Get the "type" of the frame
|
|
|
|
*
|
|
|
|
* @see nsLayoutAtoms::tableCellFrame
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetFrameType(nsIAtom** aType) const;
|
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-11-02 01:12:45 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsString& aResult) const;
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
1999-08-31 07:09:40 +04:00
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
virtual void VerticallyAlignChild(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nscoord aMaxAscent);
|
|
|
|
|
|
|
|
PRBool HasVerticalAlignBaseline();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1999-02-21 22:55:22 +03: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-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
|
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
/*---------------- nsITableCellLayout methods ------------------------*/
|
|
|
|
|
1999-02-21 22:55:22 +03: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 06:04:45 +04:00
|
|
|
* and the column index (starting at 0 for the first column
|
1999-02-21 22:55:22 +03:00
|
|
|
*/
|
1999-08-04 06:04:45 +04: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 23:52:37 +04:00
|
|
|
virtual nsresult GetRowIndex(PRInt32 &aRowIndex) const;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
2000-03-23 07:24:58 +03:00
|
|
|
/** return the previous cell having the same column index as current cell
|
|
|
|
* returns null if no cell is present (but nsresult is still NS_OK)
|
|
|
|
* (When used within layout, you can QI aCellLayout to get an nsIFrame*)
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetPreviousCellInColumn(nsITableCellLayout **aCellLayout);
|
|
|
|
|
|
|
|
/** return the next cell having the same column index
|
|
|
|
* returns null if no cell is present (but nsresult is still NS_OK)
|
|
|
|
* (When used within layout, you can QI aCellLayout to get an nsIFrame*)
|
|
|
|
*/
|
|
|
|
NS_IMETHOD GetNextCellInColumn(nsITableCellLayout **aCellLayout);
|
|
|
|
|
1999-02-21 22:55:22 +03: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 21:29:07 +04:00
|
|
|
virtual PRInt32 GetColSpan();
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-02-21 22:55:22 +03:00
|
|
|
/** return the cell's column index (starting at 0 for the first column) */
|
1999-08-19 23:52:37 +04:00
|
|
|
virtual nsresult GetColIndex(PRInt32 &aColIndex) const;
|
1999-07-28 12:09:02 +04:00
|
|
|
virtual nsresult SetColIndex(PRInt32 aColIndex);
|
1998-04-23 21:29:07 +04:00
|
|
|
|
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();
|
2000-06-05 12:25:11 +04:00
|
|
|
virtual nscoord GetDesiredAscent();
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/** 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
|
|
|
|
1999-12-24 06:46:21 +03:00
|
|
|
/** return the maximum width of the cell */
|
|
|
|
virtual nscoord GetMaximumWidth() const;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-12-24 06:46:21 +03:00
|
|
|
/** set the maximum width of the cell */
|
|
|
|
virtual void SetMaximumWidth(nscoord aMaximumWidth);
|
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
|
|
|
|
*/
|
1999-08-19 23:52:37 +04:00
|
|
|
virtual nsSize GetPass1MaxElementSize() const;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
|
|
|
/** set the MaxElement size returned by this frame during its last reflow.
|
|
|
|
* should never be called with a null MaxElementSize
|
|
|
|
*/
|
2001-01-12 02:03:37 +03:00
|
|
|
virtual void SetPass1MaxElementSize(nscoord aMaxWidth,
|
|
|
|
const nsSize& aMaxElementSize);
|
1998-07-07 05:06:51 +04:00
|
|
|
|
1998-12-10 22:57:42 +03:00
|
|
|
PRBool GetContentEmpty();
|
|
|
|
void SetContentEmpty(PRBool aContentEmpty);
|
|
|
|
|
1999-02-11 09:22:33 +03:00
|
|
|
// The collapse offset is (0,0) except for cells originating in a row/col which is collapsed
|
1999-10-22 06:06:22 +04:00
|
|
|
void SetCollapseOffsetX(nsIPresContext* aPresContext, nscoord aXOffset);
|
|
|
|
void SetCollapseOffsetY(nsIPresContext* aPresContext, nscoord aYOffset);
|
|
|
|
void GetCollapseOffset(nsIPresContext* aPresContext, nsPoint& aOffset);
|
1999-02-11 09:22:33 +03:00
|
|
|
|
1998-10-20 21:45:07 +04:00
|
|
|
protected:
|
|
|
|
/** implement abstract method on nsHTMLContainerFrame */
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
1999-06-02 03:04:13 +04:00
|
|
|
virtual PRBool ParentDisablesSelection() const; //override default behavior
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
// All these methods are support methods for RecalcLayoutData
|
|
|
|
nsIFrame* GetFrameAt(nsVoidArray* aList, PRInt32 aIndex);
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
//XXX: aTableFrame can be removed as soon as border-collapse inherits correctly
|
|
|
|
void GetCellBorder(nsMargin &aBorder, nsTableFrame *aTableFrame);
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
protected:
|
|
|
|
|
2000-11-15 19:01:26 +03:00
|
|
|
friend class nsTableRowFrame;
|
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);
|
1999-10-20 18:18:56 +04:00
|
|
|
void MapBorderPadding(nsIPresContext* aPresContext);
|
1998-11-11 22:56:02 +03:00
|
|
|
|
|
|
|
void MapHTMLBorderStyle(nsIPresContext* aPresContext,
|
2001-02-07 12:57:26 +03:00
|
|
|
nsStyleBorder& aBorderStyle,
|
1999-05-18 09:18:16 +04:00
|
|
|
nsTableFrame* aTableFrame);
|
1998-11-11 22:56:02 +03:00
|
|
|
|
1999-01-03 22:22:40 +03:00
|
|
|
void MapVAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);
|
|
|
|
void MapHAlignAttribute(nsIPresContext* aPresContext, nsTableFrame *aTableFrame);
|
|
|
|
|
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 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;
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord mDesiredAscent;
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-12-24 06:46:21 +03:00
|
|
|
/** these are the Pass 1 maximum width and max element sizes */
|
|
|
|
nscoord mMaximumWidth;
|
1998-07-11 04:00:31 +04:00
|
|
|
nsSize mPass1MaxElementSize;
|
1998-07-07 05:06:51 +04:00
|
|
|
|
1998-12-30 09:48:15 +03:00
|
|
|
public:
|
1998-06-11 04:13:18 +04:00
|
|
|
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsReflowTimer* mTimer;
|
|
|
|
nsReflowTimer* mBlockTimer;
|
|
|
|
#endif
|
1998-12-21 09:38:18 +03:00
|
|
|
};
|
1998-06-11 04:13:18 +04:00
|
|
|
|
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; }
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
inline nscoord nsTableCellFrame::GetDesiredAscent()
|
|
|
|
{ return mDesiredAscent; }
|
|
|
|
|
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;
|
2000-06-05 12:25:11 +04:00
|
|
|
mDesiredAscent = aDesiredSize.ascent;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
1999-12-24 06:46:21 +03:00
|
|
|
inline nscoord nsTableCellFrame::GetMaximumWidth() const
|
|
|
|
{ return mMaximumWidth; }
|
1998-07-11 04:00:31 +04:00
|
|
|
|
1999-12-24 06:46:21 +03:00
|
|
|
inline void nsTableCellFrame::SetMaximumWidth(nscoord aMaximumWidth)
|
1998-07-11 04:00:31 +04:00
|
|
|
{
|
1999-12-24 06:46:21 +03:00
|
|
|
mMaximumWidth = aMaximumWidth;
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
1999-08-19 23:52:37 +04:00
|
|
|
inline nsSize nsTableCellFrame::GetPass1MaxElementSize() const
|
1998-07-11 04:00:31 +04:00
|
|
|
{ return mPass1MaxElementSize; }
|
|
|
|
|
1999-10-08 22:52:19 +04:00
|
|
|
inline PRBool nsTableCellFrame::GetContentEmpty()
|
|
|
|
{
|
1999-10-15 07:14:59 +04:00
|
|
|
return (mState & NS_TABLE_CELL_FRAME_CONTENT_EMPTY) ==
|
|
|
|
NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
1999-10-08 22:52:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void nsTableCellFrame::SetContentEmpty(PRBool aContentEmpty)
|
|
|
|
{
|
1999-10-15 07:14:59 +04:00
|
|
|
if (aContentEmpty) {
|
|
|
|
mState |= NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_TABLE_CELL_FRAME_CONTENT_EMPTY;
|
|
|
|
}
|
1999-10-08 22:52:19 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 02:23:26 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1998-07-11 04:00:31 +04:00
|
|
|
|