Bug 836050 part 1. Make Element::GetAttr non-virtual. r=smaug

This commit is contained in:
Boris Zbarsky 2013-01-30 22:26:46 -05:00
parent 1786b88346
commit cfe74f2ae2
5 changed files with 18 additions and 20 deletions

View File

@ -462,8 +462,10 @@ public:
const nsAString& aValue, bool aNotify);
nsresult SetParsedAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix,
nsAttrValue& aParsedValue, bool aNotify);
virtual bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const;
// GetAttr is not inlined on purpose, to keep down codesize from all
// 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;
// aCaseSensitive == eIgnoreCaase means ASCII case-insensitive matching.
virtual bool AttrValueIs(int32_t aNameSpaceID, nsIAtom* aName,
@ -1184,6 +1186,16 @@ inline bool nsINode::HasAttributes() const
return IsElement() && AsElement()->GetAttrCount() > 0;
}
inline bool nsIContent::GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const
{
if (IsElement()) {
return AsElement()->GetAttr(aNameSpaceID, aName, aResult);
}
aResult.Truncate();
return false;
}
/**
* Macros to implement Clone(). _elementName is the class for which to implement
* Clone.

View File

@ -371,9 +371,11 @@ public:
* @param aResult the value (may legitimately be the empty string) [OUT]
* @returns true if the attribute was set (even when set to empty string)
* false when not set.
*
* Implemented inline in Element.h
*/
virtual bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const = 0;
bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const;
/**
* Determine if an attribute has been set (empty string or otherwise).

View File

@ -62,11 +62,6 @@ public:
{
return NS_OK;
}
virtual bool GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsAString& aResult) const
{
return false;
}
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
{
return false;

View File

@ -577,15 +577,6 @@ nsGenericDOMDataNode::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttr,
return NS_OK;
}
bool
nsGenericDOMDataNode::GetAttr(int32_t aNameSpaceID, nsIAtom *aAttr,
nsAString& aResult) const
{
aResult.Truncate();
return false;
}
bool
nsGenericDOMDataNode::HasAttr(int32_t aNameSpaceID, nsIAtom *aAttribute) const
{

View File

@ -115,8 +115,6 @@ public:
bool aNotify);
virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
bool aNotify);
virtual bool GetAttr(int32_t aNameSpaceID, nsIAtom *aAttribute,
nsAString& aResult) const;
virtual bool HasAttr(int32_t aNameSpaceID, nsIAtom *aAttribute) const;
virtual const nsAttrName* GetAttrNameAt(uint32_t aIndex) const;
virtual uint32_t GetAttrCount() const;