some tentative steps towards content/frame separation in tables

This commit is contained in:
buster 1998-06-11 00:13:18 +00:00
parent 6bddcaeebe
commit 2d31c54583
17 changed files with 177 additions and 96 deletions

View File

@ -30,7 +30,6 @@
#include "nsHTMLIIDs.h"
NS_DEF_PTR(nsTableCol);
NS_DEF_PTR(nsTableCell);
NS_DEF_PTR(nsIStyleContext);

View File

@ -18,8 +18,8 @@
#include "nsCRT.h"
#include "nsCellLayoutData.h"
#include "nsSize.h"
#include "nsVoidArray.h"
#include "nsIFrame.h"
#include "nsTableCell.h"
#include "nsIStyleContext.h"
#include "nsIPtr.h"
@ -528,14 +528,15 @@ void nsCellLayoutData::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 indent;
nsTableCell* cell;
nsIContent* cell;
mCellFrame->GetContent((nsIContent*&)cell);
mCellFrame->GetContent(cell);
if (cell != nsnull)
{
/*
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fprintf(out,"RowSpan = %d ColSpan = %d \n",cell->GetRowSpan(),cell->GetColSpan());
*/
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fprintf(out,"Margin -- Top: %d Left: %d Bottom: %d Right: %d \n",
NS_TWIPS_TO_POINTS_INT(mMargin.top),

View File

@ -19,6 +19,7 @@
#include "nsTableCol.h"
#include "nsVoidArray.h"
#include "nsCellLayoutData.h"
#include "nsTableCell.h"
nsColLayoutData::nsColLayoutData(nsTableCol *aCol)
{

View File

@ -150,6 +150,7 @@ nsTableCell::CreateFrame(nsIPresContext* aPresContext,
if (NS_OK != rv) {
return rv;
}
((nsTableCellFrame*)frame)->Init(mRowSpan, mColSpan, mColIndex);
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;

View File

@ -26,10 +26,14 @@
#include "nsIContent.h"
#include "nsIContentDelegate.h"
#include "nsCSSLayout.h"
#include "nsHTMLValue.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
#include "nsIPtr.h"
#include "nsIView.h"
// evil dep's to be removed ASAP
#include "nsTablePart.h"
#include "nsTableContent.h"
NS_DEF_PTR(nsIStyleContext);
@ -47,6 +51,9 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
nsIFrame* aParentFrame)
: nsContainerFrame(aContent, aParentFrame)
{
mRowSpan=1;
mColSpan=1;
mColIndex=0;
}
nsTableCellFrame::~nsTableCellFrame()
@ -145,42 +152,6 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
mFirstChild->MoveTo(kidRect.x, kidYTop);
}
/** helper method to get the row span of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetRowSpan()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetRowSpan();
}
return result;
}
/** helper method to get the col span of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetColSpan()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetColSpan();
}
return result;
}
/** helper method to get the col index of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetColIndex()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetColIndex();
}
return result;
}
void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext)
{
// Do we have a prev-in-flow?
@ -583,7 +554,7 @@ void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
{
nsHTMLValue value;
((nsTableCell*)mContent)->GetAttribute(nsHTMLAtoms::align, value);
((nsHTMLTagContent*)mContent)->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
nsStyleText* text = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);

View File

@ -20,7 +20,6 @@
#include "nscore.h"
#include "nsContainerFrame.h"
#include "nsTableCell.h"
#include "nsTableFrame.h"
struct nsStyleSpacing;
@ -34,6 +33,9 @@ struct nsStyleSpacing;
class nsTableCellFrame : public nsContainerFrame
{
public:
void Init(PRInt32 aRowSpan, PRInt32 aColSpan, PRInt32 aColIndex);
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent);
@ -93,7 +95,37 @@ protected:
void MapBorderMarginPadding(nsIPresContext* aPresContext);
void MapHTMLBorderStyle(nsIPresContext* aPresContext,nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
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;
};
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;}
inline PRInt32 nsTableCellFrame::GetColSpan()
{ return mColSpan;}
inline PRInt32 nsTableCellFrame::GetColIndex()
{ return mColIndex;}
#endif

View File

@ -46,6 +46,8 @@ static nsIAtom *HACKattribute=nsnull;
nsTableColFrame::nsTableColFrame(nsIContent* aContent, nsIFrame* aParentFrame)
: nsFrame(aContent, aParentFrame)
{
mColIndex = 0;
mRepeat = 0;
}
@ -80,14 +82,6 @@ NS_METHOD nsTableColFrame::Reflow(nsIPresContext* aPresContext,
return NS_OK;
}
PRInt32 nsTableColFrame::GetColumnIndex()
{
if (nsnull!=mContent)
return ((nsTableCol *)mContent)->GetColumnIndex();
else
return 0;
}
/* ----- static methods ------ */
@ -203,6 +197,8 @@ void nsTableCol::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
}
return;
}
// unknown attributes are handled by my parent
nsTableContent::SetAttribute(aAttribute, aValue);
}
void nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
@ -267,6 +263,7 @@ nsTableCol::CreateFrame(nsIPresContext* aPresContext,
if (NS_OK != rv) {
return rv;
}
((nsTableColFrame*)frame)->Init(mColIndex, mRepeat);
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;

View File

@ -24,6 +24,9 @@
class nsTableColFrame : public nsFrame {
public:
void Init(PRInt32 aColIndex, PRInt32 aRepeat);
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent);
@ -37,16 +40,41 @@ public:
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** return the index of the column this content object represents. always >= 0 */
/** return the index of the column the col represents. always >= 0 */
virtual int GetColumnIndex ();
/** return the number of the columns the col represents. always >= 0 */
virtual int GetRepeat ();
protected:
nsTableColFrame(nsIContent* aContent, nsIFrame* aParentFrame);
~nsTableColFrame();
/** the starting index of the column (starting at 0) that this col object represents */
PRInt32 mColIndex;
/** the number of columns that the attributes of this column extend to */
PRInt32 mRepeat;
};
inline void nsTableColFrame::Init(PRInt32 aColIndex, PRInt32 aRepeat)
{
NS_ASSERTION(0<=aColIndex, "bad col index param");
NS_ASSERTION(0<=aRepeat, "bad repeat param");
mColIndex = aColIndex;
mRepeat = aRepeat;
}
inline nsTableColFrame::GetColumnIndex()
{ return mColIndex; }
inline nsTableColFrame::GetRepeat()
{ return mRepeat; }
#endif

