most HTML 4 attributes supported (though some are still ignored)

lots of methods made inline
This commit is contained in:
buster 1998-06-08 19:57:04 +00:00
parent 50871e6493
commit 469b205bb3
25 changed files with 495 additions and 301 deletions

View File

@ -106,6 +106,7 @@ nsIAtom* nsHTMLAtoms::pre;
nsIAtom* nsHTMLAtoms::prompt;
nsIAtom* nsHTMLAtoms::readonly;
nsIAtom* nsHTMLAtoms::rel;
nsIAtom* nsHTMLAtoms::repeat;
nsIAtom* nsHTMLAtoms::rightpadding;
nsIAtom* nsHTMLAtoms::rootContentPseudo;
nsIAtom* nsHTMLAtoms::rows;
@ -235,6 +236,7 @@ void nsHTMLAtoms::AddrefAtoms()
prompt = NS_NewAtom("PROMPT");
readonly = NS_NewAtom("READONLY");
rel = NS_NewAtom("REL");
repeat = NS_NewAtom("REPEAT");
rightpadding = NS_NewAtom("RIGHTPADDING");
rootContentPseudo = NS_NewAtom(":ROOT-CONTENT");
rows = NS_NewAtom("ROWS");
@ -365,6 +367,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(prompt);
NS_RELEASE(readonly);
NS_RELEASE(rel);
NS_RELEASE(repeat);
NS_RELEASE(rightpadding);
NS_RELEASE(rootContentPseudo);
NS_RELEASE(rows);

View File

@ -136,6 +136,7 @@ public:
static nsIAtom* readonly;
static nsIAtom* rel;
static nsIAtom* repeat;
static nsIAtom* rightpadding;
static nsIAtom* rootContentPseudo;
static nsIAtom* rows;

View File

@ -136,6 +136,7 @@ public:
static nsIAtom* readonly;
static nsIAtom* rel;
static nsIAtom* repeat;
static nsIAtom* rightpadding;
static nsIAtom* rootContentPseudo;
static nsIAtom* rows;

View File

@ -106,6 +106,7 @@ nsIAtom* nsHTMLAtoms::pre;
nsIAtom* nsHTMLAtoms::prompt;
nsIAtom* nsHTMLAtoms::readonly;
nsIAtom* nsHTMLAtoms::rel;
nsIAtom* nsHTMLAtoms::repeat;
nsIAtom* nsHTMLAtoms::rightpadding;
nsIAtom* nsHTMLAtoms::rootContentPseudo;
nsIAtom* nsHTMLAtoms::rows;
@ -235,6 +236,7 @@ void nsHTMLAtoms::AddrefAtoms()
prompt = NS_NewAtom("PROMPT");
readonly = NS_NewAtom("READONLY");
rel = NS_NewAtom("REL");
repeat = NS_NewAtom("REPEAT");
rightpadding = NS_NewAtom("RIGHTPADDING");
rootContentPseudo = NS_NewAtom(":ROOT-CONTENT");
rows = NS_NewAtom("ROWS");
@ -365,6 +367,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(prompt);
NS_RELEASE(readonly);
NS_RELEASE(rel);
NS_RELEASE(repeat);
NS_RELEASE(rightpadding);
NS_RELEASE(rootContentPseudo);
NS_RELEASE(rows);

View File

@ -106,6 +106,7 @@ nsIAtom* nsHTMLAtoms::pre;
nsIAtom* nsHTMLAtoms::prompt;
nsIAtom* nsHTMLAtoms::readonly;
nsIAtom* nsHTMLAtoms::rel;
nsIAtom* nsHTMLAtoms::repeat;
nsIAtom* nsHTMLAtoms::rightpadding;
nsIAtom* nsHTMLAtoms::rootContentPseudo;
nsIAtom* nsHTMLAtoms::rows;
@ -235,6 +236,7 @@ void nsHTMLAtoms::AddrefAtoms()
prompt = NS_NewAtom("PROMPT");
readonly = NS_NewAtom("READONLY");
rel = NS_NewAtom("REL");
repeat = NS_NewAtom("REPEAT");
rightpadding = NS_NewAtom("RIGHTPADDING");
rootContentPseudo = NS_NewAtom(":ROOT-CONTENT");
rows = NS_NewAtom("ROWS");
@ -365,6 +367,7 @@ void nsHTMLAtoms::ReleaseAtoms()
NS_RELEASE(prompt);
NS_RELEASE(readonly);
NS_RELEASE(rel);
NS_RELEASE(repeat);
NS_RELEASE(rightpadding);
NS_RELEASE(rootContentPseudo);
NS_RELEASE(rows);

