Make ParseAttribute handle namespaced attributes too, since SVG needs to

ParseAttribute things like xlink:href.  Bug 314568, r=sicking, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2005-11-29 16:37:15 +00:00
parent fe494a9f14
commit 6d003a9d96
39 changed files with 687 additions and 532 deletions

View File

@ -4033,8 +4033,7 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
NS_ENSURE_SUCCESS(rv, rv);
nsAttrValue attrValue;
if (aNamespaceID != kNameSpaceID_None ||
!ParseAttribute(aName, aValue, attrValue)) {
if (!ParseAttribute(aNamespaceID, aName, aValue, attrValue)) {
attrValue.SetTo(aValue);
}
@ -4131,11 +4130,13 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
}
PRBool
nsGenericElement::ParseAttribute(nsIAtom* aAttribute,
nsGenericElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == GetIDAttributeName() && !aValue.IsEmpty()) {
if (aNamespaceID == kNameSpaceID_None &&
aAttribute == GetIDAttributeName() && !aValue.IsEmpty()) {
// Store id as an atom. id="" means that the element has no id,
// not that it has an emptystring as the id.
aResult.ParseAtom(aValue);

View File

@ -727,12 +727,14 @@ protected:
* attribute. Called by SetAttr(). Note that at the moment we only do this
* for attributes in the null namespace (kNameSpaceID_None).
*
* @param aNamespaceID the namespace of the attribute to convert
* @param aAttribute the attribute to convert
* @param aValue the string value to convert
* @param aResult the nsAttrValue [OUT]
* @return PR_TRUE if the parsing was successful, PR_FALSE otherwise
*/
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);

View File

@ -2027,36 +2027,40 @@ nsGenericHTMLElement::IsContentOfType(PRUint32 aFlags) const
PRBool
nsGenericHTMLElement::ParseAttribute(nsIAtom* aAttribute,
nsGenericHTMLElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::dir) {
return aResult.ParseEnumValue(aValue, kDirTable);
}
if (aAttribute == nsHTMLAtoms::style) {
ParseStyleAttribute(this, mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML),
aValue, aResult);
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::kClass) {
aResult.ParseAtomArray(aValue);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::dir) {
return aResult.ParseEnumValue(aValue, kDirTable);
}
if (aAttribute == nsHTMLAtoms::style) {
ParseStyleAttribute(this, mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML),
aValue, aResult);
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::kClass) {
aResult.ParseAtomArray(aValue);
return PR_TRUE;
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::tabindex) {
return aResult.ParseIntWithBounds(aValue, -32768, 32767);
}
if (aAttribute == nsHTMLAtoms::name && !aValue.IsEmpty()) {
// Store name as an atom. name="" means that the element has no name,
// not that it has an emptystring as the name.
aResult.ParseAtom(aValue);
return PR_TRUE;
}
}
if (aAttribute == nsHTMLAtoms::tabindex) {
return aResult.ParseIntWithBounds(aValue, -32768, 32767);
}
if (aAttribute == nsHTMLAtoms::name && !aValue.IsEmpty()) {
// Store name as an atom. name="" means that the element has no name,
// not that it has an emptystring as the name.
aResult.ParseAtom(aValue);
return PR_TRUE;
}
return nsGenericElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
PRBool

View File

@ -245,18 +245,8 @@ public:
NS_IMETHOD SetInlineStyleRule(nsICSSStyleRule* aStyleRule, PRBool aNotify);
already_AddRefed<nsIURI> GetBaseURI() const;
//----------------------------------------
/**
* Convert an attribute string value to attribute type based on the type of
* attribute. Called by SetAttr().
*
* @param aAttribute to attribute to convert
* @param aValue the string value to convert
* @param aResult the nsAttrValue [OUT]
* @return PR_TRUE if the parsing was successful, PR_FALSE otherwise
* @see nsGenericHTMLElement::SetAttr
*/
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);

View File

