Changed table code to pay attention to the ALIGN attribute

This commit is contained in:
troy 1998-05-11 21:31:12 +00:00
parent 8c077bc14e
commit 341b30497d
3 changed files with 49 additions and 0 deletions

View File

@ -552,6 +552,25 @@ PRBool nsHTMLTagContent::DivAlignParamToString(const nsHTMLValue& aValue,
return EnumValueToString(aValue, kDivAlignTable, aResult);
}
static nsHTMLTagContent::EnumTable kTableAlignTable[] = {
{ "left", NS_STYLE_TEXT_ALIGN_LEFT },
{ "right", NS_STYLE_TEXT_ALIGN_RIGHT },
{ "center", NS_STYLE_TEXT_ALIGN_CENTER },
{ 0 }
};
PRBool nsHTMLTagContent::ParseTableAlignParam(const nsString& aString,
nsHTMLValue& aResult)
{
return ParseEnumValue(aString, kTableAlignTable, aResult);
}
PRBool nsHTMLTagContent::TableAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult)
{
return EnumValueToString(aValue, kTableAlignTable, aResult);
}
void nsHTMLTagContent::ParseValueOrPercent(const nsString& aString,
nsHTMLValue& aResult,
nsHTMLUnit aValueUnit)

View File

@ -170,6 +170,11 @@ public:
static PRBool DivAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult);
static PRBool ParseTableAlignParam(const nsString& aString, nsHTMLValue& aRes);
static PRBool TableAlignParamToString(const nsHTMLValue& aValue,
nsString& aResult);
protected:
nsHTMLTagContent();

View File

@ -41,6 +41,7 @@ static NS_DEFINE_IID(kITableContentIID, NS_ITABLECONTENT_IID);
static NS_DEFINE_IID(kStylePositionSID, NS_STYLEPOSITION_SID);
static NS_DEFINE_IID(kStyleBorderSID, NS_STYLEBORDER_SID);
static NS_DEFINE_IID(kStyleSpacingSID, NS_STYLESPACING_SID);
static NS_DEFINE_IID(kStyleDisplaySID, NS_STYLEDISPLAY_SID);
#ifdef NS_DEBUG
static PRBool gsDebug = PR_FALSE;
@ -1053,6 +1054,13 @@ void nsTablePart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue)
nsHTMLTagContent::SetAttribute(aAttribute, val);
return;
}
else if (aAttribute == nsHTMLAtoms::align) {
nsHTMLValue val;
if (ParseTableAlignParam(aValue, val)) {
nsHTMLTagContent::SetAttribute(aAttribute, val);
}
return;
}
}
void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
@ -1082,6 +1090,23 @@ void nsTablePart::MapAttributesInto(nsIStyleContext* aContext,
}
// border
GetTableBorder(this, aContext, aPresContext, PR_FALSE);
// align
GetAttribute(nsHTMLAtoms::align, value);
if (value.GetUnit() != eHTMLUnit_Null) {
NS_ASSERTION(value.GetUnit() == eHTMLUnit_Enumerated, "unexpected unit");
nsStyleDisplay* display = (nsStyleDisplay*)aContext->GetData(kStyleDisplaySID);
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;
}
}
}
void nsTablePart::GetTableBorder(nsIHTMLContent* aContent,