View File

@ -136,6 +136,7 @@ public:
static nsIAtom* readonly;
static nsIAtom* rel;
static nsIAtom* repeat;
static nsIAtom* rightpadding;
static nsIAtom* rootContentPseudo;
static nsIAtom* rows;

View File

@ -703,6 +703,8 @@ PRBool nsHTMLTagContent::DivAlignParamToString(const nsHTMLValue& aValue,
return EnumValueToString(aValue, kDivAlignTable, aResult);
}
/* ----- table specific attribute code ----- */
static nsHTMLTagContent::EnumTable kTableAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
@ -722,6 +724,30 @@ PRBool nsHTMLTagContent::TableAlignParamToString(const nsHTMLValue& aValue,
return EnumValueToString(aValue, kTableAlignTable, aResult);
}
static nsHTMLTagContent::EnumTable kTableCaptionAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "top", NS_STYLE_VERTICAL_ALIGN_TOP},
{ "bottom",NS_STYLE_VERTICAL_ALIGN_BOTTOM},
{ 0 }
};
PRBool nsHTMLTagContent::ParseTableCaptionAlignParam(const nsString& aString,
nsHTMLValue& aResult)
{
return ParseEnumValue(aString, kTableCaptionAlignTable, aResult);
}
PRBool nsHTMLTagContent::TableCaptionAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult)
{
return EnumValueToString(aValue, kTableCaptionAlignTable, aResult);
}
/* ----- end table specific attribute code ----- */
void
nsHTMLTagContent::ParseValueOrPercent(const nsString& aString,
nsHTMLValue& aResult,

View File

@ -188,10 +188,23 @@ public:
static PRBool DivAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult);
/** HTML4 table align attributes
*/
static PRBool ParseTableAlignParam(const nsString& aString, nsHTMLValue& aRes);
/** HTML4 table align attributes
*/
static PRBool TableAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult);
/** HTML4 table caption align attributes
*/
static PRBool ParseTableCaptionAlignParam(const nsString& aString, nsHTMLValue& aRes);
/** HTML4 table caption align attributes
*/
static PRBool TableCaptionAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult);
protected:
nsHTMLTagContent();

View File

