Bug 795610 - Part a: Outparamdel GetBoolAttr/GetIntAttr; r=mounir

This commit is contained in:
Peter Van der Beken 2012-10-02 10:24:12 +02:00
parent 872ef56d79
commit 8ff3a955d1
3 changed files with 19 additions and 28 deletions

View File

@ -2874,24 +2874,14 @@ nsGenericHTMLElement::SetBoolAttr(nsIAtom* aAttr, bool aValue)
return UnsetAttr(kNameSpaceID_None, aAttr, true);
}
nsresult
nsGenericHTMLElement::GetBoolAttr(nsIAtom* aAttr, bool* aValue) const
{
*aValue = HasAttr(kNameSpaceID_None, aAttr);
return NS_OK;
}
nsresult
nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, int32_t aDefault, int32_t* aResult)
int32_t
nsGenericHTMLElement::GetIntAttr(nsIAtom* aAttr, int32_t aDefault) const
{
const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
if (attrVal && attrVal->Type() == nsAttrValue::eInteger) {
*aResult = attrVal->GetIntegerValue();
return attrVal->GetIntegerValue();
}
else {
*aResult = aDefault;
}
return NS_OK;
return aDefault;
}
nsresult
@ -3555,8 +3545,7 @@ nsGenericHTMLFormElement::IntrinsicState() const
// Make the text controls read-write
if (!state.HasState(NS_EVENT_STATE_MOZ_READWRITE) &&
IsTextControl(false)) {
bool roState;
GetBoolAttr(nsGkAtoms::readonly, &roState);
bool roState = GetBoolAttr(nsGkAtoms::readonly);
if (!roState) {
state |= NS_EVENT_STATE_MOZ_READWRITE;

View File

@ -645,7 +645,10 @@ protected:
* @param aAttr name of attribute.
* @param aValue Boolean value of attribute.
*/
NS_HIDDEN_(nsresult) GetBoolAttr(nsIAtom* aAttr, bool* aValue) const;
NS_HIDDEN_(bool) GetBoolAttr(nsIAtom* aAttr) const
{
return HasAttr(kNameSpaceID_None, aAttr);
}
/**
* Helper method for NS_IMPL_BOOL_ATTR macro.
@ -665,9 +668,8 @@ protected:
*
* @param aAttr name of attribute.
* @param aDefault default-value to return if attribute isn't set.
* @param aResult result value [out]
*/
NS_HIDDEN_(nsresult) GetIntAttr(nsIAtom* aAttr, int32_t aDefault, int32_t* aValue);
NS_HIDDEN_(int32_t) GetIntAttr(nsIAtom* aAttr, int32_t aDefault) const;
/**
* Helper method for NS_IMPL_INT_ATTR macro.
@ -1017,7 +1019,8 @@ PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 1 < 32);
NS_IMETHODIMP \
_class::Get##_method(bool* aValue) \
{ \
return GetBoolAttr(nsGkAtoms::_atom, aValue); \
*aValue = GetBoolAttr(nsGkAtoms::_atom); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(bool aValue) \
@ -1037,12 +1040,13 @@ PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 1 < 32);
NS_IMETHODIMP \
_class::Get##_method(int32_t* aValue) \
{ \
return GetIntAttr(nsGkAtoms::_atom, _default, aValue); \
*aValue = GetIntAttr(nsGkAtoms::_atom, _default); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(int32_t aValue) \
{ \
return SetIntAttr(nsGkAtoms::_atom, aValue); \
return SetIntAttr(nsGkAtoms::_atom, aValue); \
}
/**
@ -1155,7 +1159,8 @@ PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 1 < 32);
NS_IMETHODIMP \
_class::Get##_method(int32_t* aValue) \
{ \
return GetIntAttr(nsGkAtoms::_atom, _default, aValue); \
*aValue = GetIntAttr(nsGkAtoms::_atom, _default); \
return NS_OK; \
} \
NS_IMETHODIMP \
_class::Set##_method(int32_t aValue) \

View File

@ -217,11 +217,8 @@ NS_IMPL_STRING_ATTR(nsHTMLScriptElement, CrossOrigin, crossorigin)
nsresult
nsHTMLScriptElement::GetAsync(bool* aValue)
{
if (mForceAsync) {
*aValue = true;
return NS_OK;
}
return GetBoolAttr(nsGkAtoms::async, aValue);
*aValue = mForceAsync || GetBoolAttr(nsGkAtoms::async);
return NS_OK;
}
nsresult