@ -96,7 +96,8 @@ public:
nsIAtom* aPrefix, const nsAString& aValue,
PRBool aNotify);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -191,19 +192,23 @@ NS_IMPL_STRING_ATTR(nsHTMLAppletElement, Width, width)
NS_IMPL_INT_ATTR(nsHTMLAppletElement, TabIndex, tabindex)
PRBool
nsHTMLAppletElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLAppletElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
return nsGenericHTMLElement::ParseAlignValue(aValue, aResult);
}
if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::align) {
return nsGenericHTMLElement::ParseAlignValue(aValue, aResult);
}
if (nsGenericHTMLElement::ParseImageAttribute(aAttribute,
aValue, aResult)) {
return PR_TRUE;
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -65,7 +65,8 @@ public:
// nsIDOMHTMLBRElement
NS_DECL_NSIDOMHTMLBRELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -110,15 +111,17 @@ static const nsAttrValue::EnumTable kClearTable[] = {
};
PRBool
nsHTMLBRElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLBRElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::clear) {
if (aAttribute == nsHTMLAtoms::clear && aNamespaceID == kNameSpaceID_None) {
return aResult.ParseEnumValue(aValue, kClearTable);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -106,7 +106,8 @@ public:
// nsIDOMHTMLBodyElement
NS_DECL_NSIDOMHTMLBODYELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
@ -387,27 +388,31 @@ nsHTMLBodyElement::SetBgColor(const nsAString& aBgColor)
}
PRBool
nsHTMLBodyElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLBodyElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::bgcolor ||
aAttribute == nsHTMLAtoms::text ||
aAttribute == nsHTMLAtoms::link ||
aAttribute == nsHTMLAtoms::alink ||
aAttribute == nsHTMLAtoms::vlink) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::marginwidth ||
aAttribute == nsHTMLAtoms::marginheight ||
aAttribute == nsHTMLAtoms::topmargin ||
aAttribute == nsHTMLAtoms::bottommargin ||
aAttribute == nsHTMLAtoms::leftmargin ||
aAttribute == nsHTMLAtoms::rightmargin) {
return aResult.ParseIntWithBounds(aValue, 0);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::bgcolor ||
aAttribute == nsHTMLAtoms::text ||
aAttribute == nsHTMLAtoms::link ||
aAttribute == nsHTMLAtoms::alink ||
aAttribute == nsHTMLAtoms::vlink) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::marginwidth ||
aAttribute == nsHTMLAtoms::marginheight ||
aAttribute == nsHTMLAtoms::topmargin ||
aAttribute == nsHTMLAtoms::bottommargin ||
aAttribute == nsHTMLAtoms::leftmargin ||
aAttribute == nsHTMLAtoms::rightmargin) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
void

View File

@ -98,7 +98,8 @@ public:
// nsIContent overrides...
virtual void SetFocus(nsPresContext* aPresContext);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
@ -262,11 +263,12 @@ static const nsAttrValue::EnumTable kButtonTypeTable[] = {
};
PRBool
nsHTMLButtonElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLButtonElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::type) {
if (aAttribute == nsHTMLAtoms::type && kNameSpaceID_None == aNamespaceID) {
// XXX ARG!! This is major evilness. ParseAttribute
// shouldn't set members. Override SetAttr instead
PRBool res = aResult.ParseEnumValue(aValue, kButtonTypeTable);
@ -276,7 +278,8 @@ nsHTMLButtonElement::ParseAttribute(nsIAtom* aAttribute,
return res;
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsresult

View File

@ -89,7 +89,10 @@ public:
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
PRBool ParseAttribute(nsIAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult);
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, PRInt32 aModType) const;
// SetAttr override. C++ is stupid, so have to override both
@ -238,20 +241,27 @@ nsHTMLCanvasElement::IsAttributeMapped(const nsIAtom* aAttribute) const
}
PRBool
nsHTMLCanvasElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLCanvasElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height))
if (aNamespaceID == kNameSpaceID_None)
{
return aResult.ParseIntWithBounds(aValue, 0);
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height))
{
return aResult.ParseIntWithBounds(aValue, 0);
}
if (ParseImageAttribute(aAttribute, aValue, aResult))
{
return PR_TRUE;
}
}
if (ParseImageAttribute(aAttribute, aValue, aResult))
return PR_TRUE;
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}

View File