@ -53,30 +53,6 @@ nsCellLayoutData::~nsCellLayoutData()
mColLayoutData = nsnull;
}
nsTableCellFrame * nsCellLayoutData::GetCellFrame()
{ return mCellFrame; }
void nsCellLayoutData::SetCellFrame(nsTableCellFrame * aCellFrame)
{ mCellFrame = aCellFrame; }
nsReflowMetrics * nsCellLayoutData::GetDesiredSize()
{ return &mDesiredSize; }
void nsCellLayoutData::SetDesiredSize(nsReflowMetrics * aDesiredSize)
{
if (nsnull!=aDesiredSize)
mDesiredSize = *aDesiredSize;
}
nsSize * nsCellLayoutData::GetMaxElementSize()
{ return &mMaxElementSize; }
void nsCellLayoutData::SetMaxElementSize(nsSize * aMaxElementSize)
{
if (nsnull!=aMaxElementSize)
mMaxElementSize = *aMaxElementSize;
}
/**
* Get the style context for this object (determined, by
* asking for the frame
@ -92,10 +68,6 @@ nsIStyleContext* nsCellLayoutData::GetStyleContext()
return nsnull;
}
/**
* Given a list of nsCellLayoutData and a index, get the style context for
* that element in the list
@ -479,21 +451,11 @@ nsIFrame* nsCellLayoutData::FindBorderFrame(nsTableFrame* aTableFrame,
}
void nsCellLayoutData::CalculateBorders(nsTableFrame* aTableFrame,
nsVoidArray* aBoundaryCells[4])
{
for (PRInt32 edge = 0; edge < 4; edge++)
mBorderFrame[edge] = FindBorderFrame(aTableFrame, aBoundaryCells[edge], edge);
}
/**
* Given a List of cell layout data, compare the edges to see which has the
* border with the highest precidence.
*
**/
nscoord nsCellLayoutData::FindLargestMargin(nsVoidArray* aList,PRUint8 aEdge)
{
nscoord result = 0;
@ -557,25 +519,11 @@ void nsCellLayoutData::RecalcLayoutData(nsTableFrame* aTableFrame,
nsVoidArray* aBoundaryCells[4])
{
CalculateBorders(aTableFrame, aBoundaryCells);
CalculateMargins(aTableFrame, aBoundaryCells);
mCalculated = NS_OK;
}
NS_METHOD nsCellLayoutData::GetMargin(nsMargin& aMargin)
{
if (mCalculated == NS_OK)
{
aMargin = mMargin;
return NS_OK;
}
return NS_ERROR_NOT_INITIALIZED;
}
void nsCellLayoutData::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 indent;

View File

@ -151,4 +151,46 @@ private:
nsIFrame* mBorderFrame[4]; // the frame whose border is used
};
inline nsTableCellFrame * nsCellLayoutData::GetCellFrame()
{ return mCellFrame; }
inline void nsCellLayoutData::SetCellFrame(nsTableCellFrame * aCellFrame)
{ mCellFrame = aCellFrame; }
inline nsReflowMetrics * nsCellLayoutData::GetDesiredSize()
{ return &mDesiredSize; }
inline void nsCellLayoutData::SetDesiredSize(nsReflowMetrics * aDesiredSize)
{
if (nsnull!=aDesiredSize)
mDesiredSize = *aDesiredSize;
}
inline nsSize * nsCellLayoutData::GetMaxElementSize()
{ return &mMaxElementSize; }
inline void nsCellLayoutData::SetMaxElementSize(nsSize * aMaxElementSize)
{
if (nsnull!=aMaxElementSize)
mMaxElementSize = *aMaxElementSize;
}
inline void nsCellLayoutData::CalculateBorders(nsTableFrame* aTableFrame,
nsVoidArray* aBoundaryCells[4])
{
for (PRInt32 edge = 0; edge < 4; edge++)
mBorderFrame[edge] = FindBorderFrame(aTableFrame, aBoundaryCells[edge], edge);
}
inline NS_METHOD nsCellLayoutData::GetMargin(nsMargin& aMargin)
{
if (mCalculated == NS_OK)
{
aMargin = mMargin;
return NS_OK;
}
return NS_ERROR_NOT_INITIALIZED;
}
#endif

View File

@ -87,40 +87,6 @@ void nsCellMap::GrowTo(int aColCount)
mColCount = aColCount;
}
CellData * nsCellMap::GetCellAt(int aRow, int aColumn) const
{
int index = (aRow*mColCount)+aColumn;
if (gsDebug1==PR_TRUE)
{
printf("GetCellAt [%d, %d] returning %d\n", aRow, aColumn, mCells[index]);
}
return (CellData *)mCells[index];
}
void nsCellMap::SetCellAt(CellData *aCell, int aRow, int aColumn)
{
//Assert aRow, aColumn
int index = (aRow*mColCount)+aColumn;
CellData* cell = GetCellAt(aRow,aColumn);
if (cell != nsnull)
delete cell;
mCells[index] = (PRInt32)aCell;
if (gsDebug1==PR_TRUE)
{
printf("SetCellAt [%d, %d] setting %d\n", aRow, aColumn, aCell);
}
}
int nsCellMap::GetColCount() const
{
return mColCount;
}
int nsCellMap::GetRowCount() const
{
return mRowCount;
}
void nsCellMap::DumpCellMap() const
{
if (gsDebug1==PR_TRUE)

View File

@ -76,4 +76,30 @@ public:
};
inline CellData * nsCellMap::GetCellAt(int aRow, int aColumn) const
{
int index = (aRow*mColCount)+aColumn;
return (CellData *)mCells[index];
}
inline void nsCellMap::SetCellAt(CellData *aCell, int aRow, int aColumn)
{
//Assert aRow, aColumn
int index = (aRow*mColCount)+aColumn;
CellData* cell = GetCellAt(aRow,aColumn);
if (cell != nsnull)
delete cell;
mCells[index] = (PRInt32)aCell;
}
inline int nsCellMap::GetColCount() const
{
return mColCount;
}
inline int nsCellMap::GetRowCount() const
{
return mRowCount;
}
#endif

