From bfef8a330085d232640aa3cadd92c591858907ee Mon Sep 17 00:00:00 2001 From: "peterl%netscape.com" Date: Sat, 24 Jul 1999 19:55:35 +0000 Subject: [PATCH] Cleaned up attribute parsing so that illegal values are preserved as strings --- .../html/content/src/nsGenericHTMLElement.cpp | 65 ++++------------ .../html/content/src/nsGenericHTMLElement.h | 6 +- .../html/content/src/nsHTMLAnchorElement.cpp | 15 ++-- .../html/content/src/nsHTMLBodyElement.cpp | 20 +++-- .../html/content/src/nsHTMLButtonElement.cpp | 9 ++- .../content/src/nsHTMLDirectoryElement.cpp | 19 +++-- content/html/content/src/nsHTMLDivElement.cpp | 23 +++--- .../html/content/src/nsHTMLFontElement.cpp | 7 +- .../html/content/src/nsHTMLFormElement.cpp | 10 ++- .../html/content/src/nsHTMLFrameElement.cpp | 29 ++++--- .../content/src/nsHTMLFrameSetElement.cpp | 15 ++-- content/html/content/src/nsHTMLHRElement.cpp | 12 +-- .../html/content/src/nsHTMLIFrameElement.cpp | 38 ++++++---- .../html/content/src/nsHTMLImageElement.cpp | 6 -- .../html/content/src/nsHTMLInputElement.cpp | 34 +++++---- content/html/content/src/nsHTMLLIElement.cpp | 5 +- .../html/content/src/nsHTMLLegendElement.cpp | 5 +- .../html/content/src/nsHTMLMenuElement.cpp | 23 +++--- .../html/content/src/nsHTMLOListElement.cpp | 30 ++++---- content/html/content/src/nsHTMLPreElement.cpp | 11 +-- .../html/content/src/nsHTMLSelectElement.cpp | 10 ++- .../html/content/src/nsHTMLSpacerElement.cpp | 17 +++-- .../content/src/nsHTMLTableCellElement.cpp | 37 +++++---- .../content/src/nsHTMLTableColElement.cpp | 17 +++-- .../src/nsHTMLTableColGroupElement.cpp | 17 +++-- .../html/content/src/nsHTMLTableElement.cpp | 76 +++++++------------ .../content/src/nsHTMLTableRowElement.cpp | 24 +++--- .../content/src/nsHTMLTableSectionElement.cpp | 19 +++-- .../content/src/nsHTMLTextAreaElement.cpp | 15 ++-- .../html/content/src/nsHTMLUListElement.cpp | 28 +++---- .../html/content/src/nsGenericHTMLElement.cpp | 65 ++++------------ .../html/content/src/nsGenericHTMLElement.h | 6 +- .../html/content/src/nsHTMLAnchorElement.cpp | 15 ++-- layout/html/content/src/nsHTMLBodyElement.cpp | 20 +++-- .../html/content/src/nsHTMLButtonElement.cpp | 9 ++- .../content/src/nsHTMLDirectoryElement.cpp | 19 +++-- layout/html/content/src/nsHTMLDivElement.cpp | 23 +++--- layout/html/content/src/nsHTMLFontElement.cpp | 7 +- layout/html/content/src/nsHTMLFormElement.cpp | 10 ++- .../html/content/src/nsHTMLFrameElement.cpp | 29 ++++--- .../content/src/nsHTMLFrameSetElement.cpp | 15 ++-- layout/html/content/src/nsHTMLHRElement.cpp | 12 +-- .../html/content/src/nsHTMLIFrameElement.cpp | 38 ++++++---- .../html/content/src/nsHTMLImageElement.cpp | 6 -- .../html/content/src/nsHTMLInputElement.cpp | 34 +++++---- layout/html/content/src/nsHTMLLIElement.cpp | 5 +- .../html/content/src/nsHTMLLayerElement.cpp | 18 ++--- .../html/content/src/nsHTMLLegendElement.cpp | 5 +- layout/html/content/src/nsHTMLMenuElement.cpp | 23 +++--- .../html/content/src/nsHTMLOListElement.cpp | 30 ++++---- layout/html/content/src/nsHTMLPreElement.cpp | 11 +-- .../html/content/src/nsHTMLSelectElement.cpp | 10 ++- .../html/content/src/nsHTMLSpacerElement.cpp | 17 +++-- .../content/src/nsHTMLTableCellElement.cpp | 37 +++++---- .../content/src/nsHTMLTableColElement.cpp | 17 +++-- .../src/nsHTMLTableColGroupElement.cpp | 17 +++-- .../html/content/src/nsHTMLTableElement.cpp | 76 +++++++------------ .../content/src/nsHTMLTableRowElement.cpp | 24 +++--- .../content/src/nsHTMLTableSectionElement.cpp | 19 +++-- .../content/src/nsHTMLTextAreaElement.cpp | 15 ++-- .../html/content/src/nsHTMLUListElement.cpp | 28 +++---- 61 files changed, 619 insertions(+), 683 deletions(-) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 7866de06fd81..e1cedf4485a1 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -591,6 +591,12 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } else { + if (0 == aValue.Length()) { // ifempty string + val.Reset(); // set empty value + result = SetHTMLAttribute(aAttribute, val, aNotify); + NS_RELEASE(htmlContent); + return result; + } // set as string value to avoid another string copy PRBool impact = NS_STYLE_HINT_NONE; htmlContent->GetMappedAttributeImpact(aAttribute, impact); @@ -1265,8 +1271,6 @@ nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1275,7 +1279,7 @@ nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString, * percent (n%), * or proportional (n*) */ -void +PRBool nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString, nsHTMLValue& aResult, nsHTMLUnit aValueUnit) @@ -1298,7 +1302,9 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString, aResult.SetIntValue(val, aValueUnit); } } + return PR_TRUE; } + return PR_FALSE; } PRBool @@ -1365,8 +1371,6 @@ nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1388,8 +1392,6 @@ nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1435,8 +1437,6 @@ nsGenericHTMLElement::ParseColor(const nsString& aString, } } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1458,10 +1458,6 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue, aValue.GetStringValue(aResult); return PR_TRUE; } - if (aValue.GetUnit() == eHTMLUnit_Empty) { // was illegal - aResult.Truncate(); - return PR_TRUE; - } return PR_FALSE; } @@ -1652,14 +1648,12 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute, { if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { - ParseValueOrPercent(aString, aResult, eHTMLUnit_Pixel); - return PR_TRUE; + return ParseValueOrPercent(aString, aResult, eHTMLUnit_Pixel); } else if ((aAttribute == nsHTMLAtoms::hspace) || (aAttribute == nsHTMLAtoms::vspace) || (aAttribute == nsHTMLAtoms::border)) { - ParseValue(aString, 0, aResult, eHTMLUnit_Pixel); - return PR_TRUE; + return ParseValue(aString, 0, aResult, eHTMLUnit_Pixel); } return PR_FALSE; } @@ -1894,7 +1888,7 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* // border: pixels aAttributes->GetAttribute(nsHTMLAtoms::border, value); - if (value.GetUnit() != eHTMLUnit_Pixel) { + if (value.GetUnit() == eHTMLUnit_Null) { if (nsnull == aBorderColors) { return; } @@ -1902,6 +1896,9 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* // the size to 2 pixels. value.SetPixelValue(2); } + else if (value.GetUnit() != eHTMLUnit_Pixel) { // something other than pixels + value.SetPixelValue(0); + } float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); @@ -2026,38 +2023,6 @@ nsGenericHTMLElement::GetBackgroundAttributesImpact(const nsIAtom* aAttribute, } -static PRBool AttributeChangeRequiresRepaint(const nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and a repaint, but not a reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::bgcolor || - aAttribute==nsHTMLAtoms::color); -} - -static PRBool AttributeChangeRequiresReflow(const nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::align || - aAttribute==nsHTMLAtoms::border || - aAttribute==nsHTMLAtoms::cellpadding || - aAttribute==nsHTMLAtoms::cellspacing || - aAttribute==nsHTMLAtoms::ch || - aAttribute==nsHTMLAtoms::choff || - aAttribute==nsHTMLAtoms::colspan || - aAttribute==nsHTMLAtoms::face || - aAttribute==nsHTMLAtoms::frame || - aAttribute==nsHTMLAtoms::height || - aAttribute==nsHTMLAtoms::nowrap || - aAttribute==nsHTMLAtoms::rowspan || - aAttribute==nsHTMLAtoms::rules || - aAttribute==nsHTMLAtoms::span || - aAttribute==nsHTMLAtoms::valign || - aAttribute==nsHTMLAtoms::width); -} - //---------------------------------------------------------------------- nsGenericHTMLLeafElement::nsGenericHTMLLeafElement() diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index cfa642cabbc9..bc4cbc621cb8 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -151,9 +151,9 @@ public: nsHTMLValue& aResult, nsHTMLUnit aValueUnit); - static void ParseValueOrPercentOrProportional(const nsString& aString, - nsHTMLValue& aResult, - nsHTMLUnit aValueUnit); + static PRBool ParseValueOrPercentOrProportional(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit); static PRBool ValueOrPercentToString(const nsHTMLValue& aValue, nsString& aResult); diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index 62ac54e8614e..6b824d069460 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -221,17 +221,14 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, - eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::href) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::suppress) { + else if (aAttribute == nsHTMLAtoms::suppress) { if (aValue.EqualsIgnoreCase("true")) { - aResult.SetEmptyValue(); + aResult.SetEmptyValue(); // XXX? shouldn't just leave "true" return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 01f1374c18d9..56878f8f1182 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -408,7 +408,7 @@ nsresult BodyFixupRule::QueryInterface(const nsIID& aIID, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +// static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); if (aIID.Equals(kIStyleRuleIID)) { *aInstancePtrResult = (void*) ((nsIStyleRule*)this); NS_ADDREF_THIS(); @@ -591,22 +591,20 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { - if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } if ((aAttribute == nsHTMLAtoms::bgcolor) || (aAttribute == nsHTMLAtoms::text) || (aAttribute == nsHTMLAtoms::link) || (aAttribute == nsHTMLAtoms::alink) || (aAttribute == nsHTMLAtoms::vlink)) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if ((aAttribute == nsHTMLAtoms::marginwidth) || - (aAttribute == nsHTMLAtoms::marginheight)) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if ((aAttribute == nsHTMLAtoms::marginwidth) || + (aAttribute == nsHTMLAtoms::marginheight)) { + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index f73dde3155f6..09278f2d63e9 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -308,11 +308,12 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, - eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::type) { + else if (aAttribute == nsHTMLAtoms::type) { nsGenericHTMLElement::EnumTable *table = kButtonTypeTable; while (nsnull != table->tag) { if (aValue.EqualsIgnoreCase(table->tag)) { diff --git a/content/html/content/src/nsHTMLDirectoryElement.cpp b/content/html/content/src/nsHTMLDirectoryElement.cpp index 63f42cad4e38..f9781706233a 100644 --- a/content/html/content/src/nsHTMLDirectoryElement.cpp +++ b/content/html/content/src/nsHTMLDirectoryElement.cpp @@ -135,17 +135,17 @@ nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::compact) { + else if (aAttribute == nsHTMLAtoms::compact) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_NO_VALUE; } @@ -179,6 +179,9 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); diff --git a/content/html/content/src/nsHTMLDivElement.cpp b/content/html/content/src/nsHTMLDivElement.cpp index 370cda5b8d76..addd2481dbf2 100644 --- a/content/html/content/src/nsHTMLDivElement.cpp +++ b/content/html/content/src/nsHTMLDivElement.cpp @@ -137,18 +137,21 @@ nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::cols) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::cols) { + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::gutter) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::gutter) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::width) { + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLFontElement.cpp b/content/html/content/src/nsHTMLFontElement.cpp index ee8f95bf9f32..5896073dceda 100644 --- a/content/html/content/src/nsHTMLFontElement.cpp +++ b/content/html/content/src/nsHTMLFontElement.cpp @@ -154,9 +154,10 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::color) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::color) { + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index f1912b126938..de8a822ab483 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -363,12 +363,14 @@ nsHTMLFormElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::method) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFormMethodTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFormMethodTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::enctype) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFormEnctypeTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFormEnctypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLFrameElement.cpp b/content/html/content/src/nsHTMLFrameElement.cpp index 1ee216893d22..f72b991612e1 100644 --- a/content/html/content/src/nsHTMLFrameElement.cpp +++ b/content/html/content/src/nsHTMLFrameElement.cpp @@ -151,31 +151,36 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { // XXX need to check for correct mode - nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginwidth) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginheight) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::noresize) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::scrolling) { - nsGenericHTMLElement::ParseScrollingValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseScrollingValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLFrameSetElement.cpp b/content/html/content/src/nsHTMLFrameSetElement.cpp index 09a8e5bd2077..13e54b905107 100644 --- a/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -133,17 +133,20 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { // XXX need to check for correct mode - nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::border) { - nsGenericHTMLElement::ParseValue(aValue, 0, 100, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 100, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLHRElement.cpp b/content/html/content/src/nsHTMLHRElement.cpp index c3e8d6d5283e..95b1828219a6 100644 --- a/content/html/content/src/nsHTMLHRElement.cpp +++ b/content/html/content/src/nsHTMLHRElement.cpp @@ -172,13 +172,15 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::noshade) { aResult.SetEmptyValue(); diff --git a/content/html/content/src/nsHTMLIFrameElement.cpp b/content/html/content/src/nsHTMLIFrameElement.cpp index a4b1cce33822..646aaa76c48e 100644 --- a/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/content/html/content/src/nsHTMLIFrameElement.cpp @@ -165,32 +165,38 @@ nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::marginwidth) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginheight) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { - nsGenericHTMLElement::ParseFrameborderValue(PR_TRUE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_TRUE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::scrolling) { - nsGenericHTMLElement::ParseScrollingValue(PR_TRUE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseScrollingValue(PR_TRUE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::align) { if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) { diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index c97bcbf3f47e..d91affa5b96b 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -229,12 +229,6 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } - if ((aAttribute == nsHTMLAtoms::usemap) || - (aAttribute == nsHTMLAtoms::src) || - (aAttribute == nsHTMLAtoms::lowsrc)) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, aValue, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 8ae10b7af5b2..e10aa4aed088 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -510,26 +510,31 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::maxlength) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (IsImage()) { if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, @@ -538,8 +543,9 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::border) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLLIElement.cpp b/content/html/content/src/nsHTMLLIElement.cpp index 513de1cfea5f..b6257eeb7b89 100644 --- a/content/html/content/src/nsHTMLLIElement.cpp +++ b/content/html/content/src/nsHTMLLIElement.cpp @@ -154,8 +154,9 @@ nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::value) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLLegendElement.cpp b/content/html/content/src/nsHTMLLegendElement.cpp index 01ec5db9ccb4..e80d28a4b37f 100644 --- a/content/html/content/src/nsHTMLLegendElement.cpp +++ b/content/html/content/src/nsHTMLLegendElement.cpp @@ -168,8 +168,9 @@ nsHTMLLegendElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::align) { - nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLMenuElement.cpp b/content/html/content/src/nsHTMLMenuElement.cpp index 08c6ddcc511b..fd08afd9530b 100644 --- a/content/html/content/src/nsHTMLMenuElement.cpp +++ b/content/html/content/src/nsHTMLMenuElement.cpp @@ -135,19 +135,15 @@ nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -179,10 +175,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } } diff --git a/content/html/content/src/nsHTMLOListElement.cpp b/content/html/content/src/nsHTMLOListElement.cpp index fa28b3c95ff8..6312947eafd6 100644 --- a/content/html/content/src/nsHTMLOListElement.cpp +++ b/content/html/content/src/nsHTMLOListElement.cpp @@ -159,22 +159,19 @@ nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, - kOldListTypeTable, aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated); - } + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + if (nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, + kOldListTypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -219,10 +216,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_DECIMAL; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } } diff --git a/content/html/content/src/nsHTMLPreElement.cpp b/content/html/content/src/nsHTMLPreElement.cpp index 1ccbcaa8d717..8ace87c074e9 100644 --- a/content/html/content/src/nsHTMLPreElement.cpp +++ b/content/html/content/src/nsHTMLPreElement.cpp @@ -132,24 +132,19 @@ nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { - if ((aAttribute == nsHTMLAtoms::wrap) || - (aAttribute == nsHTMLAtoms::variable)) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_HAS_VALUE; - } if (aAttribute == nsHTMLAtoms::cols) { if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::width) { + else if (aAttribute == nsHTMLAtoms::width) { if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::tabstop) { + else if (aAttribute == nsHTMLAtoms::tabstop) { PRInt32 ec, tabstop = aValue.ToInteger(&ec); if (tabstop <= 0) { tabstop = 8; @@ -196,7 +191,7 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, // wrap: empty aAttributes->GetAttribute(nsHTMLAtoms::wrap, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { nsStyleText* text = (nsStyleText*) aContext->GetMutableStyleData(eStyleStruct_Text); text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index 727f9ad2a9bf..980473233e63 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -672,12 +672,14 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLSpacerElement.cpp b/content/html/content/src/nsHTMLSpacerElement.cpp index c9364b9a1556..83a3ade83015 100644 --- a/content/html/content/src/nsHTMLSpacerElement.cpp +++ b/content/html/content/src/nsHTMLSpacerElement.cpp @@ -129,18 +129,21 @@ nsHTMLSpacerElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::align) { - nsGenericHTMLElement::ParseAlignValue(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLTableCellElement.cpp b/content/html/content/src/nsHTMLTableCellElement.cpp index 1f675e01dff6..62a6d7256e73 100644 --- a/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/content/html/content/src/nsHTMLTableCellElement.cpp @@ -337,27 +337,31 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers with a min of 0 */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers with a min of 1 */ - if ((aAttribute == nsHTMLAtoms::colspan) || + else if ((aAttribute == nsHTMLAtoms::colspan) || (aAttribute == nsHTMLAtoms::rowspan)) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -366,17 +370,10 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if (aAttribute == nsHTMLAtoms::nowrap) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::scope) { if (nsGenericHTMLElement::ParseEnumValue(aValue, kCellScopeTable, aResult)) { @@ -478,7 +475,7 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, // nowrap // nowrap depends on the width attribute, so be sure to handle it after width is mapped! aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value); - if (value.GetUnit() == eHTMLUnit_Empty) + if (value.GetUnit() != eHTMLUnit_Null) { if (widthValue.GetUnit() != eHTMLUnit_Pixel) { diff --git a/content/html/content/src/nsHTMLTableColElement.cpp b/content/html/content/src/nsHTMLTableColElement.cpp index d0d1af3c3f5c..0ad4d4560756 100644 --- a/content/html/content/src/nsHTMLTableColElement.cpp +++ b/content/html/content/src/nsHTMLTableColElement.cpp @@ -162,18 +162,21 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - else if (aAttribute == nsHTMLAtoms::span) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::span) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ diff --git a/content/html/content/src/nsHTMLTableColGroupElement.cpp b/content/html/content/src/nsHTMLTableColGroupElement.cpp index 4e419c568dd3..b91aa125b208 100644 --- a/content/html/content/src/nsHTMLTableColGroupElement.cpp +++ b/content/html/content/src/nsHTMLTableColGroupElement.cpp @@ -151,18 +151,21 @@ nsHTMLTableColGroupElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - else if (aAttribute == nsHTMLAtoms::span) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::span) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index 0ec9673db022..778ea7f98772 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -841,50 +841,37 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, /* attributes that resolve to pixels, with min=0 */ if ((aAttribute == nsHTMLAtoms::cellspacing) || (aAttribute == nsHTMLAtoms::cellpadding)) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that are either empty, or integers, with min=0 */ else if (aAttribute == nsHTMLAtoms::cols) { - nsAutoString tmp(aValue); - tmp.StripWhitespace(); - if (0 == tmp.Length()) { - // Just set COLS, same as COLS=number of columns - aResult.SetEmptyValue(); + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - else - { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - } - return NS_CONTENT_ATTR_HAS_VALUE; } /* attributes that are either empty, or pixels */ else if (aAttribute == nsHTMLAtoms::border) { - nsAutoString tmp(aValue); - tmp.StripWhitespace(); - if (0 == tmp.Length()) { - // Just enable the border; same as border=1 - aResult.SetEmptyValue(); + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - else - { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - } - return NS_CONTENT_ATTR_HAS_VALUE; } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -893,25 +880,25 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frame) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::layout) { - nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::rules) { - nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; @@ -1033,21 +1020,14 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes, nsHTMLValue borderValue; aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue); - if (borderValue.GetUnit() == eHTMLUnit_String) - { - nsAutoString borderAsString; - borderValue.GetStringValue(borderAsString); - nsGenericHTMLElement::ParseValue(borderAsString, 0, borderValue, eHTMLUnit_Pixel); - } - else if (borderValue.GetUnit() == eHTMLUnit_Null) + if (borderValue.GetUnit() == eHTMLUnit_Null) { // the absence of "border" with the presence of "frame" implies border = 1 pixel nsHTMLValue frameValue; aAttributes->GetAttribute(nsHTMLAtoms::frame, frameValue); if (frameValue.GetUnit() != eHTMLUnit_Null) borderValue.SetPixelValue(1); } - if ((borderValue.GetUnit() == eHTMLUnit_Pixel) || - (borderValue.GetUnit() == eHTMLUnit_Empty)) { + if (borderValue.GetUnit() != eHTMLUnit_Null) { nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); nsStyleTable *tableStyle = (nsStyleTable*) @@ -1055,7 +1035,7 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes, float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); nsStyleCoord twips; - if (borderValue.GetUnit() == eHTMLUnit_Empty) { + if (borderValue.GetUnit() != eHTMLUnit_Pixel) { tableStyle->mRules=NS_STYLE_TABLE_RULES_ALL; // non-0 values of border imply default rules=all twips.SetCoordValue(NSIntPixelsToTwips(1, p2t)); } diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp index baca96d727be..194b3de251c8 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/nsHTMLTableRowElement.cpp @@ -497,20 +497,23 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers with default=0*/ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -519,13 +522,10 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::valign) { if (nsGenericHTMLElement::ParseTableVAlignValue(aValue, aResult)) { diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/nsHTMLTableSectionElement.cpp index 13c619fdfa10..437f65aaec9b 100644 --- a/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -225,14 +225,16 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -241,13 +243,10 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::valign) { if (nsGenericHTMLElement::ParseTableVAlignValue(aValue, aResult)) { diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index fbb06b2d1e0a..51c068fa5fa1 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -344,20 +344,23 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::cols) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::readonly) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::rows) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/content/html/content/src/nsHTMLUListElement.cpp b/content/html/content/src/nsHTMLUListElement.cpp index e9de64b0bf1e..b73f7652f2bc 100644 --- a/content/html/content/src/nsHTMLUListElement.cpp +++ b/content/html/content/src/nsHTMLUListElement.cpp @@ -137,22 +137,19 @@ nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, - kOldListTypeTable, aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); - } + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + if (nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, + kOldListTypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -197,10 +194,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() == eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } } diff --git a/layout/html/content/src/nsGenericHTMLElement.cpp b/layout/html/content/src/nsGenericHTMLElement.cpp index 7866de06fd81..e1cedf4485a1 100644 --- a/layout/html/content/src/nsGenericHTMLElement.cpp +++ b/layout/html/content/src/nsGenericHTMLElement.cpp @@ -591,6 +591,12 @@ nsGenericHTMLElement::SetAttribute(PRInt32 aNameSpaceID, return result; } else { + if (0 == aValue.Length()) { // ifempty string + val.Reset(); // set empty value + result = SetHTMLAttribute(aAttribute, val, aNotify); + NS_RELEASE(htmlContent); + return result; + } // set as string value to avoid another string copy PRBool impact = NS_STYLE_HINT_NONE; htmlContent->GetMappedAttributeImpact(aAttribute, impact); @@ -1265,8 +1271,6 @@ nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1275,7 +1279,7 @@ nsGenericHTMLElement::ParseValueOrPercent(const nsString& aString, * percent (n%), * or proportional (n*) */ -void +PRBool nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString, nsHTMLValue& aResult, nsHTMLUnit aValueUnit) @@ -1298,7 +1302,9 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsString& aString, aResult.SetIntValue(val, aValueUnit); } } + return PR_TRUE; } + return PR_FALSE; } PRBool @@ -1365,8 +1371,6 @@ nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1388,8 +1392,6 @@ nsGenericHTMLElement::ParseValue(const nsString& aString, PRInt32 aMin, return PR_TRUE; } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1435,8 +1437,6 @@ nsGenericHTMLElement::ParseColor(const nsString& aString, } } - // Illegal values are mapped to empty - aResult.SetEmptyValue(); return PR_FALSE; } @@ -1458,10 +1458,6 @@ nsGenericHTMLElement::ColorToString(const nsHTMLValue& aValue, aValue.GetStringValue(aResult); return PR_TRUE; } - if (aValue.GetUnit() == eHTMLUnit_Empty) { // was illegal - aResult.Truncate(); - return PR_TRUE; - } return PR_FALSE; } @@ -1652,14 +1648,12 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute, { if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { - ParseValueOrPercent(aString, aResult, eHTMLUnit_Pixel); - return PR_TRUE; + return ParseValueOrPercent(aString, aResult, eHTMLUnit_Pixel); } else if ((aAttribute == nsHTMLAtoms::hspace) || (aAttribute == nsHTMLAtoms::vspace) || (aAttribute == nsHTMLAtoms::border)) { - ParseValue(aString, 0, aResult, eHTMLUnit_Pixel); - return PR_TRUE; + return ParseValue(aString, 0, aResult, eHTMLUnit_Pixel); } return PR_FALSE; } @@ -1894,7 +1888,7 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* // border: pixels aAttributes->GetAttribute(nsHTMLAtoms::border, value); - if (value.GetUnit() != eHTMLUnit_Pixel) { + if (value.GetUnit() == eHTMLUnit_Null) { if (nsnull == aBorderColors) { return; } @@ -1902,6 +1896,9 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsIHTMLMappedAttributes* // the size to 2 pixels. value.SetPixelValue(2); } + else if (value.GetUnit() != eHTMLUnit_Pixel) { // something other than pixels + value.SetPixelValue(0); + } float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); @@ -2026,38 +2023,6 @@ nsGenericHTMLElement::GetBackgroundAttributesImpact(const nsIAtom* aAttribute, } -static PRBool AttributeChangeRequiresRepaint(const nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and a repaint, but not a reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::bgcolor || - aAttribute==nsHTMLAtoms::color); -} - -static PRBool AttributeChangeRequiresReflow(const nsIAtom* aAttribute) -{ - // these are attributes that always require a restyle and reflow - // regardless of the tag they are associated with - return (PRBool) - (aAttribute==nsHTMLAtoms::align || - aAttribute==nsHTMLAtoms::border || - aAttribute==nsHTMLAtoms::cellpadding || - aAttribute==nsHTMLAtoms::cellspacing || - aAttribute==nsHTMLAtoms::ch || - aAttribute==nsHTMLAtoms::choff || - aAttribute==nsHTMLAtoms::colspan || - aAttribute==nsHTMLAtoms::face || - aAttribute==nsHTMLAtoms::frame || - aAttribute==nsHTMLAtoms::height || - aAttribute==nsHTMLAtoms::nowrap || - aAttribute==nsHTMLAtoms::rowspan || - aAttribute==nsHTMLAtoms::rules || - aAttribute==nsHTMLAtoms::span || - aAttribute==nsHTMLAtoms::valign || - aAttribute==nsHTMLAtoms::width); -} - //---------------------------------------------------------------------- nsGenericHTMLLeafElement::nsGenericHTMLLeafElement() diff --git a/layout/html/content/src/nsGenericHTMLElement.h b/layout/html/content/src/nsGenericHTMLElement.h index cfa642cabbc9..bc4cbc621cb8 100644 --- a/layout/html/content/src/nsGenericHTMLElement.h +++ b/layout/html/content/src/nsGenericHTMLElement.h @@ -151,9 +151,9 @@ public: nsHTMLValue& aResult, nsHTMLUnit aValueUnit); - static void ParseValueOrPercentOrProportional(const nsString& aString, - nsHTMLValue& aResult, - nsHTMLUnit aValueUnit); + static PRBool ParseValueOrPercentOrProportional(const nsString& aString, + nsHTMLValue& aResult, + nsHTMLUnit aValueUnit); static PRBool ValueOrPercentToString(const nsHTMLValue& aValue, nsString& aResult); diff --git a/layout/html/content/src/nsHTMLAnchorElement.cpp b/layout/html/content/src/nsHTMLAnchorElement.cpp index 62ac54e8614e..6b824d069460 100644 --- a/layout/html/content/src/nsHTMLAnchorElement.cpp +++ b/layout/html/content/src/nsHTMLAnchorElement.cpp @@ -221,17 +221,14 @@ nsHTMLAnchorElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, - eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::href) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::suppress) { + else if (aAttribute == nsHTMLAtoms::suppress) { if (aValue.EqualsIgnoreCase("true")) { - aResult.SetEmptyValue(); + aResult.SetEmptyValue(); // XXX? shouldn't just leave "true" return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/layout/html/content/src/nsHTMLBodyElement.cpp b/layout/html/content/src/nsHTMLBodyElement.cpp index 01f1374c18d9..56878f8f1182 100644 --- a/layout/html/content/src/nsHTMLBodyElement.cpp +++ b/layout/html/content/src/nsHTMLBodyElement.cpp @@ -408,7 +408,7 @@ nsresult BodyFixupRule::QueryInterface(const nsIID& aIID, if (nsnull == aInstancePtrResult) { return NS_ERROR_NULL_POINTER; } - static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +// static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); if (aIID.Equals(kIStyleRuleIID)) { *aInstancePtrResult = (void*) ((nsIStyleRule*)this); NS_ADDREF_THIS(); @@ -591,22 +591,20 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { - if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } if ((aAttribute == nsHTMLAtoms::bgcolor) || (aAttribute == nsHTMLAtoms::text) || (aAttribute == nsHTMLAtoms::link) || (aAttribute == nsHTMLAtoms::alink) || (aAttribute == nsHTMLAtoms::vlink)) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if ((aAttribute == nsHTMLAtoms::marginwidth) || - (aAttribute == nsHTMLAtoms::marginheight)) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if ((aAttribute == nsHTMLAtoms::marginwidth) || + (aAttribute == nsHTMLAtoms::marginheight)) { + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLButtonElement.cpp b/layout/html/content/src/nsHTMLButtonElement.cpp index f73dde3155f6..09278f2d63e9 100644 --- a/layout/html/content/src/nsHTMLButtonElement.cpp +++ b/layout/html/content/src/nsHTMLButtonElement.cpp @@ -308,11 +308,12 @@ nsHTMLButtonElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, - eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 32767, aResult, + eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::type) { + else if (aAttribute == nsHTMLAtoms::type) { nsGenericHTMLElement::EnumTable *table = kButtonTypeTable; while (nsnull != table->tag) { if (aValue.EqualsIgnoreCase(table->tag)) { diff --git a/layout/html/content/src/nsHTMLDirectoryElement.cpp b/layout/html/content/src/nsHTMLDirectoryElement.cpp index 63f42cad4e38..f9781706233a 100644 --- a/layout/html/content/src/nsHTMLDirectoryElement.cpp +++ b/layout/html/content/src/nsHTMLDirectoryElement.cpp @@ -135,17 +135,17 @@ nsHTMLDirectoryElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::compact) { + else if (aAttribute == nsHTMLAtoms::compact) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_NO_VALUE; } @@ -179,6 +179,9 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); diff --git a/layout/html/content/src/nsHTMLDivElement.cpp b/layout/html/content/src/nsHTMLDivElement.cpp index 370cda5b8d76..addd2481dbf2 100644 --- a/layout/html/content/src/nsHTMLDivElement.cpp +++ b/layout/html/content/src/nsHTMLDivElement.cpp @@ -137,18 +137,21 @@ nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::cols) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::cols) { + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::gutter) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::gutter) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::width) { + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLFontElement.cpp b/layout/html/content/src/nsHTMLFontElement.cpp index ee8f95bf9f32..5896073dceda 100644 --- a/layout/html/content/src/nsHTMLFontElement.cpp +++ b/layout/html/content/src/nsHTMLFontElement.cpp @@ -154,9 +154,10 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::color) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::color) { + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLFormElement.cpp b/layout/html/content/src/nsHTMLFormElement.cpp index f1912b126938..de8a822ab483 100644 --- a/layout/html/content/src/nsHTMLFormElement.cpp +++ b/layout/html/content/src/nsHTMLFormElement.cpp @@ -363,12 +363,14 @@ nsHTMLFormElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::method) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFormMethodTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFormMethodTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::enctype) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFormEnctypeTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFormEnctypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLFrameElement.cpp b/layout/html/content/src/nsHTMLFrameElement.cpp index 1ee216893d22..f72b991612e1 100644 --- a/layout/html/content/src/nsHTMLFrameElement.cpp +++ b/layout/html/content/src/nsHTMLFrameElement.cpp @@ -151,31 +151,36 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { // XXX need to check for correct mode - nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginwidth) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginheight) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::noresize) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::scrolling) { - nsGenericHTMLElement::ParseScrollingValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseScrollingValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLFrameSetElement.cpp b/layout/html/content/src/nsHTMLFrameSetElement.cpp index 09a8e5bd2077..13e54b905107 100644 --- a/layout/html/content/src/nsHTMLFrameSetElement.cpp +++ b/layout/html/content/src/nsHTMLFrameSetElement.cpp @@ -133,17 +133,20 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { // XXX need to check for correct mode - nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_FALSE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::border) { - nsGenericHTMLElement::ParseValue(aValue, 0, 100, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, 100, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLHRElement.cpp b/layout/html/content/src/nsHTMLHRElement.cpp index c3e8d6d5283e..95b1828219a6 100644 --- a/layout/html/content/src/nsHTMLHRElement.cpp +++ b/layout/html/content/src/nsHTMLHRElement.cpp @@ -172,13 +172,15 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, 100, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::noshade) { aResult.SetEmptyValue(); diff --git a/layout/html/content/src/nsHTMLIFrameElement.cpp b/layout/html/content/src/nsHTMLIFrameElement.cpp index a4b1cce33822..646aaa76c48e 100644 --- a/layout/html/content/src/nsHTMLIFrameElement.cpp +++ b/layout/html/content/src/nsHTMLIFrameElement.cpp @@ -165,32 +165,38 @@ nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::marginwidth) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::marginheight) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frameborder) { - nsGenericHTMLElement::ParseFrameborderValue(PR_TRUE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseFrameborderValue(PR_TRUE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::scrolling) { - nsGenericHTMLElement::ParseScrollingValue(PR_TRUE, aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseScrollingValue(PR_TRUE, aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::align) { if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) { diff --git a/layout/html/content/src/nsHTMLImageElement.cpp b/layout/html/content/src/nsHTMLImageElement.cpp index c97bcbf3f47e..d91affa5b96b 100644 --- a/layout/html/content/src/nsHTMLImageElement.cpp +++ b/layout/html/content/src/nsHTMLImageElement.cpp @@ -229,12 +229,6 @@ nsHTMLImageElement::StringToAttribute(nsIAtom* aAttribute, aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } - if ((aAttribute == nsHTMLAtoms::usemap) || - (aAttribute == nsHTMLAtoms::src) || - (aAttribute == nsHTMLAtoms::lowsrc)) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, aValue, aResult)) { return NS_CONTENT_ATTR_HAS_VALUE; diff --git a/layout/html/content/src/nsHTMLInputElement.cpp b/layout/html/content/src/nsHTMLInputElement.cpp index 8ae10b7af5b2..e10aa4aed088 100644 --- a/layout/html/content/src/nsHTMLInputElement.cpp +++ b/layout/html/content/src/nsHTMLInputElement.cpp @@ -510,26 +510,31 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::maxlength) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (IsImage()) { if (nsGenericHTMLElement::ParseImageAttribute(aAttribute, @@ -538,8 +543,9 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::border) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLLIElement.cpp b/layout/html/content/src/nsHTMLLIElement.cpp index 513de1cfea5f..b6257eeb7b89 100644 --- a/layout/html/content/src/nsHTMLLIElement.cpp +++ b/layout/html/content/src/nsHTMLLIElement.cpp @@ -154,8 +154,9 @@ nsHTMLLIElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::value) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLLayerElement.cpp b/layout/html/content/src/nsHTMLLayerElement.cpp index 2b5c3431cb04..e9150dc29860 100644 --- a/layout/html/content/src/nsHTMLLayerElement.cpp +++ b/layout/html/content/src/nsHTMLLayerElement.cpp @@ -31,7 +31,7 @@ #include "nsIPresContext.h" #include "nsIHTMLAttributes.h" -#define _I32_MIN (-2147483647 - 1) /* minimum signed 32 bit value */ +//#define _I32_MIN (-2147483647 - 1) /* minimum signed 32 bit value */ static NS_DEFINE_IID(kIDOMHTMLLayerElementIID, NS_IDOMHTMLLAYERELEMENT_IID); static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID); @@ -185,14 +185,10 @@ nsHTMLLayerElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { // XXX CLIP - if (aAttribute == nsHTMLAtoms::src) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if ((aAttribute == nsHTMLAtoms::top) || - (aAttribute == nsHTMLAtoms::left) || - (aAttribute == nsHTMLAtoms::width) || - (aAttribute == nsHTMLAtoms::height)) { + if ((aAttribute == nsHTMLAtoms::top) || + (aAttribute == nsHTMLAtoms::left) || + (aAttribute == nsHTMLAtoms::width) || + (aAttribute == nsHTMLAtoms::height)) { if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { return NS_CONTENT_ATTR_HAS_VALUE; } @@ -213,10 +209,6 @@ nsHTMLLayerElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } // ABOVE, BELOW, OnMouseOver, OnMouseOut, OnFocus, OnBlur, OnLoad return NS_CONTENT_ATTR_NOT_THERE; diff --git a/layout/html/content/src/nsHTMLLegendElement.cpp b/layout/html/content/src/nsHTMLLegendElement.cpp index 01ec5db9ccb4..e80d28a4b37f 100644 --- a/layout/html/content/src/nsHTMLLegendElement.cpp +++ b/layout/html/content/src/nsHTMLLegendElement.cpp @@ -168,8 +168,9 @@ nsHTMLLegendElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::align) { - nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kAlignTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLMenuElement.cpp b/layout/html/content/src/nsHTMLMenuElement.cpp index 08c6ddcc511b..fd08afd9530b 100644 --- a/layout/html/content/src/nsHTMLMenuElement.cpp +++ b/layout/html/content/src/nsHTMLMenuElement.cpp @@ -135,19 +135,15 @@ nsHTMLMenuElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -179,10 +175,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } } diff --git a/layout/html/content/src/nsHTMLOListElement.cpp b/layout/html/content/src/nsHTMLOListElement.cpp index fa28b3c95ff8..6312947eafd6 100644 --- a/layout/html/content/src/nsHTMLOListElement.cpp +++ b/layout/html/content/src/nsHTMLOListElement.cpp @@ -159,22 +159,19 @@ nsHTMLOListElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, - kOldListTypeTable, aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_DECIMAL, eHTMLUnit_Enumerated); - } + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + if (nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, + kOldListTypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } - if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + else if (aAttribute == nsHTMLAtoms::start) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -219,10 +216,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() != eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_DECIMAL; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } } diff --git a/layout/html/content/src/nsHTMLPreElement.cpp b/layout/html/content/src/nsHTMLPreElement.cpp index 1ccbcaa8d717..8ace87c074e9 100644 --- a/layout/html/content/src/nsHTMLPreElement.cpp +++ b/layout/html/content/src/nsHTMLPreElement.cpp @@ -132,24 +132,19 @@ nsHTMLPreElement::StringToAttribute(nsIAtom* aAttribute, const nsString& aValue, nsHTMLValue& aResult) { - if ((aAttribute == nsHTMLAtoms::wrap) || - (aAttribute == nsHTMLAtoms::variable)) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_HAS_VALUE; - } if (aAttribute == nsHTMLAtoms::cols) { if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::width) { + else if (aAttribute == nsHTMLAtoms::width) { if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { return NS_CONTENT_ATTR_HAS_VALUE; } } - if (aAttribute == nsHTMLAtoms::tabstop) { + else if (aAttribute == nsHTMLAtoms::tabstop) { PRInt32 ec, tabstop = aValue.ToInteger(&ec); if (tabstop <= 0) { tabstop = 8; @@ -196,7 +191,7 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, // wrap: empty aAttributes->GetAttribute(nsHTMLAtoms::wrap, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { nsStyleText* text = (nsStyleText*) aContext->GetMutableStyleData(eStyleStruct_Text); text->mWhiteSpace = NS_STYLE_WHITESPACE_MOZ_PRE_WRAP; diff --git a/layout/html/content/src/nsHTMLSelectElement.cpp b/layout/html/content/src/nsHTMLSelectElement.cpp index 727f9ad2a9bf..980473233e63 100644 --- a/layout/html/content/src/nsHTMLSelectElement.cpp +++ b/layout/html/content/src/nsHTMLSelectElement.cpp @@ -672,12 +672,14 @@ nsHTMLSelectElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLSpacerElement.cpp b/layout/html/content/src/nsHTMLSpacerElement.cpp index c9364b9a1556..83a3ade83015 100644 --- a/layout/html/content/src/nsHTMLSpacerElement.cpp +++ b/layout/html/content/src/nsHTMLSpacerElement.cpp @@ -129,18 +129,21 @@ nsHTMLSpacerElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::size) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::align) { - nsGenericHTMLElement::ParseAlignValue(aValue, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseAlignValue(aValue, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if ((aAttribute == nsHTMLAtoms::width) || (aAttribute == nsHTMLAtoms::height)) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, - eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, + eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLTableCellElement.cpp b/layout/html/content/src/nsHTMLTableCellElement.cpp index 1f675e01dff6..62a6d7256e73 100644 --- a/layout/html/content/src/nsHTMLTableCellElement.cpp +++ b/layout/html/content/src/nsHTMLTableCellElement.cpp @@ -337,27 +337,31 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers with a min of 0 */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers with a min of 1 */ - if ((aAttribute == nsHTMLAtoms::colspan) || + else if ((aAttribute == nsHTMLAtoms::colspan) || (aAttribute == nsHTMLAtoms::rowspan)) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -366,17 +370,10 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; - } - else if (aAttribute == nsHTMLAtoms::nowrap) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::scope) { if (nsGenericHTMLElement::ParseEnumValue(aValue, kCellScopeTable, aResult)) { @@ -478,7 +475,7 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, // nowrap // nowrap depends on the width attribute, so be sure to handle it after width is mapped! aAttributes->GetAttribute(nsHTMLAtoms::nowrap, value); - if (value.GetUnit() == eHTMLUnit_Empty) + if (value.GetUnit() != eHTMLUnit_Null) { if (widthValue.GetUnit() != eHTMLUnit_Pixel) { diff --git a/layout/html/content/src/nsHTMLTableColElement.cpp b/layout/html/content/src/nsHTMLTableColElement.cpp index d0d1af3c3f5c..0ad4d4560756 100644 --- a/layout/html/content/src/nsHTMLTableColElement.cpp +++ b/layout/html/content/src/nsHTMLTableColElement.cpp @@ -162,18 +162,21 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - else if (aAttribute == nsHTMLAtoms::span) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::span) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ diff --git a/layout/html/content/src/nsHTMLTableColGroupElement.cpp b/layout/html/content/src/nsHTMLTableColGroupElement.cpp index 4e419c568dd3..b91aa125b208 100644 --- a/layout/html/content/src/nsHTMLTableColGroupElement.cpp +++ b/layout/html/content/src/nsHTMLTableColGroupElement.cpp @@ -151,18 +151,21 @@ nsHTMLTableColGroupElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } - else if (aAttribute == nsHTMLAtoms::span) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + else if (aAttribute == nsHTMLAtoms::span) { + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ diff --git a/layout/html/content/src/nsHTMLTableElement.cpp b/layout/html/content/src/nsHTMLTableElement.cpp index 0ec9673db022..778ea7f98772 100644 --- a/layout/html/content/src/nsHTMLTableElement.cpp +++ b/layout/html/content/src/nsHTMLTableElement.cpp @@ -841,50 +841,37 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, /* attributes that resolve to pixels, with min=0 */ if ((aAttribute == nsHTMLAtoms::cellspacing) || (aAttribute == nsHTMLAtoms::cellpadding)) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that are either empty, or integers, with min=0 */ else if (aAttribute == nsHTMLAtoms::cols) { - nsAutoString tmp(aValue); - tmp.StripWhitespace(); - if (0 == tmp.Length()) { - // Just set COLS, same as COLS=number of columns - aResult.SetEmptyValue(); + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - else - { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - } - return NS_CONTENT_ATTR_HAS_VALUE; } /* attributes that are either empty, or pixels */ else if (aAttribute == nsHTMLAtoms::border) { - nsAutoString tmp(aValue); - tmp.StripWhitespace(); - if (0 == tmp.Length()) { - // Just enable the border; same as border=1 - aResult.SetEmptyValue(); + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - else - { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Pixel); - } - return NS_CONTENT_ATTR_HAS_VALUE; } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -893,25 +880,25 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::frame) { - nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kFrameTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::layout) { - nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kLayoutTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::rules) { - nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseEnumValue(aValue, kRulesTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; @@ -1033,21 +1020,14 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes, nsHTMLValue borderValue; aAttributes->GetAttribute(nsHTMLAtoms::border, borderValue); - if (borderValue.GetUnit() == eHTMLUnit_String) - { - nsAutoString borderAsString; - borderValue.GetStringValue(borderAsString); - nsGenericHTMLElement::ParseValue(borderAsString, 0, borderValue, eHTMLUnit_Pixel); - } - else if (borderValue.GetUnit() == eHTMLUnit_Null) + if (borderValue.GetUnit() == eHTMLUnit_Null) { // the absence of "border" with the presence of "frame" implies border = 1 pixel nsHTMLValue frameValue; aAttributes->GetAttribute(nsHTMLAtoms::frame, frameValue); if (frameValue.GetUnit() != eHTMLUnit_Null) borderValue.SetPixelValue(1); } - if ((borderValue.GetUnit() == eHTMLUnit_Pixel) || - (borderValue.GetUnit() == eHTMLUnit_Empty)) { + if (borderValue.GetUnit() != eHTMLUnit_Null) { nsStyleSpacing* spacing = (nsStyleSpacing*) aContext->GetMutableStyleData(eStyleStruct_Spacing); nsStyleTable *tableStyle = (nsStyleTable*) @@ -1055,7 +1035,7 @@ MapTableBorderInto(const nsIHTMLMappedAttributes* aAttributes, float p2t; aPresContext->GetScaledPixelsToTwips(&p2t); nsStyleCoord twips; - if (borderValue.GetUnit() == eHTMLUnit_Empty) { + if (borderValue.GetUnit() != eHTMLUnit_Pixel) { tableStyle->mRules=NS_STYLE_TABLE_RULES_ALL; // non-0 values of border imply default rules=all twips.SetCoordValue(NSIntPixelsToTwips(1, p2t)); } diff --git a/layout/html/content/src/nsHTMLTableRowElement.cpp b/layout/html/content/src/nsHTMLTableRowElement.cpp index baca96d727be..194b3de251c8 100644 --- a/layout/html/content/src/nsHTMLTableRowElement.cpp +++ b/layout/html/content/src/nsHTMLTableRowElement.cpp @@ -497,20 +497,23 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers with default=0*/ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents or proportions */ else if (aAttribute == nsHTMLAtoms::width) { - nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -519,13 +522,10 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::valign) { if (nsGenericHTMLElement::ParseTableVAlignValue(aValue, aResult)) { diff --git a/layout/html/content/src/nsHTMLTableSectionElement.cpp b/layout/html/content/src/nsHTMLTableSectionElement.cpp index 13c619fdfa10..437f65aaec9b 100644 --- a/layout/html/content/src/nsHTMLTableSectionElement.cpp +++ b/layout/html/content/src/nsHTMLTableSectionElement.cpp @@ -225,14 +225,16 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, */ /* attributes that resolve to integers */ if (aAttribute == nsHTMLAtoms::choff) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* attributes that resolve to integers or percents */ else if (aAttribute == nsHTMLAtoms::height) { - nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } /* other attributes */ @@ -241,13 +243,10 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } } - else if (aAttribute == nsHTMLAtoms::background) { - aResult.SetStringValue(aValue); - return NS_CONTENT_ATTR_HAS_VALUE; - } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseColor(aValue, mInner.mDocument, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::valign) { if (nsGenericHTMLElement::ParseTableVAlignValue(aValue, aResult)) { diff --git a/layout/html/content/src/nsHTMLTextAreaElement.cpp b/layout/html/content/src/nsHTMLTextAreaElement.cpp index fbb06b2d1e0a..51c068fa5fa1 100644 --- a/layout/html/content/src/nsHTMLTextAreaElement.cpp +++ b/layout/html/content/src/nsHTMLTextAreaElement.cpp @@ -344,20 +344,23 @@ nsHTMLTextAreaElement::StringToAttribute(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::cols) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::readonly) { aResult.SetEmptyValue(); return NS_CONTENT_ATTR_HAS_VALUE; } else if (aAttribute == nsHTMLAtoms::rows) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } else if (aAttribute == nsHTMLAtoms::tabindex) { - nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 0, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } diff --git a/layout/html/content/src/nsHTMLUListElement.cpp b/layout/html/content/src/nsHTMLUListElement.cpp index e9de64b0bf1e..b73f7652f2bc 100644 --- a/layout/html/content/src/nsHTMLUListElement.cpp +++ b/layout/html/content/src/nsHTMLUListElement.cpp @@ -137,22 +137,19 @@ nsHTMLUListElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::type) { - if (!nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, - aResult)) { - if (!nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, - kOldListTypeTable, aResult)) { - aResult.SetIntValue(NS_STYLE_LIST_STYLE_BASIC, eHTMLUnit_Enumerated); - } + if (nsGenericHTMLElement::ParseEnumValue(aValue, kListTypeTable, + aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } + if (nsGenericHTMLElement::ParseCaseSensitiveEnumValue(aValue, + kOldListTypeTable, aResult)) { + return NS_CONTENT_ATTR_HAS_VALUE; } - return NS_CONTENT_ATTR_HAS_VALUE; } if (aAttribute == nsHTMLAtoms::start) { - nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer); - return NS_CONTENT_ATTR_HAS_VALUE; - } - if (aAttribute == nsHTMLAtoms::compact) { - aResult.SetEmptyValue(); - return NS_CONTENT_ATTR_NO_VALUE; + if (nsGenericHTMLElement::ParseValue(aValue, 1, aResult, eHTMLUnit_Integer)) { + return NS_CONTENT_ATTR_HAS_VALUE; + } } return NS_CONTENT_ATTR_NOT_THERE; } @@ -197,10 +194,13 @@ MapAttributesInto(const nsIHTMLMappedAttributes* aAttributes, if (value.GetUnit() == eHTMLUnit_Enumerated) { list->mListStyleType = value.GetIntValue(); } + else if (value.GetUnit() == eHTMLUnit_Null) { + list->mListStyleType = NS_STYLE_LIST_STYLE_BASIC; + } // compact: empty aAttributes->GetAttribute(nsHTMLAtoms::compact, value); - if (value.GetUnit() == eHTMLUnit_Empty) { + if (value.GetUnit() != eHTMLUnit_Null) { // XXX set } }