@ -64,7 +64,8 @@ public:
// nsIDOMHTMLDivElement
NS_DECL_NSIDOMHTMLDIVELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -104,29 +105,34 @@ NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align)
PRBool
nsHTMLDivElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLDivElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (mNodeInfo->Equals(nsHTMLAtoms::marquee)) {
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if ((aAttribute == nsHTMLAtoms::hspace) ||
(aAttribute == nsHTMLAtoms::vspace)) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aNamespaceID == kNameSpaceID_None) {
if (mNodeInfo->Equals(nsHTMLAtoms::marquee)) {
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if ((aAttribute == nsHTMLAtoms::hspace) ||
(aAttribute == nsHTMLAtoms::vspace)) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
if (mNodeInfo->Equals(nsHTMLAtoms::div) &&
aAttribute == nsHTMLAtoms::align) {
return ParseDivAlignValue(aValue, aResult);
}
}
if (mNodeInfo->Equals(nsHTMLAtoms::div) && aAttribute == nsHTMLAtoms::align) {
return ParseDivAlignValue(aValue, aResult);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -69,7 +69,8 @@ public:
// nsIDOMHTMLFontElement
NS_DECL_NSIDOMHTMLFONTELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -135,30 +136,34 @@ static const nsAttrValue::EnumTable kRelFontSizeTable[] = {
PRBool
nsHTMLFontElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLFontElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::size) {
nsAutoString tmp(aValue);
tmp.CompressWhitespace(PR_TRUE, PR_TRUE);
PRUnichar ch = tmp.IsEmpty() ? 0 : tmp.First();
if ((ch == '+' || ch == '-') &&
aResult.ParseEnumValue(aValue, kRelFontSizeTable)) {
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::size) {
nsAutoString tmp(aValue);
tmp.CompressWhitespace(PR_TRUE, PR_TRUE);
PRUnichar ch = tmp.IsEmpty() ? 0 : tmp.First();
if ((ch == '+' || ch == '-') &&
aResult.ParseEnumValue(aValue, kRelFontSizeTable)) {
return PR_TRUE;
}
return aResult.ParseIntValue(aValue);
}
if (aAttribute == nsHTMLAtoms::pointSize ||
aAttribute == nsHTMLAtoms::fontWeight) {
return aResult.ParseIntValue(aValue);
}
if (aAttribute == nsHTMLAtoms::color) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
return aResult.ParseIntValue(aValue);
}
if (aAttribute == nsHTMLAtoms::pointSize ||
aAttribute == nsHTMLAtoms::fontWeight) {
return aResult.ParseIntValue(aValue);
}
if (aAttribute == nsHTMLAtoms::color) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -199,7 +199,8 @@ public:
nsIFormControl* aRadio);
// nsIContent
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsresult HandleDOMEvent(nsPresContext* aPresContext,
@ -646,18 +647,22 @@ static const nsAttrValue::EnumTable kFormEnctypeTable[] = {
};
PRBool
nsHTMLFormElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLFormElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::method) {
return aResult.ParseEnumValue(aValue, kFormMethodTable);
}
if (aAttribute == nsHTMLAtoms::enctype) {
return aResult.ParseEnumValue(aValue, kFormEnctypeTable);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::method) {
return aResult.ParseEnumValue(aValue, kFormMethodTable);
}
if (aAttribute == nsHTMLAtoms::enctype) {
return aResult.ParseEnumValue(aValue, kFormEnctypeTable);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsresult

View File

@ -66,7 +66,8 @@ public:
NS_DECL_NSIDOMHTMLFRAMEELEMENT
// nsIContent
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -119,27 +120,31 @@ nsHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
}
PRBool
nsHTMLFrameElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLFrameElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, nsGenericHTMLFrameElement::GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::marginwidth) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::marginheight) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::scrolling) {
return ParseScrollingValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::marginwidth) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::marginheight) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::scrolling) {
return ParseScrollingValue(aValue, aResult);
}
}
return nsGenericHTMLFrameElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
aValue, aResult);
}
static void

View File

@ -82,7 +82,8 @@ public:
NS_IMETHOD GetRowSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
NS_IMETHOD GetColSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
@ -258,21 +259,25 @@ nsHTMLFrameSetElement::GetColSpec(PRInt32 *aNumValues,
PRBool
nsHTMLFrameSetElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLFrameSetElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return nsGenericHTMLElement::ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::border) {
return aResult.ParseIntWithBounds(aValue, 0, 100);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return nsGenericHTMLElement::ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::border) {
return aResult.ParseIntWithBounds(aValue, 0, 100);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsChangeHint

View File

@ -70,7 +70,8 @@ public:
// nsIDOMNSHTMLHRElement
NS_DECL_NSIDOMNSHTMLHRELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -120,24 +121,28 @@ static const nsAttrValue::EnumTable kAlignTable[] = {
};
PRBool
nsHTMLHRElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLHRElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 1, 1000);
}
if (aAttribute == nsHTMLAtoms::align) {
return aResult.ParseEnumValue(aValue, kAlignTable);
}
if (aAttribute == nsHTMLAtoms::color) {
return aResult.ParseColor(aValue, GetOwnerDoc());
if (aAttribute == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 1, 1000);
}
if (aAttribute == nsHTMLAtoms::align) {
return aResult.ParseEnumValue(aValue, kAlignTable);
}
if (aAttribute == nsHTMLAtoms::color) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -65,7 +65,8 @@ public:
// nsIDOMHTMLHeadingElement
NS_DECL_NSIDOMHTMLHEADINGELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -104,15 +105,17 @@ NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align)
PRBool
nsHTMLHeadingElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLHeadingElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
if (aAttribute == nsHTMLAtoms::align && aNamespaceID == kNameSpaceID_None) {
return ParseDivAlignValue(aValue, aResult);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -67,7 +67,8 @@ public:
NS_DECL_NSIDOMHTMLIFRAMEELEMENT
// nsIContent
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -119,33 +120,37 @@ nsHTMLIFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
}
PRBool
nsHTMLIFrameElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLIFrameElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::marginwidth) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::marginheight) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::scrolling) {
return ParseScrollingValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::marginwidth) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::marginheight) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::frameborder) {
return ParseFrameborderValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::scrolling) {
return ParseScrollingValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
}
return nsGenericHTMLFrameElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLFrameElement::ParseAttribute(aNamespaceID, aAttribute,
aValue, aResult);
}
static void