View File

@ -42,61 +42,6 @@ nsColLayoutData::~nsColLayoutData()
mCells = 0;
}
nsTableCol * nsColLayoutData::GetCol()
{
NS_IF_ADDREF(mCol);
return mCol;
};
void nsColLayoutData::SetCol(nsTableCol * aCol)
{
if (aCol != mCol)
{
NS_IF_ADDREF(aCol);
NS_IF_RELEASE(mCol);
mCol = aCol;
}
}
nsTableColFrame * nsColLayoutData::GetColFrame()
{
return mColFrame;
}
void nsColLayoutData::SetColFrame(nsTableColFrame *aColFrame)
{
mColFrame = aColFrame;
}
nsCellLayoutData* nsColLayoutData::ElementAt(PRInt32 aIndex) const
{
return (nsCellLayoutData*)mCells->ElementAt(aIndex);
}
PRBool nsColLayoutData::AppendElement(nsCellLayoutData* aCellLayoutData)
{
return mCells->AppendElement((void*)aCellLayoutData);
}
PRBool nsColLayoutData::ReplaceElementAt(nsCellLayoutData* aCellLayoutData, PRInt32 aIndex)
{
return mCells->ReplaceElementAt((void*)aCellLayoutData,aIndex);
}
nsVoidArray * nsColLayoutData::GetCells()
{ return mCells; }
PRInt32 nsColLayoutData::Count() const
{ return mCells->Count(); }
PRInt32 nsColLayoutData::IndexOf(nsCellLayoutData* aCellLayoutData) const
{
return mCells->IndexOf((void*)aCellLayoutData);
}
PRInt32 nsColLayoutData::IndexOf(nsTableCell* aTableCell) const
{
PRInt32 count = this->Count();

View File

@ -77,4 +77,50 @@ private:
};
/* ---------- inlines ---------- */
inline nsTableCol * nsColLayoutData::GetCol()
{
NS_IF_ADDREF(mCol);
return mCol;
};
inline void nsColLayoutData::SetCol(nsTableCol * aCol)
{
if (aCol != mCol)
{
NS_IF_ADDREF(aCol);
NS_IF_RELEASE(mCol);
mCol = aCol;
}
}
inline nsTableColFrame * nsColLayoutData::GetColFrame()
{ return mColFrame;}
inline void nsColLayoutData::SetColFrame(nsTableColFrame *aColFrame)
{ mColFrame = aColFrame;}
inline nsCellLayoutData* nsColLayoutData::ElementAt(PRInt32 aIndex) const
{ return (nsCellLayoutData*)mCells->ElementAt(aIndex);}
inline PRBool nsColLayoutData::AppendElement(nsCellLayoutData* aCellLayoutData)
{ return mCells->AppendElement((void*)aCellLayoutData);}
inline PRBool nsColLayoutData::ReplaceElementAt(nsCellLayoutData* aCellLayoutData, PRInt32 aIndex)
{ return mCells->ReplaceElementAt((void*)aCellLayoutData,aIndex);}
inline nsVoidArray * nsColLayoutData::GetCells()
{ return mCells; }
inline PRInt32 nsColLayoutData::Count() const
{ return mCells->Count(); }
inline PRInt32 nsColLayoutData::IndexOf(nsCellLayoutData* aCellLayoutData) const
{ return mCells->IndexOf((void*)aCellLayoutData);}
#endif

