зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1580491 - Introduce Element::HasNonEmptyAttr; r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D51213 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ce7c2ef520
Коммит
5301c9ad90
|
@ -764,6 +764,20 @@ class Element : public FragmentOrElement {
|
|||
return HasAttr(kNameSpaceID_None, aAttr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an attribute has been set to a non-empty string value. If the
|
||||
* attribute is not set at all, this will return false.
|
||||
*
|
||||
* @param aNameSpaceId the namespace id of the attribute (defaults to
|
||||
* kNameSpaceID_None in the overload that omits this arg)
|
||||
* @param aAttr the attribute name
|
||||
*/
|
||||
inline bool HasNonEmptyAttr(int32_t aNameSpaceID, const nsAtom* aName) const;
|
||||
|
||||
bool HasNonEmptyAttr(const nsAtom* aAttr) const {
|
||||
return HasNonEmptyAttr(kNameSpaceID_None, aAttr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether this Element's given attribute has the given value. If the
|
||||
* attribute is not set at all, this will return false.
|
||||
|
@ -1988,6 +2002,15 @@ inline bool Element::HasAttr(int32_t aNameSpaceID, const nsAtom* aName) const {
|
|||
return mAttrs.IndexOfAttr(aName, aNameSpaceID) >= 0;
|
||||
}
|
||||
|
||||
inline bool Element::HasNonEmptyAttr(int32_t aNameSpaceID,
|
||||
const nsAtom* aName) const {
|
||||
MOZ_ASSERT(aNameSpaceID > kNameSpaceID_Unknown, "Must have namespace");
|
||||
MOZ_ASSERT(aName, "Must have attribute name");
|
||||
|
||||
const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
|
||||
return val && !val->IsEmptyString();
|
||||
}
|
||||
|
||||
inline bool Element::AttrValueIs(int32_t aNameSpaceID, const nsAtom* aName,
|
||||
const nsAString& aValue,
|
||||
nsCaseTreatment aCaseSensitive) const {
|
||||
|
|
Загрузка…
Ссылка в новой задаче