View File

@ -113,7 +113,8 @@ public:
PRUint32 argc, jsval *argv);
// nsIContent
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
@ -421,23 +422,27 @@ nsHTMLImageElement::SetWidth(PRInt32 aWidth)
}
PRBool
nsHTMLImageElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLImageElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetTo(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
return PR_TRUE;
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::src) {
static const char* kWhitespace = " \n\r\t\b";
aResult.SetTo(nsContentUtils::TrimCharsInSet(kWhitespace, aValue));
return PR_TRUE;
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -180,7 +180,8 @@ public:
virtual void SetFocus(nsPresContext* aPresContext);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
@ -1728,56 +1729,60 @@ static const nsAttrValue::EnumTable kInputTypeTable[] = {
};
PRBool
nsHTMLInputElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLInputElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::type) {
// XXX ARG!! This is major evilness. ParseAttribute
// shouldn't set members. Override SetAttr instead
if (!aResult.ParseEnumValue(aValue, kInputTypeTable)) {
mType = NS_FORM_INPUT_TEXT;
return PR_FALSE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::type) {
// XXX ARG!! This is major evilness. ParseAttribute
// shouldn't set members. Override SetAttr instead
if (!aResult.ParseEnumValue(aValue, kInputTypeTable)) {
mType = NS_FORM_INPUT_TEXT;
return PR_FALSE;
}
mType = aResult.GetEnumValue();
if (mType == NS_FORM_INPUT_FILE) {
// If the type is being changed to file, set the element value
// to the empty string. This is for security.
// Call SetValueInternal so that this doesn't accidentally get caught
// in the security checks in SetValue.
SetValueInternal(EmptyString(), nsnull);
}
return PR_TRUE;
}
mType = aResult.GetEnumValue();
if (mType == NS_FORM_INPUT_FILE) {
// If the type is being changed to file, set the element value
// to the empty string. This is for security.
// Call SetValueInternal so that this doesn't accidentally get caught
// in the security checks in SetValue.
SetValueInternal(EmptyString(), nsnull);
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::maxlength) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::border) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
// We have to call |ParseImageAttribute| unconditionally since we
// don't know if we're going to have a type="image" attribute yet,
// (or could have it set dynamically in the future). See bug
// 214077.
return PR_TRUE;
}
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::maxlength) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::border) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
// We have to call |ParseImageAttribute| unconditionally since we
// don't know if we're going to have a type="image" attribute yet,
// (or could have it set dynamically in the future). See bug
// 214077.
return PR_TRUE;
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
NS_IMETHODIMP

View File