View File

@ -82,7 +82,7 @@ void nsTableCaption::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
nsHTMLValue val;
if (aAttribute == nsHTMLAtoms::align) {
if (ParseAlignParam(aValue, val)) {
if (ParseTableCaptionAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
return;
@ -102,9 +102,24 @@ void nsTableCaption::MapAttributesInto(nsIStyleContext* aContext,
if (value.GetUnit() != eHTMLUnit_Null) {
NS_ASSERTION(value.GetUnit() == eHTMLUnit_Enumerated, "unexpected unit");
nsStyleText* captionStyle =
(nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
captionStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
PRUint8 alignValue = value.GetIntValue();
// this code relies on top, bottom, left, and right all being unique values
if (NS_STYLE_VERTICAL_ALIGN_BOTTOM==alignValue ||
NS_STYLE_VERTICAL_ALIGN_TOP==alignValue)
{
nsStyleText* textStyle =
(nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(alignValue, eStyleUnit_Enumerated);
}
// XXX: this isn't the right place to put this attribute! probably on the float guy
// talk to Peter and Troy
else if (NS_STYLE_TEXT_ALIGN_LEFT==alignValue ||
NS_STYLE_TEXT_ALIGN_RIGHT==alignValue)
{
nsStyleText* textStyle =
(nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = alignValue;
}
}
}

View File

@ -241,11 +241,11 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
if (nsnull!=mRow)
{
// TODO: optimize by putting a flag on the row to say whether valign attr is set
nsHTMLValue rowAlignValue;
mRow->GetAttribute(nsHTMLAtoms::valign, rowAlignValue);
if (rowAlignValue.GetUnit() == eHTMLUnit_Enumerated)
nsHTMLValue parentAlignValue;
mRow->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
{
PRUint8 rowVAlign = rowAlignValue.GetIntValue();
PRUint8 rowVAlign = parentAlignValue.GetIntValue();
if (NS_STYLE_VERTICAL_ALIGN_MIDDLE!=rowVAlign)
{
if (nsnull==textStyle)
@ -253,6 +253,24 @@ void nsTableCell::MapAttributesInto(nsIStyleContext* aContext,
textStyle->mVerticalAlign.SetIntValue(rowVAlign, eStyleUnit_Enumerated);
}
}
else
{ // we need to check the row group as well
nsTableRowGroup *rowGroup = mRow->GetRowGroup();
if (nsnull!=rowGroup)
{
rowGroup->GetAttribute(nsHTMLAtoms::valign, parentAlignValue);
if (parentAlignValue.GetUnit() == eHTMLUnit_Enumerated)
{
PRUint8 rowGroupVAlign = parentAlignValue.GetIntValue();
if (NS_STYLE_VERTICAL_ALIGN_MIDDLE!=rowGroupVAlign)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(rowGroupVAlign, eStyleUnit_Enumerated);
}
}
}
}
}
}

View File

@ -27,6 +27,7 @@
#include "nsStyleConsts.h"
#include "nsIPresContext.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -173,53 +174,84 @@ nsrefcnt nsTableCol::Release(void)
return mRefCnt;
}
// TODO: what about proportional width values (0*, 1*, etc.) down in COL tag
// TODO: need a ::SetAttribute hook for width
int nsTableCol::GetType()
void nsTableCol::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
return nsITableContent::kTableColType;
nsHTMLValue val;
if (aAttribute == nsHTMLAtoms::width)
{
ParseValueOrPercentOrProportional(aValue, val, eHTMLUnit_Pixel);
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
else if ( aAttribute == nsHTMLAtoms::repeat)
{
ParseValue(aValue, 0, val, eHTMLUnit_Integer);
nsHTMLTagContent::SetAttribute(aAttribute, val);
SetRepeat(val.GetIntValue());
}
else if (aAttribute == nsHTMLAtoms::align) {
nsHTMLValue val;
if (ParseTableAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
return;
}
else if (aAttribute == nsHTMLAtoms::valign) {
nsHTMLValue val;
if (ParseTableAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
return;
}
}
int nsTableCol::GetRepeat ()
void nsTableCol::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
if (0 < mRepeat)
return mRepeat;
return 1;
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
if (nsnull != mAttributes) {
float p2t;
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// width
GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
switch (value.GetUnit()) {
case eHTMLUnit_Percent:
position->mWidth.SetPercentValue(value.GetPercentValue());
break;
case eHTMLUnit_Pixel:
p2t = aPresContext->GetPixelsToTwips();
position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue()));
break;
}
}
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = value.GetIntValue();
}
// valign: enum
GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
}
nsTableColGroup * nsTableCol::GetColGroup ()
{
NS_IF_ADDREF(mColGroup);
return mColGroup;
}
void nsTableCol::SetColGroup (nsTableColGroup * aColGroup)
{
mColGroup = aColGroup;
}
int nsTableCol::GetColumnIndex ()
{
return mColIndex;
}
void nsTableCol::SetColumnIndex (int aColIndex)
{
mColIndex = aColIndex;
}
void nsTableCol::SetRepeat (int aRepeat)
{
mRepeat = aRepeat;
ResetColumns ();
}
void nsTableCol::ResetColumns ()
{
if (nsnull != mColGroup)
mColGroup->ResetColumns ();
}
nsresult

View File

@ -75,6 +75,11 @@ public:
/** returns nsITableContent::kTableCellType */
virtual int GetType();
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
/** @see nsIHTMLContent::CreateFrame */
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
@ -111,6 +116,46 @@ private:
};
/* ---------- inlines ---------- */
inline int nsTableCol::GetType()
{ return nsITableContent::kTableColType;}
inline int nsTableCol::GetRepeat ()
{
if (0 < mRepeat)
return mRepeat;
return 1;
}
inline nsTableColGroup * nsTableCol::GetColGroup ()
{
NS_IF_ADDREF(mColGroup);
return mColGroup;
}
inline void nsTableCol::SetColGroup (nsTableColGroup * aColGroup)
{ mColGroup = aColGroup;}
inline int nsTableCol::GetColumnIndex ()
{ return mColIndex;}
inline void nsTableCol::SetColumnIndex (int aColIndex)
{ mColIndex = aColIndex;}
inline void nsTableCol::SetRepeat (int aRepeat)
{
mRepeat = aRepeat;
ResetColumns ();
}
inline void nsTableCol::ResetColumns ()
{
if (nsnull != mColGroup)
mColGroup->ResetColumns ();
}
#endif

View File

@ -106,45 +106,6 @@ nsrefcnt nsTableColGroup::Release(void)
return mRefCnt;
}
int nsTableColGroup::GetType()
{
return nsITableContent::kTableColGroupType;
}
int nsTableColGroup::GetSpan ()
{
if (0 < mSpan)
return mSpan;
return 1;
}
int nsTableColGroup::GetStartColumnIndex ()
{
return mStartColIndex;
}
void nsTableColGroup::SetStartColumnIndex (int aIndex)
{
if (aIndex != mStartColIndex)
mColCount = 0; // our index is being changed, trigger reset of col indicies, don't propogate back to table
mStartColIndex = aIndex;
}
void nsTableColGroup::SetSpan (int aSpan)
{
mSpan = aSpan;
if (0 < ChildCount ()) // span is only relevant if we don't have children
ResetColumns ();
}
void nsTableColGroup::ResetColumns ()
{
mColCount = 0;
if (nsnull != mTable)
mTable->ResetColumns ();
}
/** returns the number of columns represented by this group.
* if there are col children, count them (taking into account the span of each)
* else, check my own span attribute.
@ -338,6 +299,7 @@ void nsTableColGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
ParseValue(aValue, 0, val, eHTMLUnit_Integer);
nsHTMLTagContent::SetAttribute(aAttribute, val);
SetSpan(val.GetIntValue());
}
else if (aAttribute == nsHTMLAtoms::align) {
nsHTMLValue val;
@ -360,41 +322,44 @@ void nsTableColGroup::MapAttributesInto(nsIStyleContext* aContext,
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
if (nsnull != mAttributes) {
float p2t;
nsHTMLValue value;
float p2t;
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// width
GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
switch (value.GetUnit()) {
case eHTMLUnit_Percent:
position->mWidth.SetPercentValue(value.GetPercentValue());
break;
// width
GetAttribute(nsHTMLAtoms::width, value);
if (value.GetUnit() != eHTMLUnit_Null) {
nsStylePosition* position = (nsStylePosition*)
aContext->GetMutableStyleData(eStyleStruct_Position);
switch (value.GetUnit()) {
case eHTMLUnit_Percent:
position->mWidth.SetPercentValue(value.GetPercentValue());
break;
case eHTMLUnit_Pixel:
p2t = aPresContext->GetPixelsToTwips();
position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue()));
break;
case eHTMLUnit_Pixel:
p2t = aPresContext->GetPixelsToTwips();
position->mWidth.SetCoordValue(nscoord(p2t * (float)value.GetPixelValue()));
break;
}
}
}
// align
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() != eHTMLUnit_Null) {
NS_ASSERTION(value.GetUnit() == eHTMLUnit_Enumerated, "unexpected unit");
nsStyleDisplay* display = (nsStyleDisplay*)aContext->GetMutableStyleData(eStyleStruct_Display);
switch (value.GetIntValue()) {
case NS_STYLE_TEXT_ALIGN_LEFT:
display->mFloats = NS_STYLE_FLOAT_LEFT;
break;
case NS_STYLE_TEXT_ALIGN_RIGHT:
display->mFloats = NS_STYLE_FLOAT_RIGHT;
break;
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = value.GetIntValue();
}
// valign: enum
GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
}

View File

@ -145,6 +145,44 @@ public:
NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify);
};
/* ---------- inlines ---------- */
inline int nsTableColGroup::GetType()
{ return nsITableContent::kTableColGroupType;}
inline int nsTableColGroup::GetSpan ()
{
if (0 < mSpan)
return mSpan;
return 1;
}
inline int nsTableColGroup::GetStartColumnIndex ()
{ return mStartColIndex;}
inline void nsTableColGroup::SetStartColumnIndex (int aIndex)
{
if (aIndex != mStartColIndex)
mColCount = 0; // our index is being changed, trigger reset of col indicies, don't propogate back to table
mStartColIndex = aIndex;
}
inline void nsTableColGroup::SetSpan (int aSpan)
{
mSpan = aSpan;
if (0 < ChildCount ()) // span is only relevant if we don't have children
ResetColumns ();
}
inline void nsTableColGroup::ResetColumns ()
{
mColCount = 0;
if (nsnull != mTable)
mTable->ResetColumns ();
}
#endif

