зеркало из https://github.com/mozilla/pjs.git
Bug 244921. Tweak nsGenericHTMLElement attribute exposure macros. r+sr=jst.
This commit is contained in:
Родитель
27375e9b38
Коммит
6be86b9fc2
|
@ -3075,15 +3075,29 @@ nsGenericHTMLElement::GetContentsAsText(nsAString& aText)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
nsresult
|
||||||
|
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 nsAString& aDefault,
|
const char* 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) {
|
||||||
aResult = aDefault;
|
CopyASCIItoUTF16(aDefault, aResult);
|
||||||
}
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -3096,7 +3110,14 @@ nsGenericHTMLElement::SetBoolAttr(nsIAtom* aAttr, PRBool aValue)
|
||||||
return UnsetAttr(kNameSpaceID_None, aAttr, PR_TRUE);
|
return UnsetAttr(kNameSpaceID_None, aAttr, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
nsresult
|
||||||
|
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);
|
||||||
|
@ -3106,6 +3127,7 @@ nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aRes
|
||||||
else {
|
else {
|
||||||
*aResult = aDefault;
|
*aResult = aDefault;
|
||||||
}
|
}
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
@ -3117,7 +3139,7 @@ nsGenericHTMLElement::SetIntAttr(nsIAtom* aAttr, PRInt32 aValue)
|
||||||
return SetAttr(kNameSpaceID_None, aAttr, value, PR_TRUE);
|
return SetAttr(kNameSpaceID_None, aAttr, value, PR_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
nsresult
|
||||||
nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
|
nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsAString& aResult)
|
||||||
{
|
{
|
||||||
nsAutoString attrValue;
|
nsAutoString attrValue;
|
||||||
|
@ -3125,7 +3147,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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||||
|
@ -3137,7 +3159,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;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_ASSERTION(attrURI,
|
NS_ASSERTION(attrURI,
|
||||||
|
@ -3146,6 +3168,7 @@ 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,6 +760,29 @@ 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
|
||||||
|
@ -769,10 +792,20 @@ 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]
|
||||||
*/
|
*/
|
||||||
void GetStringAttrWithDefault(nsIAtom* aAttr,
|
NS_HIDDEN_(nsresult) GetStringAttrWithDefault(nsIAtom* aAttr,
|
||||||
const nsAString& aDefault,
|
const char* 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
|
||||||
|
@ -781,7 +814,7 @@ protected:
|
||||||
* @param aAttr name of attribute.
|
* @param aAttr name of attribute.
|
||||||
* @param aValue Boolean value of attribute.
|
* @param aValue Boolean value of attribute.
|
||||||
*/
|
*/
|
||||||
nsresult SetBoolAttr(nsIAtom* aAttr, PRBool aValue);
|
NS_HIDDEN_(nsresult) SetBoolAttr(nsIAtom* aAttr, PRBool aValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpermethod for NS_IMPL_INT_ATTR macro.
|
* Helpermethod for NS_IMPL_INT_ATTR macro.
|
||||||
|
@ -793,7 +826,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]
|
||||||
*/
|
*/
|
||||||
void GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aValue);
|
NS_HIDDEN_(nsresult) GetIntAttr(nsIAtom* aAttr, PRInt32 aDefault, PRInt32* aValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpermethod for NS_IMPL_INT_ATTR macro.
|
* Helpermethod for NS_IMPL_INT_ATTR macro.
|
||||||
|
@ -803,7 +836,7 @@ protected:
|
||||||
* @param aAttr name of attribute.
|
* @param aAttr name of attribute.
|
||||||
* @param aValue Integer value of attribute.
|
* @param aValue Integer value of attribute.
|
||||||
*/
|
*/
|
||||||
nsresult SetIntAttr(nsIAtom* aAttr, PRInt32 aValue);
|
NS_HIDDEN_(nsresult) SetIntAttr(nsIAtom* aAttr, PRInt32 aValue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helpermethod for NS_IMPL_URI_ATTR macro.
|
* Helpermethod for NS_IMPL_URI_ATTR macro.
|
||||||
|
@ -815,7 +848,7 @@ protected:
|
||||||
* @param aAttr name of attribute.
|
* @param aAttr name of attribute.
|
||||||
* @param aResult result value [out]
|
* @param aResult result value [out]
|
||||||
*/
|
*/
|
||||||
void GetURIAttr(nsIAtom* aAttr, nsAString& aResult);
|
NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsAString& aResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -986,15 +1019,12 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Get##_method(nsAString& aValue) \
|
_class::Get##_method(nsAString& aValue) \
|
||||||
{ \
|
{ \
|
||||||
GetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue); \
|
return GetAttrHelper(nsHTMLAtoms::_atom, aValue); \
|
||||||
\
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
} \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Set##_method(const nsAString& aValue) \
|
_class::Set##_method(const nsAString& aValue) \
|
||||||
{ \
|
{ \
|
||||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
|
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \
|
||||||
PR_TRUE); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1006,17 +1036,12 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Get##_method(nsAString& aValue) \
|
_class::Get##_method(nsAString& aValue) \
|
||||||
{ \
|
{ \
|
||||||
GetStringAttrWithDefault(nsHTMLAtoms::_atom, \
|
return GetStringAttrWithDefault(nsHTMLAtoms::_atom, _default, aValue);\
|
||||||
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 SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
|
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \
|
||||||
PR_TRUE); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1028,9 +1053,7 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Get##_method(PRBool* aValue) \
|
_class::Get##_method(PRBool* aValue) \
|
||||||
{ \
|
{ \
|
||||||
*aValue = HasAttr(kNameSpaceID_None, nsHTMLAtoms::_atom); \
|
return GetBoolAttr(nsHTMLAtoms::_atom, aValue); \
|
||||||
\
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
} \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Set##_method(PRBool aValue) \
|
_class::Set##_method(PRBool aValue) \
|
||||||
|
@ -1050,9 +1073,7 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Get##_method(PRInt32* aValue) \
|
_class::Get##_method(PRInt32* aValue) \
|
||||||
{ \
|
{ \
|
||||||
GetIntAttr(nsHTMLAtoms::_atom, _default, aValue); \
|
return GetIntAttr(nsHTMLAtoms::_atom, _default, aValue); \
|
||||||
\
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
} \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Set##_method(PRInt32 aValue) \
|
_class::Set##_method(PRInt32 aValue) \
|
||||||
|
@ -1071,15 +1092,12 @@ nsHTML##_elementName##Element::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Get##_method(nsAString& aValue) \
|
_class::Get##_method(nsAString& aValue) \
|
||||||
{ \
|
{ \
|
||||||
GetURIAttr(nsHTMLAtoms::_atom, aValue); \
|
return GetURIAttr(nsHTMLAtoms::_atom, aValue); \
|
||||||
\
|
|
||||||
return NS_OK; \
|
|
||||||
} \
|
} \
|
||||||
NS_IMETHODIMP \
|
NS_IMETHODIMP \
|
||||||
_class::Set##_method(const nsAString& aValue) \
|
_class::Set##_method(const nsAString& aValue) \
|
||||||
{ \
|
{ \
|
||||||
return SetAttr(kNameSpaceID_None, nsHTMLAtoms::_atom, aValue, \
|
return SetAttrHelper(nsHTMLAtoms::_atom, aValue); \
|
||||||
PR_TRUE); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче