diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 314b2c586719..7c54e903a2eb 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -540,14 +540,6 @@ nsGenericHTMLElement::GetNameSpaceID(PRInt32& aID) const // } //} -#if 0 -static nsGenericHTMLElement::EnumTable kDirTable[] = { - { "ltr", NS_STYLE_DIRECTION_LTR }, - { "rtl", NS_STYLE_DIRECTION_RTL }, - { 0 } -}; -#endif - nsresult nsGenericHTMLElement::ParseAttributeString(const nsString& aStr, nsIAtom*& aName, @@ -688,8 +680,14 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } else { - if (0 == aValue.Length()) { // ifempty string - val.Reset(); // set empty value + if (ParseCommonAttribute(aAttribute, aValue, val)) { + // string value was mapped to nsHTMLValue, set it that way + result = SetHTMLAttribute(aAttribute, val, aNotify); + NS_RELEASE(htmlContent); + return result; + } + if (0 == aValue.Length()) { // if empty string + val.SetEmptyValue(); result = SetHTMLAttribute(aAttribute, val, aNotify); NS_RELEASE(htmlContent); return result; @@ -1586,6 +1584,12 @@ nsGenericHTMLElement::GetPrimaryFrame(nsIHTMLContent* aContent, } // XXX check all mappings against ebina's usage +static nsGenericHTMLElement::EnumTable kDirTable[] = { + { "ltr", NS_STYLE_DIRECTION_LTR }, + { "rtl", NS_STYLE_DIRECTION_RTL }, + { 0 } +}; + static nsGenericHTMLElement::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, @@ -1674,6 +1678,17 @@ static nsGenericHTMLElement::EnumTable kTableVAlignTable[] = { { 0 } }; +PRBool +nsGenericHTMLElement::ParseCommonAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (nsHTMLAtoms::dir == aAttribute) { + return ParseEnumValue(aValue, kDirTable, aResult); + } + return PR_FALSE; +} + PRBool nsGenericHTMLElement::ParseAlignValue(const nsString& aString, nsHTMLValue& aResult) diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 56f337d2ba06..82c2e6891fd3 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -182,6 +182,9 @@ public: static PRBool ColorToString(const nsHTMLValue& aValue, nsString& aResult); + static PRBool ParseCommonAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult); static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult); static PRBool ParseDivAlignValue(const nsString& aString, diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 314b2c586719..7c54e903a2eb 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -540,14 +540,6 @@ nsGenericHTMLElement::GetNameSpaceID(PRInt32& aID) const // } //} -#if 0 -static nsGenericHTMLElement::EnumTable kDirTable[] = { - { "ltr", NS_STYLE_DIRECTION_LTR }, - { "rtl", NS_STYLE_DIRECTION_RTL }, - { 0 } -}; -#endif - nsresult nsGenericHTMLElement::ParseAttributeString(const nsString& aStr, nsIAtom*& aName, @@ -688,8 +680,14 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } else { - if (0 == aValue.Length()) { // ifempty string - val.Reset(); // set empty value + if (ParseCommonAttribute(aAttribute, aValue, val)) { + // string value was mapped to nsHTMLValue, set it that way + result = SetHTMLAttribute(aAttribute, val, aNotify); + NS_RELEASE(htmlContent); + return result; + } + if (0 == aValue.Length()) { // if empty string + val.SetEmptyValue(); result = SetHTMLAttribute(aAttribute, val, aNotify); NS_RELEASE(htmlContent); return result; @@ -1586,6 +1584,12 @@ nsGenericHTMLElement::GetPrimaryFrame(nsIHTMLContent* aContent, } // XXX check all mappings against ebina's usage +static nsGenericHTMLElement::EnumTable kDirTable[] = { + { "ltr", NS_STYLE_DIRECTION_LTR }, + { "rtl", NS_STYLE_DIRECTION_RTL }, + { 0 } +}; + static nsGenericHTMLElement::EnumTable kAlignTable[] = { { "left", NS_STYLE_TEXT_ALIGN_LEFT }, { "right", NS_STYLE_TEXT_ALIGN_RIGHT }, @@ -1674,6 +1678,17 @@ static nsGenericHTMLElement::EnumTable kTableVAlignTable[] = { { 0 } }; +PRBool +nsGenericHTMLElement::ParseCommonAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult) +{ + if (nsHTMLAtoms::dir == aAttribute) { + return ParseEnumValue(aValue, kDirTable, aResult); + } + return PR_FALSE; +} + PRBool nsGenericHTMLElement::ParseAlignValue(const nsString& aString, nsHTMLValue& aResult) diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index 56f337d2ba06..82c2e6891fd3 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -182,6 +182,9 @@ public: static PRBool ColorToString(const nsHTMLValue& aValue, nsString& aResult); + static PRBool ParseCommonAttribute(nsIAtom* aAttribute, + const nsString& aValue, + nsHTMLValue& aResult); static PRBool ParseAlignValue(const nsString& aString, nsHTMLValue& aResult); static PRBool ParseDivAlignValue(const nsString& aString,