diff --git a/layout/html/base/src/nsHTMLTagContent.cpp b/layout/html/base/src/nsHTMLTagContent.cpp
index 132d1405a7f2..3ecd3e5008e2 100644
--- a/layout/html/base/src/nsHTMLTagContent.cpp
+++ b/layout/html/base/src/nsHTMLTagContent.cpp
@@ -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)
diff --git a/layout/html/base/src/nsHTMLTagContent.h b/layout/html/base/src/nsHTMLTagContent.h
index d730c93beff4..4ebdf29b7674 100644
--- a/layout/html/base/src/nsHTMLTagContent.h
+++ b/layout/html/base/src/nsHTMLTagContent.h
@@ -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();
diff --git a/layout/html/table/src/nsTablePart.cpp b/layout/html/table/src/nsTablePart.cpp
index 44f95789520e..332fd71ec1b3 100644
--- a/layout/html/table/src/nsTablePart.cpp
+++ b/layout/html/table/src/nsTablePart.cpp
@@ -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,