@ -65,7 +65,8 @@ public:
// nsIDOMHTMLLIElement
NS_DECL_NSIDOMHTMLLIELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -122,19 +123,24 @@ static const nsAttrValue::EnumTable kOrderedListItemTypeTable[] = {
};
PRBool
nsHTMLLIElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLLIElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable, PR_TRUE) ||
aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable);
}
if (aAttribute == nsHTMLAtoms::value) {
return aResult.ParseIntWithBounds(aValue, 0);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kOrderedListItemTypeTable,
PR_TRUE) ||
aResult.ParseEnumValue(aValue, kUnorderedListItemTypeTable);
}
if (aAttribute == nsHTMLAtoms::value) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -84,7 +84,8 @@ public:
virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
PRBool aNullParent = PR_TRUE);
virtual void SetFocus(nsPresContext* aPresContext);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
@ -154,15 +155,17 @@ static const nsAttrValue::EnumTable kAlignTable[] = {
};
PRBool
nsHTMLLegendElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLLegendElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
if (aAttribute == nsHTMLAtoms::align && aNamespaceID == kNameSpaceID_None) {
return aResult.ParseEnumValue(aValue, kAlignTable);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsChangeHint

View File

@ -75,7 +75,8 @@ public:
// nsIDOMHTMLUListElement
// fully declared by NS_DECL_NSIDOMHTMLOLISTELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -147,22 +148,26 @@ nsAttrValue::EnumTable kOldListTypeTable[] = {
};
PRBool
nsHTMLSharedListElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLSharedListElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (mNodeInfo->Equals(nsHTMLAtoms::ol) ||
mNodeInfo->Equals(nsHTMLAtoms::ul)) {
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kListTypeTable) ||
aResult.ParseEnumValue(aValue, kOldListTypeTable, PR_TRUE);
}
if (aAttribute == nsHTMLAtoms::start) {
return aResult.ParseIntValue(aValue);
if (aNamespaceID == kNameSpaceID_None) {
if (mNodeInfo->Equals(nsHTMLAtoms::ol) ||
mNodeInfo->Equals(nsHTMLAtoms::ul)) {
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kListTypeTable) ||
aResult.ParseEnumValue(aValue, kOldListTypeTable, PR_TRUE);
}
if (aAttribute == nsHTMLAtoms::start) {
return aResult.ParseIntValue(aValue);
}
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -98,7 +98,8 @@ public:
virtual void DoneAddingChildren(PRBool aHaveNotified);
virtual PRBool IsDoneAddingChildren();
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -365,18 +366,22 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
}
PRBool
nsHTMLObjectElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLObjectElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
}
}
return nsGenericHTMLFormElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLFormElement::ParseAttribute(aNamespaceID, aAttribute,
aValue, aResult);
}
static void

View File

