Bug 244921. Backing out because it hurt Tp on btek and the codesize savings were quite meagre.

This commit is contained in:
roc+%cs.cmu.edu 2004-05-31 19:43:13 +00:00
Родитель a1ee999a29
Коммит ee12f899fb
2 изменённых файлов: 37 добавлений и 78 удалений

Просмотреть файл

@ -3075,29 +3075,15 @@ nsGenericHTMLElement::GetContentsAsText(nsAString& aText)
return NS_OK; return NS_OK;
} }
nsresult void
nsGenericHTMLElement::GetAttrHelper(nsIAtom* aAttr, nsAString& aValue)
{
GetAttr(kNameSpaceID_None, aAttr, aValue);
return NS_OK;
}
nsresult
nsGenericHTMLElement::SetAttrHelper(nsIAtom* aAttr, const nsAString& aValue)
{
return SetAttr(kNameSpaceID_None, aAttr, aValue, PR_TRUE);
}
nsresult
nsGenericHTMLElement::GetStringAttrWithDefault(nsIAtom* aAttr, nsGenericHTMLElement::GetStringAttrWithDefault(nsIAtom* aAttr,
const char* aDefault, const nsAString& aDefault,
nsAString& aResult) nsAString& aResult)
{ {
nsresult rv = GetAttr(kNameSpaceID_None, aAttr, aResult); nsresult rv = GetAttr(kNameSpaceID_None, aAttr, aResult);
if (rv == NS_CONTENT_ATTR_NOT_THERE) { if (rv == NS_CONTENT_ATTR_NOT_THERE) {
CopyASCIItoUTF16(aDefault, aResult); aResult = aDefault;
} }
return NS_OK;
} }
nsresult nsresult
@ -3110,14 +3096,7 @@ nsGenericHTMLElement::SetBoolAttr(nsIAtom* aAttr, PRBool aValue)
return UnsetAttr(kNameSpaceID_None, aAttr, PR_TRUE); return UnsetAttr(kNameSpaceID_None, aAttr, PR_TRUE);
} }
nsresult void
nsGenericHTMLElement::GetBoolAttr(nsIAtom* aAttr, PRBool* aValue)
{
*aValue = HasAttr(kNameSpaceID_None, aAttr);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aResult) nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aResult)
{ {
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr); const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
@ -3127,7 +3106,6 @@ nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aRes
else { else {
*aResult = aDefault; *aResult = aDefault;
} }
return NS_OK;
} }
nsresult nsresult
@ -3139,7 +3117,7 @@ nsGenericHTMLElement::SetIntAttr(nsIAtom* aAttr, PRInt32 aValue)
return SetAttr(kNameSpaceID_None, aAttr, value, PR_TRUE); return SetAttr(kNameSpaceID_None, aAttr, value, PR_TRUE);
} }
nsresult void
nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult) nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
{ {
nsAutoString attrValue; nsAutoString attrValue;
@ -3147,7 +3125,7 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
if (rv != NS_CONTENT_ATTR_HAS_VALUE) { if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
aResult.Truncate(); aResult.Truncate();
return NS_OK; return;
} }
nsCOMPtr<nsIURI> baseURI = GetBaseURI(); nsCOMPtr<nsIURI> baseURI = GetBaseURI();
@ -3159,7 +3137,7 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
// Just use the attr value as the result... // Just use the attr value as the result...
aResult = attrValue; aResult = attrValue;
return NS_OK; return;
} }
NS_ASSERTION(attrURI, NS_ASSERTION(attrURI,
@ -3168,7 +3146,6 @@ nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
nsCAutoString spec; nsCAutoString spec;
attrURI->GetSpec(spec); attrURI->GetSpec(spec);
CopyUTF8toUTF16(spec, aResult); CopyUTF8toUTF16(spec, aResult);
return NS_OK;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

Просмотреть файл

@ -760,29 +760,6 @@ protected:
*/ */
nsresult GetContentsAsText(nsAString& aText); nsresult GetContentsAsText(nsAString& aText);
/**
* Helpermethod for NS_IMPL_STRING_ATTR macro.
* Gets the value of an attribute, returns empty string if
* attribute isn't set. Only works for attributes in null namespace.
*
* @param aAttr name of attribute.
* @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out]
* @result always NS_OK
*/
NS_HIDDEN_(nsresult) GetAttrHelper(nsIAtom* aAttr, nsAString& aValue);
/**
* Helpermethod for NS_IMPL_STRING_ATTR macro.
* Sets the value of an attribute, returns specified default value if the
* attribute isn't set. Only works for attributes in null namespace.
*
* @param aAttr name of attribute.
* @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out]
*/
NS_HIDDEN_(nsresult) SetAttrHelper(nsIAtom* aAttr, const nsAString& aValue);
/** /**
* Helpermethod for NS_IMPL_STRING_ATTR_DEFAULT_VALUE macro. * Helpermethod for NS_IMPL_STRING_ATTR_DEFAULT_VALUE macro.
* Gets the value of an attribute, returns specified default value if the * Gets the value of an attribute, returns specified default value if the
@ -792,20 +769,10 @@ protected:
* @param aDefault default-value to return if attribute isn't set. * @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out] * @param aResult result value [out]
*/ */
NS_HIDDEN_(nsresult) GetStringAttrWithDefault(nsIAtom* aAttr, void GetStringAttrWithDefault(nsIAtom* aAttr,
const char* aDefault, const nsAString& aDefault,
nsAString& aResult); nsAString& aResult);
/**
* Helpermethod for NS_IMPL_BOOL_ATTR macro.
* Gets value of boolean attribute. Only works for attributes in null
* namespace.
*
* @param aAttr name of attribute.
* @param aValue Boolean value of attribute.
*/
NS_HIDDEN_(nsresult) GetBoolAttr(nsIAtom* aAttr, PRBool* aValue);
/** /**
* Helpermethod for NS_IMPL_BOOL_ATTR macro. * Helpermethod for NS_IMPL_BOOL_ATTR macro.
* Sets value of boolean attribute by removing attribute or setting it to * Sets value of boolean attribute by removing attribute or setting it to
@ -814,7 +781,7 @@ protected:
* @param aAttr name of attribute. * @param aAttr name of attribute.
* @param aValue Boolean value of attribute. * @param aValue Boolean value of attribute.
*/ */
NS_HIDDEN_(nsresult) SetBoolAttr(nsIAtom* aAttr, PRBool aValue); nsresult SetBoolAttr(nsIAtom* aAttr, PRBool aValue);
/** /**
* Helpermethod for NS_IMPL_INT_ATTR macro. * Helpermethod for NS_IMPL_INT_ATTR macro.
@ -826,7 +793,7 @@ protected:
* @param aDefault default-value to return if attribute isn't set. * @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out] * @param aResult result value [out]
*/ */
NS_HIDDEN_(nsresult) GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aValue); void GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aValue);
/** /**
* Helpermethod for NS_IMPL_INT_ATTR macro. * Helpermethod for NS_IMPL_INT_ATTR macro.
@ -836,7 +803,7 @@ protected:
* @param aAttr name of attribute. * @param aAttr name of attribute.
* @param aValue Integer value of attribute. * @param aValue Integer value of attribute.
*/ */
NS_HIDDEN_(nsresult) SetIntAttr(nsIAtom* aAttr, PRInt32 aValue); nsresult SetIntAttr(nsIAtom* aAttr, PRInt32 aValue);
/** /**
* Helpermethod for NS_IMPL_URI_ATTR macro. * Helpermethod for NS_IMPL_URI_ATTR macro.
@ -848,7 +815,7 @@ protected:
* @param aAttr name of attribute. * @param aAttr name of attribute.
* @param aResult result value [out] * @param aResult result value [out]
*/ */
NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsAString& aResult); void GetURIAttr(nsIAtom* aAttr, nsAString& aResult);
}; };
@ -1019,12 +986,15 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Get##_method(nsAString& aValue) \ _class::Get##_method(nsAString& aValue) \
{ \ { \
return GetAttrHelper(nsHTMLAtoms::_atom, aValue); \ GetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue); \
\
return NS_OK; \
} \ } \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Set##_method(const nsAString& aValue) \ _class::Set##_method(const nsAString& aValue) \
{ \ { \
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \ return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
PR_TRUE); \
} }
/** /**
@ -1036,12 +1006,17 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Get##_method(nsAString& aValue) \ _class::Get##_method(nsAString& aValue) \
{ \ { \
return GetStringAttrWithDefault(nsHTMLAtoms::_atom, _default, aValue);\ GetStringAttrWithDefault(nsHTMLAtoms::_atom, \
NS_LITERAL_STRING(_default), \
aValue); \
\
return NS_OK; \
} \ } \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Set##_method(const nsAString& aValue) \ _class::Set##_method(const nsAString& aValue) \
{ \ { \
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \ return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
PR_TRUE); \
} }
/** /**
@ -1053,7 +1028,9 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Get##_method(PRBool* aValue) \ _class::Get##_method(PRBool* aValue) \
{ \ { \
return GetBoolAttr(nsHTMLAtoms::_atom, aValue); \ *aValue = HasAttr(kNameSpaceID_None, nsHTMLAtoms::_atom); \
\
return NS_OK; \
} \ } \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Set##_method(PRBool aValue) \ _class::Set##_method(PRBool aValue) \
@ -1073,7 +1050,9 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Get##_method(PRInt32* aValue) \ _class::Get##_method(PRInt32* aValue) \
{ \ { \
return GetIntAttr(nsHTMLAtoms::_atom, _default, aValue); \ GetIntAttr(nsHTMLAtoms::_atom, _default, aValue); \
\
return NS_OK; \
} \ } \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Set##_method(PRInt32 aValue) \ _class::Set##_method(PRInt32 aValue) \
@ -1092,12 +1071,15 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Get##_method(nsAString& aValue) \ _class::Get##_method(nsAString& aValue) \
{ \ { \
return GetURIAttr(nsHTMLAtoms::_atom, aValue); \ GetURIAttr(nsHTMLAtoms::_atom, aValue); \
\
return NS_OK; \
} \ } \
NS_IMETHODIMP \ NS_IMETHODIMP \
_class::Set##_method(const nsAString& aValue) \ _class::Set##_method(const nsAString& aValue) \
{ \ { \
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \ return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
PR_TRUE); \
} }
/** /**