From 8ff3a955d1501fadf2928e82885f574d4b919278 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Tue, 2 Oct 2012 10:24:12 +0200 Subject: [PATCH] Bug 795610 - Part a: Outparamdel GetBoolAttr/GetIntAttr; r=mounir --- .../html/content/src/nsGenericHTMLElement.cpp | 21 +++++-------------- .../html/content/src/nsGenericHTMLElement.h | 19 ++++++++++------- .../html/content/src/nsHTMLScriptElement.cpp | 7 ++----- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 3be2dcffa89..dab0a3a1837 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -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; diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index e1bdcc02bdd..b7b5d42e84b 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -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) \ diff --git a/content/html/content/src/nsHTMLScriptElement.cpp b/content/html/content/src/nsHTMLScriptElement.cpp index 75fef0e9eff..80857093d0a 100644 --- a/content/html/content/src/nsHTMLScriptElement.cpp +++ b/content/html/content/src/nsHTMLScriptElement.cpp @@ -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