View File

@ -259,6 +259,11 @@ void nsTableRow::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
NS_PRECONDITION(nsnull!=aAttribute, "bad attribute arg");
nsHTMLValue val;
if (aAttribute == nsHTMLAtoms::bgcolor) {
ParseColor(aValue, val);
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
if ((aAttribute == nsHTMLAtoms::align) &&
ParseDivAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
@ -296,6 +301,9 @@ void nsTableRow::MapAttributesInto(nsIStyleContext* aContext,
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
//background: color
MapBackgroundAttributesInto(aContext, aPresContext);
}
}

View File

@ -30,6 +30,7 @@
#include "nsIPresContext.h"
#include "nsIDocument.h"
#include "nsHTMLIIDs.h"
#include "nsHTMLAtoms.h"
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -122,6 +123,50 @@ nsrefcnt nsTableRowGroup::Release(void)
return mRefCnt;
}
void nsTableRowGroup::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
{
NS_PRECONDITION(nsnull!=aAttribute, "bad attribute arg");
nsHTMLValue val;
if ((aAttribute == nsHTMLAtoms::align) &&
ParseDivAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
if ((aAttribute == nsHTMLAtoms::valign) &&
ParseAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
}
void nsTableRowGroup::MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext)
{
NS_PRECONDITION(nsnull!=aContext, "bad style context arg");
NS_PRECONDITION(nsnull!=aPresContext, "bad presentation context arg");
if (nsnull != mAttributes) {
nsHTMLValue value;
nsStyleText* textStyle = nsnull;
// align: enum
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mTextAlign = value.GetIntValue();
}
// valign: enum
GetAttribute(nsHTMLAtoms::valign, value);
if (value.GetUnit() == eHTMLUnit_Enumerated)
{
if (nsnull==textStyle)
textStyle = (nsStyleText*)aContext->GetMutableStyleData(eStyleStruct_Text);
textStyle->mVerticalAlign.SetIntValue(value.GetIntValue(), eStyleUnit_Enumerated);
}
}
}
nsresult
nsTableRowGroup::CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,

