зеркало из https://github.com/mozilla/gecko-dev.git
Bug 659610 - Remove nsGenericHTMLElement::SetAttrHelper and related helper macros. r=qdot
The only remaining instance of NS_IMPL_BOOL_ATTR macro was expanded by hand. MozReview-Commit-ID: DQ8fGGNTl3y --HG-- extra : rebase_source : 9ab13bd3e0702b518f8ec8418f2a7a9861ad5062
This commit is contained in:
Родитель
ef7e020a97
Коммит
9dae626b64
|
@ -1577,7 +1577,6 @@ public:
|
|||
mozilla::TextEditor* GetTextEditorInternal();
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_BOOL_ATTR macro.
|
||||
* Gets value of boolean attribute. Only works for attributes in null
|
||||
* namespace.
|
||||
*
|
||||
|
@ -1590,7 +1589,6 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_BOOL_ATTR macro.
|
||||
* Sets value of boolean attribute by removing attribute or setting it to
|
||||
* the empty string. Only works for attributes in null namespace.
|
||||
*
|
||||
|
@ -1600,7 +1598,6 @@ public:
|
|||
nsresult SetBoolAttr(nsAtom* aAttr, bool aValue);
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_VALUE.
|
||||
* Gets the enum value string of an attribute and using a default value if
|
||||
* the attribute is missing or the string is an invalid enum value.
|
||||
*
|
||||
|
@ -1613,7 +1610,6 @@ public:
|
|||
nsAString& aResult) const;
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_MISSING_INVALID_VALUES.
|
||||
* Gets the enum value string of an attribute and using the default missing
|
||||
* value if the attribute is missing or the default invalid value if the
|
||||
* string is an invalid enum value.
|
||||
|
@ -2158,42 +2154,4 @@ _elementName::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, \
|
|||
#define NS_IMPL_ELEMENT_CLONE_WITH_INIT_AND_PARSER(_elementName) \
|
||||
NS_IMPL_ELEMENT_CLONE_WITH_INIT_HELPER(_elementName, (, NOT_FROM_PARSER))
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given string
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods. We use the 5-argument form of SetAttr, because
|
||||
* some consumers only implement that one, hiding superclass
|
||||
* 4-argument forms.
|
||||
*/
|
||||
#define NS_IMPL_STRING_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttr(kNameSpaceID_None, nsGkAtoms::_atom, nullptr, aValue, true); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given boolean
|
||||
* valued content property. The method uses the GetBoolAttr and
|
||||
* SetBoolAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_BOOL_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(bool* aValue) \
|
||||
{ \
|
||||
*aValue = GetBoolAttr(nsGkAtoms::_atom); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(bool aValue) \
|
||||
{ \
|
||||
return SetBoolAttr(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
#endif // mozilla_dom_Element_h__
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
}
|
||||
void SetLongDesc(const nsAString& aLongDesc, ErrorResult& aError)
|
||||
{
|
||||
SetAttrHelper(nsGkAtoms::longdesc, aLongDesc);
|
||||
SetHTMLAttr(nsGkAtoms::longdesc, aLongDesc);
|
||||
}
|
||||
|
||||
void GetMarginHeight(DOMString& aMarginHeight) const
|
||||
|
|
|
@ -1515,12 +1515,6 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(const nsMappedAttributes* aAtt
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::SetAttrHelper(nsAtom* aAttr, const nsAString& aValue)
|
||||
{
|
||||
return SetAttr(kNameSpaceID_None, aAttr, aValue, true);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsGenericHTMLElement::GetIntAttr(nsAtom* aAttr, int32_t aDefault) const
|
||||
{
|
||||
|
|
|
@ -624,7 +624,6 @@ public:
|
|||
static bool InNavQuirksMode(nsIDocument* aDoc);
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_URI_ATTR macro.
|
||||
* Gets the absolute URI value of an attribute, by resolving any relative
|
||||
* URIs in the attribute against the baseuri of the element. If the attribute
|
||||
* isn't a relative URI the value of the attribute is returned as is. Only
|
||||
|
@ -817,18 +816,6 @@ protected:
|
|||
}
|
||||
|
||||
/**
|
||||
* Helper method 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]
|
||||
*/
|
||||
nsresult SetAttrHelper(nsAtom* aAttr, const nsAString& aValue);
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_INT_ATTR macro.
|
||||
* Gets the integer-value of an attribute, returns specified default value
|
||||
* if the attribute isn't set or isn't set to an integer. Only works for
|
||||
* attributes in null namespace.
|
||||
|
@ -839,7 +826,6 @@ protected:
|
|||
int32_t GetIntAttr(nsAtom* aAttr, int32_t aDefault) const;
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_INT_ATTR macro.
|
||||
* Sets value of attribute to specified integer. Only works for attributes
|
||||
* in null namespace.
|
||||
*
|
||||
|
@ -849,7 +835,6 @@ protected:
|
|||
nsresult SetIntAttr(nsAtom* aAttr, int32_t aValue);
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_UINT_ATTR macro.
|
||||
* Gets the unsigned integer-value of an attribute, returns specified default
|
||||
* value if the attribute isn't set or isn't set to an integer. Only works for
|
||||
* attributes in null namespace.
|
||||
|
@ -860,7 +845,6 @@ protected:
|
|||
uint32_t GetUnsignedIntAttr(nsAtom* aAttr, uint32_t aDefault) const;
|
||||
|
||||
/**
|
||||
* Helper method for NS_IMPL_UINT_ATTR macro.
|
||||
* Sets value of attribute to specified unsigned integer. Only works for
|
||||
* attributes in null namespace.
|
||||
*
|
||||
|
@ -1241,215 +1225,6 @@ protected:
|
|||
nsCString mStateKey;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* This macro is similar to NS_IMPL_STRING_ATTR except that the getter method
|
||||
* falls back to an alternative method if the content attribute isn't set.
|
||||
*/
|
||||
#define NS_IMPL_STRING_ATTR_WITH_FALLBACK(_class, _method, _atom, _fallback) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue)) { \
|
||||
_fallback(aValue); \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given integer
|
||||
* valued content property. The method uses the generic GetAttr and
|
||||
* SetAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_INT_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0)
|
||||
|
||||
#define NS_IMPL_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(int32_t* aValue) \
|
||||
{ \
|
||||
*aValue = GetIntAttr(nsGkAtoms::_atom, _default); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(int32_t aValue) \
|
||||
{ \
|
||||
return SetIntAttr(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given unsigned integer
|
||||
* valued content property. The method uses GetUnsignedIntAttr and
|
||||
* SetUnsignedIntAttr methods.
|
||||
*/
|
||||
#define NS_IMPL_UINT_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_UINT_ATTR_DEFAULT_VALUE(_class, _method, _atom, 0)
|
||||
|
||||
#define NS_IMPL_UINT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(uint32_t* aValue) \
|
||||
{ \
|
||||
*aValue = GetUnsignedIntAttr(nsGkAtoms::_atom, _default); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(uint32_t aValue) \
|
||||
{ \
|
||||
mozilla::ErrorResult rv; \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, _default, rv); \
|
||||
return rv.StealNSResult(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given unsigned integer
|
||||
* valued content property. The method uses GetUnsignedIntAttr and
|
||||
* SetUnsignedIntAttr methods. This macro is similar to NS_IMPL_UINT_ATTR except
|
||||
* that it throws an exception if the set value is null.
|
||||
*/
|
||||
#define NS_IMPL_UINT_ATTR_NON_ZERO(_class, _method, _atom) \
|
||||
NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(_class, _method, _atom, 1)
|
||||
|
||||
#define NS_IMPL_UINT_ATTR_NON_ZERO_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(uint32_t* aValue) \
|
||||
{ \
|
||||
*aValue = GetUnsignedIntAttr(nsGkAtoms::_atom, _default); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(uint32_t aValue) \
|
||||
{ \
|
||||
if (aValue == 0) { \
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR; \
|
||||
} \
|
||||
mozilla::ErrorResult rv; \
|
||||
SetUnsignedIntAttr(nsGkAtoms::_atom, aValue, _default, rv); \
|
||||
return rv.StealNSResult(); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given content
|
||||
* property that needs to return a URI in string form. The method
|
||||
* uses the generic GetAttr and SetAttr methods. This macro is much
|
||||
* like the NS_IMPL_STRING_ATTR macro, except we make sure the URI is
|
||||
* absolute.
|
||||
*/
|
||||
#define NS_IMPL_URI_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetURIAttr(nsGkAtoms::_atom, nullptr, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_URI_ATTR_WITH_BASE(_class, _method, _atom, _base_atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetURIAttr(nsGkAtoms::_atom, nsGkAtoms::_base_atom, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement getter and setter for action and form action content
|
||||
* attributes. It's very similar to NS_IMPL_URI_ATTR excepted that if the
|
||||
* content attribute is the empty string, the empty string is returned.
|
||||
*/
|
||||
#define NS_IMPL_ACTION_ATTR(_class, _method, _atom) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue); \
|
||||
if (!aValue.IsEmpty()) { \
|
||||
GetURIAttr(nsGkAtoms::_atom, nullptr, aValue); \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given content
|
||||
* property that needs to set a non-negative integer. The method
|
||||
* uses the generic GetAttr and SetAttr methods. This macro is much
|
||||
* like the NS_IMPL_INT_ATTR macro except we throw an exception if
|
||||
* the set value is negative.
|
||||
*/
|
||||
#define NS_IMPL_NON_NEGATIVE_INT_ATTR(_class, _method, _atom) \
|
||||
NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, -1)
|
||||
|
||||
#define NS_IMPL_NON_NEGATIVE_INT_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(int32_t* aValue) \
|
||||
{ \
|
||||
*aValue = GetIntAttr(nsGkAtoms::_atom, _default); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(int32_t aValue) \
|
||||
{ \
|
||||
if (aValue < 0) { \
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR; \
|
||||
} \
|
||||
return SetIntAttr(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given content
|
||||
* property that needs to set an enumerated string. The method
|
||||
* uses a specific GetEnumAttr and the generic SetAttrHelper methods.
|
||||
*/
|
||||
#define NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetEnumAttr(nsGkAtoms::_atom, _default, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
/**
|
||||
* A macro to implement the getter and setter for a given content
|
||||
* property that needs to set an enumerated string that has different
|
||||
* default values for missing and invalid values. The method uses a
|
||||
* specific GetEnumAttr and the generic SetAttrHelper methods.
|
||||
*/
|
||||
#define NS_IMPL_ENUM_ATTR_DEFAULT_MISSING_INVALID_VALUES(_class, _method, _atom, _defaultMissing, _defaultInvalid) \
|
||||
NS_IMETHODIMP \
|
||||
_class::Get##_method(nsAString& aValue) \
|
||||
{ \
|
||||
GetEnumAttr(nsGkAtoms::_atom, _defaultMissing, _defaultInvalid, aValue); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::Set##_method(const nsAString& aValue) \
|
||||
{ \
|
||||
return SetAttrHelper(nsGkAtoms::_atom, aValue); \
|
||||
}
|
||||
|
||||
#define NS_INTERFACE_MAP_ENTRY_IF_TAG(_interface, _tag) \
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface, \
|
||||
mNodeInfo->Equals(nsGkAtoms::_tag))
|
||||
|
|
|
@ -56,7 +56,17 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(nsGenericHTMLFrameElement,
|
|||
nsIMozBrowserFrame,
|
||||
nsGenericHTMLFrameElement)
|
||||
|
||||
NS_IMPL_BOOL_ATTR(nsGenericHTMLFrameElement, Mozbrowser, mozbrowser)
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::GetMozbrowser(bool* aValue)
|
||||
{
|
||||
*aValue = GetBoolAttr(nsGkAtoms::mozbrowser);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsGenericHTMLFrameElement::SetMozbrowser(bool aValue)
|
||||
{
|
||||
return SetBoolAttr(nsGkAtoms::mozbrowser, aValue);
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsGenericHTMLFrameElement::TabIndexDefault()
|
||||
|
|
Загрузка…
Ссылка в новой задаче