Bug 836050 part 2. Make Element::HasAttr non-virtual. r=smaug

This commit is contained in:
Boris Zbarsky 2013-01-30 22:26:46 -05:00
parent b9e7c78fb6
commit b5b7008fa1
6 changed files with 20 additions and 23 deletions

View File

@ -466,7 +466,7 @@ public:
// the inlined nsAttrValue bits for C++ callers.
bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const;
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const;
inline bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const;
// aCaseSensitive == eIgnoreCaase means ASCII case-insensitive matching.
virtual bool AttrValueIs(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
@ -1166,6 +1166,16 @@ private:
NS_DEFINE_STATIC_IID_ACCESSOR(Element, NS_ELEMENT_IID)
inline bool
Element::HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
{
NS_ASSERTION(nullptr != aName, "must have attribute name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
"must have a real namespace ID!");
return mAttrsAndChildren.IndexOfAttr(aName, aNameSpaceID) >= 0;
}
} // namespace dom
} // namespace mozilla
@ -1196,6 +1206,12 @@ inline bool nsIContent::GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
return false;
}
inline bool nsIContent::HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
{
return IsElement() && AsElement()->HasAttr(aNameSpaceID, aName);
}
/**
* Macros to implement Clone(). _elementName is the class for which to implement
* Clone.

View File

@ -383,8 +383,10 @@ public:
* @param aNameSpaceId the namespace id of the attribute
* @param aAttr the attribute name
* @return whether an attribute exists
*
* Implemented inline in Element.h
*/
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const = 0;
bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const;
/**
* Test whether this content node's given attribute has the given value. If

View File

@ -62,10 +62,6 @@ public:
{
return NS_OK;
}
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
{
return false;
}
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify)
{

View File

@ -1967,16 +1967,6 @@ Element::GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
return haveAttr;
}
bool
Element::HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
{
NS_ASSERTION(nullptr != aName, "must have attribute name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown,
"must have a real namespace ID!");
return mAttrsAndChildren.IndexOfAttr(aName, aNameSpaceID) >= 0;
}
bool
Element::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,

View File

@ -577,12 +577,6 @@ nsGenericDOMDataNode::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
return NS_OK;
}
bool
nsGenericDOMDataNode::HasAttr(int32_t aNameSpaceID, nsIAtom *aAttribute) const
{
return false;
}
const nsAttrName*
nsGenericDOMDataNode::GetAttrNameAt(uint32_t aIndex) const
{

View File

@ -115,7 +115,6 @@ public:
bool aNotify);
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom *aAttribute) const;
virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const;
virtual uint32_t GetAttrCount() const;
virtual const nsTextFragment *GetText();