View File

@ -62,6 +62,12 @@ public:
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue);
virtual void MapAttributesInto(nsIStyleContext* aContext,
nsIPresContext* aPresContext);
/** @see nsIHTMLContent::CreateFrame */
virtual nsresult CreateFrame(nsIPresContext* aPresContext,
nsIFrame* aParentFrame,
@ -69,16 +75,10 @@ public:
nsIFrame*& aResult);
/** return the number of contained rows */
virtual int GetRowCount ()
{
return ChildCount ();
};
int GetRowCount ();
/** returns nsITableContent::kTableRowGroupType */
virtual int GetType()
{
return nsITableContent::kTableRowGroupType;
};
int GetType();
/** notify the containing nsTablePart that cell information has changed */
virtual void ResetCellMap ();
@ -115,5 +115,17 @@ protected:
};
/** return the number of contained rows */
inline int nsTableRowGroup::GetRowCount ()
{
return ChildCount ();
}
/** returns nsITableContent::kTableRowGroupType */
inline int nsTableRowGroup::GetType()
{
return nsITableContent::kTableRowGroupType;
}
#endif

View File

@ -87,40 +87,6 @@ void nsCellMap::GrowTo(int aColCount)
mColCount = aColCount;
}
CellData * nsCellMap::GetCellAt(int aRow, int aColumn) const
{
int index = (aRow*mColCount)+aColumn;
if (gsDebug1==PR_TRUE)
{
printf("GetCellAt [%d, %d] returning %d\n", aRow, aColumn, mCells[index]);
}
return (CellData *)mCells[index];
}
void nsCellMap::SetCellAt(CellData *aCell, int aRow, int aColumn)
{
//Assert aRow, aColumn
int index = (aRow*mColCount)+aColumn;
CellData* cell = GetCellAt(aRow,aColumn);
if (cell != nsnull)
delete cell;
mCells[index] = (PRInt32)aCell;
if (gsDebug1==PR_TRUE)
{
printf("SetCellAt [%d, %d] setting %d\n", aRow, aColumn, aCell);
}
}
int nsCellMap::GetColCount() const
{
return mColCount;
}
int nsCellMap::GetRowCount() const
{
return mRowCount;
}
void nsCellMap::DumpCellMap() const
{
if (gsDebug1==PR_TRUE)

View File

@ -76,4 +76,30 @@ public:
};
inline CellData * nsCellMap::GetCellAt(int aRow, int aColumn) const
{
int index = (aRow*mColCount)+aColumn;
return (CellData *)mCells[index];
}
inline void nsCellMap::SetCellAt(CellData *aCell, int aRow, int aColumn)
{
//Assert aRow, aColumn
int index = (aRow*mColCount)+aColumn;
CellData* cell = GetCellAt(aRow,aColumn);
if (cell != nsnull)
delete cell;
mCells[index] = (PRInt32)aCell;
}
inline int nsCellMap::GetColCount() const
{
return mColCount;
}
inline int nsCellMap::GetRowCount() const
{
return mRowCount;
}
#endif