View File

@ -321,6 +321,7 @@ nsTableRow::CreateFrame(nsIPresContext* aPresContext,
if (NS_OK != rv) {
return rv;
}
((nsTableRowFrame*)frame)->Init(mRowIndex);
frame->SetStyleContext(aPresContext, aStyleContext);
aResult = frame;
return rv;

View File

@ -1159,8 +1159,7 @@ nsTableRowFrame::SetColumnStyleFromCell(nsIPresContext* aPresContext,
// also acts as the width attribute for the entire column
if ((nsnull!=aCellSC) && (nsnull!=aCellFrame))
{
PRInt32 rowIndex = ((nsTableRow*)mContent)->GetRowIndex();
if (0==rowIndex)
if (0==mRowIndex)
{
// get the cell style info
const nsStylePosition* cellPosition = (const nsStylePosition*) aCellSC->GetStyleData(eStyleStruct_Position);

View File

@ -40,6 +40,8 @@ struct RowReflowState;
class nsTableRowFrame : public nsContainerFrame
{
public:
/** Initialization procedure */
void Init(PRInt32 aRowIndex);
/** instantiate a new instance of nsTableRowFrame.
* @param aInstancePtrResult the new object is returned in this out-param
@ -166,9 +168,18 @@ protected:
nsIStyleContext * aCellSC);
private:
PRInt32 mRowIndex;
nscoord mTallestCell; // not my height, but the height of my tallest child
nscoord mCellMaxTopMargin;
nscoord mCellMaxBottomMargin;
};
inline void nsTableRowFrame::Init(PRInt32 aRowIndex)
{
NS_ASSERTION(0<=aRowIndex, "bad param row index");
mRowIndex = aRowIndex;
}
#endif

View File

@ -30,7 +30,6 @@
#include "nsHTMLIIDs.h"
NS_DEF_PTR(nsTableCol);
NS_DEF_PTR(nsTableCell);
NS_DEF_PTR(nsIStyleContext);

View File

@ -26,10 +26,14 @@
#include "nsIContent.h"
#include "nsIContentDelegate.h"
#include "nsCSSLayout.h"
#include "nsHTMLValue.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLIIDs.h"
#include "nsIPtr.h"
#include "nsIView.h"
// evil dep's to be removed ASAP
#include "nsTablePart.h"
#include "nsTableContent.h"
NS_DEF_PTR(nsIStyleContext);
@ -47,6 +51,9 @@ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent,
nsIFrame* aParentFrame)
: nsContainerFrame(aContent, aParentFrame)
{
mRowSpan=1;
mColSpan=1;
mColIndex=0;
}
nsTableCellFrame::~nsTableCellFrame()
@ -145,42 +152,6 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext)
mFirstChild->MoveTo(kidRect.x, kidYTop);
}
/** helper method to get the row span of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetRowSpan()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetRowSpan();
}
return result;
}
/** helper method to get the col span of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetColSpan()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetColSpan();
}
return result;
}
/** helper method to get the col index of this frame's content (which must be a cell) */
PRInt32 nsTableCellFrame::GetColIndex()
{
PRInt32 result = 0;
nsTableCell *cellContent = (nsTableCell *)mContent;
if (nsnull!=cellContent)
{
result = cellContent->GetColIndex();
}
return result;
}
void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext)
{
// Do we have a prev-in-flow?
@ -583,7 +554,7 @@ void nsTableCellFrame::MapTextAttributes(nsIPresContext* aPresContext)
{
nsHTMLValue value;
((nsTableCell*)mContent)->GetAttribute(nsHTMLAtoms::align, value);
((nsHTMLTagContent*)mContent)->GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
nsStyleText* text = (nsStyleText*)mStyleContext->GetMutableStyleData(eStyleStruct_Text);

View File

@ -20,7 +20,6 @@
#include "nscore.h"
#include "nsContainerFrame.h"
#include "nsTableCell.h"
#include "nsTableFrame.h"
struct nsStyleSpacing;
@ -34,6 +33,9 @@ struct nsStyleSpacing;
class nsTableCellFrame : public nsContainerFrame
{
public:
void Init(PRInt32 aRowSpan, PRInt32 aColSpan, PRInt32 aColIndex);
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent);
@ -93,7 +95,37 @@ protected:
void MapBorderMarginPadding(nsIPresContext* aPresContext);
void MapHTMLBorderStyle(nsIPresContext* aPresContext,nsStyleSpacing& aSpacingStyle, nscoord aBorderWidth);
PRBool ConvertToPixelValue(nsHTMLValue& aValue, PRInt32 aDefault, PRInt32& aResult);
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;
};
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;}
inline PRInt32 nsTableCellFrame::GetColSpan()
{ return mColSpan;}
inline PRInt32 nsTableCellFrame::GetColIndex()
{ return mColIndex;}
#endif

View File

@ -24,6 +24,9 @@
class nsTableColFrame : public nsFrame {
public:
void Init(PRInt32 aColIndex, PRInt32 aRepeat);
static nsresult NewFrame(nsIFrame** aInstancePtrResult,
nsIContent* aContent,
nsIFrame* aParent);
@ -37,16 +40,41 @@ public:
const nsReflowState& aReflowState,
nsReflowStatus& aStatus);
/** return the index of the column this content object represents. always >= 0 */
/** return the index of the column the col represents. always >= 0 */
virtual int GetColumnIndex ();
/** return the number of the columns the col represents. always >= 0 */
virtual int GetRepeat ();
protected:
nsTableColFrame(nsIContent* aContent, nsIFrame* aParentFrame);
~nsTableColFrame();
/** the starting index of the column (starting at 0) that this col object represents */
PRInt32 mColIndex;
/** the number of columns that the attributes of this column extend to */
PRInt32 mRepeat;
};
inline void nsTableColFrame::Init(PRInt32 aColIndex, PRInt32 aRepeat)
{
NS_ASSERTION(0<=aColIndex, "bad col index param");
NS_ASSERTION(0<=aRepeat, "bad repeat param");
mColIndex = aColIndex;
mRepeat = aRepeat;
}
inline nsTableColFrame::GetColumnIndex()
{ return mColIndex; }
inline nsTableColFrame::GetRepeat()
{ return mRepeat; }
#endif

View File

@ -1159,8 +1159,7 @@ nsTableRowFrame::SetColumnStyleFromCell(nsIPresContext* aPresContext,
// also acts as the width attribute for the entire column
if ((nsnull!=aCellSC) && (nsnull!=aCellFrame))
{
PRInt32 rowIndex = ((nsTableRow*)mContent)->GetRowIndex();
if (0==rowIndex)
if (0==mRowIndex)
{
// get the cell style info
const nsStylePosition* cellPosition = (const nsStylePosition*) aCellSC->GetStyleData(eStyleStruct_Position);

View File

@ -40,6 +40,8 @@ struct RowReflowState;
class nsTableRowFrame : public nsContainerFrame
{
public:
/** Initialization procedure */
void Init(PRInt32 aRowIndex);
/** instantiate a new instance of nsTableRowFrame.
* @param aInstancePtrResult the new object is returned in this out-param
@ -166,9 +168,18 @@ protected:
nsIStyleContext * aCellSC);
private:
PRInt32 mRowIndex;
nscoord mTallestCell; // not my height, but the height of my tallest child
nscoord mCellMaxTopMargin;
nscoord mCellMaxBottomMargin;
};
inline void nsTableRowFrame::Init(PRInt32 aRowIndex)
{
NS_ASSERTION(0<=aRowIndex, "bad param row index");
mRowIndex = aRowIndex;
}
#endif