@ -68,7 +68,8 @@ public:
// nsIDOMHTMLParagraphElement
NS_DECL_NSIDOMHTMLPARAGRAPHELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -108,15 +109,17 @@ NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align)
PRBool
nsHTMLParagraphElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLParagraphElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
if (aAttribute == nsHTMLAtoms::align && aNamespaceID == kNameSpaceID_None) {
return ParseDivAlignValue(aValue, aResult);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -70,7 +70,8 @@ public:
NS_IMETHOD GetWidth(PRInt32* aWidth);
NS_IMETHOD SetWidth(PRInt32 aWidth);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
@ -109,18 +110,22 @@ NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width)
PRBool
nsHTMLPreElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLPreElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseIntWithBounds(aValue, 0);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -249,7 +249,8 @@ public:
virtual void DoneAddingChildren(PRBool aHaveNotified);
virtual PRBool IsDoneAddingChildren();
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -1695,14 +1696,16 @@ nsHTMLSelectElement::DoneAddingChildren(PRBool aHaveNotified)
}
PRBool
nsHTMLSelectElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLSelectElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::size) {
if (aAttribute == nsHTMLAtoms::size && kNameSpaceID_None == aNamespaceID) {
return aResult.ParseIntWithBounds(aValue, 0);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -132,8 +132,9 @@ public:
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
virtual PRUint32 GetDesiredIMEState();
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -283,46 +284,50 @@ NS_IMPL_URI_ATTR(nsHTMLSharedElement, Href, href)
NS_IMPL_STRING_ATTR(nsHTMLSharedElement, Target, target)
PRBool
nsHTMLSharedElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLSharedElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (mNodeInfo->Equals(nsHTMLAtoms::embed)) {
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
if (mNodeInfo->Equals(nsHTMLAtoms::embed)) {
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
}
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::width ||
aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
}
}
else if (mNodeInfo->Equals(nsHTMLAtoms::spacer)) {
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntWithBounds(aValue, 0);
else if (mNodeInfo->Equals(nsHTMLAtoms::dir) ||
mNodeInfo->Equals(nsHTMLAtoms::menu)) {
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kListTypeTable);
}
if (aAttribute == nsHTMLAtoms::start) {
return aResult.ParseIntWithBounds(aValue, 1);
}
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::width ||
aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
}
else if (mNodeInfo->Equals(nsHTMLAtoms::dir) ||
mNodeInfo->Equals(nsHTMLAtoms::menu)) {
if (aAttribute == nsHTMLAtoms::type) {
return aResult.ParseEnumValue(aValue, kListTypeTable);
}
if (aAttribute == nsHTMLAtoms::start) {
return aResult.ParseIntWithBounds(aValue, 1);
}
}
else if (mNodeInfo->Equals(nsHTMLAtoms::basefont)) {
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntValue(aValue);
else if (mNodeInfo->Equals(nsHTMLAtoms::basefont)) {
if (aAttribute == nsHTMLAtoms::size) {
return aResult.ParseIntValue(aValue);
}
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
// spacer element code

View File

@ -91,7 +91,8 @@ public:
NS_IMETHOD SaveState();
virtual PRBool RestoreState(nsPresState* aState);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -204,18 +205,22 @@ nsHTMLObjectElement::GetContentDocument(nsIDOMDocument** aContentDocument)
}
PRBool
nsHTMLObjectElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLObjectElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::align) {
return ParseAlignValue(aValue, aResult);
}
if (ParseImageAttribute(aAttribute, aValue, aResult)) {
return PR_TRUE;
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -65,7 +65,8 @@ public:
// nsIDOMHTMLTableCaptionElement
NS_DECL_NSIDOMHTMLTABLECAPTIONELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -113,15 +114,17 @@ static const nsAttrValue::EnumTable kCaptionAlignTable[] = {
};
PRBool
nsHTMLTableCaptionElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableCaptionElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::align) {
if (aAttribute == nsHTMLAtoms::align && aNamespaceID == kNameSpaceID_None) {
return aResult.ParseEnumValue(aValue, kCaptionAlignTable);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static

View File

@ -68,7 +68,8 @@ public:
// nsIDOMHTMLTableCellElement
NS_DECL_NSIDOMHTMLTABLECELLELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -261,60 +262,65 @@ static const nsAttrValue::EnumTable kCellScopeTable[] = {
#define MAX_COLSPAN 1000 // limit as IE and opera do
PRBool
nsHTMLTableCellElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableCellElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
/* ignore these attributes, stored simply as strings
abbr, axis, ch, headers
*/
if (aAttribute == nsHTMLAtoms::charoff) {
/* attributes that resolve to integers with a min of 0 */
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::colspan) {
PRBool res = aResult.ParseIntWithBounds(aValue, -1);
if (res) {
PRInt32 val = aResult.GetIntegerValue();
// reset large colspan values as IE and opera do
// quirks mode does not honor the special html 4 value of 0
if (val > MAX_COLSPAN || val < 0 || (0 == val && InNavQuirksMode(GetOwnerDoc()))) {
aResult.SetTo(1);
}
if (aNamespaceID == kNameSpaceID_None) {
/* ignore these attributes, stored simply as strings
abbr, axis, ch, headers
*/
if (aAttribute == nsHTMLAtoms::charoff) {
/* attributes that resolve to integers with a min of 0 */
return aResult.ParseIntWithBounds(aValue, 0);
}
return res;
}
if (aAttribute == nsHTMLAtoms::rowspan) {
PRBool res = aResult.ParseIntWithBounds(aValue, -1, MAX_ROWSPAN);
if (res) {
PRInt32 val = aResult.GetIntegerValue();
// quirks mode does not honor the special html 4 value of 0
if (val < 0 || (0 == val && InNavQuirksMode(GetOwnerDoc()))) {
aResult.SetTo(1);
if (aAttribute == nsHTMLAtoms::colspan) {
PRBool res = aResult.ParseIntWithBounds(aValue, -1);
if (res) {
PRInt32 val = aResult.GetIntegerValue();
// reset large colspan values as IE and opera do
// quirks mode does not honor the special html 4 value of 0
if (val > MAX_COLSPAN || val < 0 ||
(0 == val && InNavQuirksMode(GetOwnerDoc()))) {
aResult.SetTo(1);
}
}
return res;
}
if (aAttribute == nsHTMLAtoms::rowspan) {
PRBool res = aResult.ParseIntWithBounds(aValue, -1, MAX_ROWSPAN);
if (res) {
PRInt32 val = aResult.GetIntegerValue();
// quirks mode does not honor the special html 4 value of 0
if (val < 0 || (0 == val && InNavQuirksMode(GetOwnerDoc()))) {
aResult.SetTo(1);
}
}
return res;
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::scope) {
return aResult.ParseEnumValue(aValue, kCellScopeTable);
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
}
return res;
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::scope) {
return aResult.ParseEnumValue(aValue, kCellScopeTable);
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static

View File

@ -69,7 +69,8 @@ public:
// nsIDOMHTMLTableColElement
NS_DECL_NSIDOMHTMLTABLECOLELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -114,29 +115,33 @@ NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Width, width)
PRBool
nsHTMLTableColElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableColElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
/* ignore these attributes, stored simply as strings ch */
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::span) {
/* protection from unrealistic large colspan values */
return aResult.ParseIntWithBounds(aValue, 1, MAX_COLSPAN);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_TRUE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
/* ignore these attributes, stored simply as strings ch */
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::span) {
/* protection from unrealistic large colspan values */
return aResult.ParseIntWithBounds(aValue, 1, MAX_COLSPAN);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_TRUE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static

View File

@ -81,7 +81,8 @@ public:
// nsIDOMHTMLTableElement
NS_DECL_NSIDOMHTMLTABLEELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -876,62 +877,69 @@ static const nsAttrValue::EnumTable kLayoutTable[] = {
PRBool
nsHTMLTableElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
/* ignore summary, just a string */
if (aAttribute == nsHTMLAtoms::cellspacing ||
aAttribute == nsHTMLAtoms::cellpadding) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::border) {
if (!aResult.ParseIntWithBounds(aValue, 0)) {
// XXX this should really be NavQuirks only to allow non numeric value
aResult.SetTo(1);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::cellspacing ||
aAttribute == nsHTMLAtoms::cellpadding) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
if (aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE)) {
// treat 0 width as auto
nsAttrValue::ValueType type = aResult.Type();
if ((type == nsAttrValue::eInteger && aResult.GetIntegerValue() == 0) ||
(type == nsAttrValue::ePercent && aResult.GetPercentValue() == 0.0f)) {
return PR_FALSE;
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::border) {
if (!aResult.ParseIntWithBounds(aValue, 0)) {
// XXX this should really be NavQuirks only to allow non numeric value
aResult.SetTo(1);
}
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
if (aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE)) {
// treat 0 width as auto
nsAttrValue::ValueType type = aResult.Type();
if ((type == nsAttrValue::eInteger &&
aResult.GetIntegerValue() == 0) ||
(type == nsAttrValue::ePercent &&
aResult.GetPercentValue() == 0.0f)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor ||
aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frame) {
return aResult.ParseEnumValue(aValue, kFrameTable);
}
if (aAttribute == nsHTMLAtoms::layout) {
return aResult.ParseEnumValue(aValue, kLayoutTable);
}
if (aAttribute == nsHTMLAtoms::rules) {
return aResult.ParseEnumValue(aValue, kRulesTable);
}
if (aAttribute == nsHTMLAtoms::hspace ||
aAttribute == nsHTMLAtoms::vspace) {
return aResult.ParseIntWithBounds(aValue, 0);
}
return PR_TRUE;
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor ||
aAttribute == nsHTMLAtoms::bordercolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::frame) {
return aResult.ParseEnumValue(aValue, kFrameTable);
}
if (aAttribute == nsHTMLAtoms::layout) {
return aResult.ParseEnumValue(aValue, kLayoutTable);
}
if (aAttribute == nsHTMLAtoms::rules) {
return aResult.ParseEnumValue(aValue, kRulesTable);
}
if (aAttribute == nsHTMLAtoms::hspace ||
aAttribute == nsHTMLAtoms::vspace) {
return aResult.ParseIntWithBounds(aValue, 0);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -76,7 +76,8 @@ public:
// nsIDOMHTMLTableRowElement
NS_DECL_NSIDOMHTMLTABLEROWELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -385,7 +386,8 @@ NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableRowElement, VAlign, valign, "middle
PRBool
nsHTMLTableRowElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableRowElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
@ -395,26 +397,29 @@ nsHTMLTableRowElement::ParseAttribute(nsIAtom* aAttribute,
* ch
*/
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::width) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static

View File

@ -71,7 +71,8 @@ public:
// nsIDOMHTMLTableSectionElement
NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -232,30 +233,34 @@ nsHTMLTableSectionElement::DeleteRow(PRInt32 aValue)
}
PRBool
nsHTMLTableSectionElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTableSectionElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
/* ignore these attributes, stored simply as strings
ch
*/
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
if (aNamespaceID == kNameSpaceID_None) {
/* ignore these attributes, stored simply as strings
ch
*/
if (aAttribute == nsHTMLAtoms::charoff) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::height) {
return aResult.ParseSpecialIntValue(aValue, PR_TRUE, PR_FALSE);
}
if (aAttribute == nsHTMLAtoms::align) {
return ParseTableCellHAlignValue(aValue, aResult);
}
if (aAttribute == nsHTMLAtoms::bgcolor) {
return aResult.ParseColor(aValue, GetOwnerDoc());
}
if (aAttribute == nsHTMLAtoms::valign) {
return ParseTableVAlignValue(aValue, aResult);
}
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static

View File

@ -121,7 +121,8 @@ public:
PRBool aNotify);
virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify);
virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
@ -491,17 +492,21 @@ nsHTMLTextAreaElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify)
}
PRBool
nsHTMLTextAreaElement::ParseAttribute(nsIAtom* aAttribute,
nsHTMLTextAreaElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsHTMLAtoms::cols) {
return aResult.ParseIntWithBounds(aValue, 0);
}
if (aAttribute == nsHTMLAtoms::rows) {
return aResult.ParseIntWithBounds(aValue, 0);
}
}
if (aAttribute == nsHTMLAtoms::rows) {
return aResult.ParseIntWithBounds(aValue, 0);
}
return nsGenericHTMLElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
static void

View File

@ -165,13 +165,14 @@ nsSVGElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
}
PRBool
nsSVGElement::ParseAttribute(nsIAtom* aAttribute,
nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
// Parse value
nsCOMPtr<nsISVGValue> svg_value;
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aAttribute);
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aAttribute, aNamespaceID);
if (val) {
// Found the attr in the list.
if (val->Type() == nsAttrValue::eSVGValue) {
@ -180,7 +181,7 @@ nsSVGElement::ParseAttribute(nsIAtom* aAttribute,
}
else {
// Could be a mapped attribute.
svg_value = GetMappedAttribute(kNameSpaceID_None, aAttribute);
svg_value = GetMappedAttribute(aNamespaceID, aAttribute);
}
if (svg_value) {
@ -208,12 +209,13 @@ nsSVGElement::ParseAttribute(nsIAtom* aAttribute,
return PR_TRUE;
}
if (aAttribute == nsSVGAtoms::style) {
if (aAttribute == nsSVGAtoms::style && aNamespaceID == kNameSpaceID_None) {
nsGenericHTMLElement::ParseStyleAttribute(this, PR_TRUE, aValue, aResult);
return PR_TRUE;
}
return nsGenericElement::ParseAttribute(aAttribute, aValue, aResult);
return nsGenericElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult);
}
nsresult

View File

@ -120,9 +120,8 @@ protected:
const nsAString* aValue, PRBool aNotify);
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);
virtual PRBool ParseAttribute(PRInt32 aNamespaceID, nsIAtom* aAttribute,
const nsAString& aValue, nsAttrValue& aResult);
// Hooks for subclasses
virtual PRBool IsEventName(nsIAtom* aName);

View File

@ -1237,7 +1237,8 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
}
PRBool
nsXULElement::ParseAttribute(nsIAtom* aAttribute,
nsXULElement::ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult)
{
@ -1246,18 +1247,21 @@ nsXULElement::ParseAttribute(nsIAtom* aAttribute,
// WARNING!!
// This code is largely duplicated in nsXULPrototypeElement::SetAttrAt.
// Any changes should be made to both functions.
if (aAttribute == nsXULAtoms::style) {
nsGenericHTMLElement::ParseStyleAttribute(this, PR_TRUE, aValue,
aResult);
return PR_TRUE;
if (aNamespaceID == kNameSpaceID_None) {
if (aAttribute == nsXULAtoms::style) {
nsGenericHTMLElement::ParseStyleAttribute(this, PR_TRUE, aValue,
aResult);
return PR_TRUE;
}
if (aAttribute == nsXULAtoms::clazz) {
aResult.ParseAtomArray(aValue);
return PR_TRUE;
}
}
if (aAttribute == nsXULAtoms::clazz) {
aResult.ParseAtomArray(aValue);
return PR_TRUE;
}
if (!nsGenericElement::ParseAttribute(aAttribute, aValue, aResult)) {
if (!nsGenericElement::ParseAttribute(aNamespaceID, aAttribute, aValue,
aResult)) {
// Fall back to parsing as atom for short values
aResult.ParseStringOrAtom(aValue);
}

View File

@ -615,7 +615,8 @@ protected:
virtual nsresult AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
const nsAString* aValue, PRBool aNotify);
virtual PRBool ParseAttribute(nsIAtom* aAttribute,
virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,
const nsAString& aValue,
nsAttrValue& aResult);