Bug 836050 part 3. Make Element::AttrValueIs non-virtual. r=smaug

This commit is contained in:
Boris Zbarsky 2013-01-30 22:26:46 -05:00
parent 6c77187ae8
commit e07baed27f
4 changed files with 65 additions and 51 deletions

View File

@ -121,8 +121,8 @@ class UndoManager;
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
{ 0xc6c049a1, 0x96e8, 0x4580, \
{ 0xa6, 0x93, 0xb9, 0x5f, 0x53, 0xbe, 0xe8, 0x1c } }
{ 0xcae9f7e7, 0x6163, 0x47b5, \
{ 0xa1, 0x63, 0x30, 0xc8, 0x1d, 0x2d, 0x79, 0x39 } }
class Element : public FragmentOrElement
{
@ -468,12 +468,12 @@ public:
nsAString& aResult) 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,
nsCaseTreatment aCaseSensitive) const;
virtual bool AttrValueIs(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const;
inline bool AttrValueIs(int32_t aNameSpaceID, nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const;
inline bool AttrValueIs(int32_t aNameSpaceID, nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const;
virtual int32_t FindAttrValueIn(int32_t aNameSpaceID,
nsIAtom* aName,
AttrValuesArray* aValues,
@ -1176,6 +1176,33 @@ Element::HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
return mAttrsAndChildren.IndexOfAttr(aName, aNameSpaceID) >= 0;
}
inline bool
Element::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const
{
NS_ASSERTION(aName, "Must have attr name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNameSpaceID);
return val && val->Equals(aValue, aCaseSensitive);
}
inline bool
Element::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const
{
NS_ASSERTION(aName, "Must have attr name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
NS_ASSERTION(aValue, "Null value atom");
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNameSpaceID);
return val && val->Equals(aValue, aCaseSensitive);
}
} // namespace dom
} // namespace mozilla

View File

@ -34,8 +34,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0xe2985850, 0x81ca, 0x4b5d, \
{ 0xb0, 0xf3, 0xe3, 0x95, 0xd5, 0x0d, 0x85, 0x64 } }
{ 0x8a8b4b1d, 0x72d8, 0x428e, \
{ 0x95, 0x75, 0xf9, 0x18, 0xba, 0xf6, 0x9e, 0xa1 } }
/**
* A node of content in a document's content model. This interface
@ -394,13 +394,10 @@ public:
* @param aValue The value to compare to.
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
*/
virtual bool AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const
{
return false;
}
bool AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const;
/**
* Test whether this content node's given attribute has the given value. If
@ -412,13 +409,10 @@ public:
* @param aValue The value to compare to. Must not be null.
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
*/
virtual bool AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const
{
return false;
}
bool AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const;
enum {
ATTR_MISSING = -1,

View File

@ -1967,33 +1967,6 @@ Element::GetAttr(int32_t aNameSpaceID, nsIAtom* aName,
return haveAttr;
}
bool
Element::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const
{
NS_ASSERTION(aName, "Must have attr name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNameSpaceID);
return val && val->Equals(aValue, aCaseSensitive);
}
bool
Element::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const
{
NS_ASSERTION(aName, "Must have attr name");
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
NS_ASSERTION(aValue, "Null value atom");
const nsAttrValue* val = mAttrsAndChildren.GetAttr(aName, aNameSpaceID);
return val && val->Equals(aValue, aCaseSensitive);
}
int32_t
Element::FindAttrValueIn(int32_t aNameSpaceID,
nsIAtom* aName,

View File

@ -860,6 +860,26 @@ nsIContent::HasAttr(int32_t aNameSpaceID, nsIAtom* aName) const
return IsElement() && AsElement()->HasAttr(aNameSpaceID, aName);
}
bool
nsIContent::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const
{
return IsElement() &&
AsElement()->AttrValueIs(aNameSpaceID, aName, aValue, aCaseSensitive);
}
bool
nsIContent::AttrValueIs(int32_t aNameSpaceID,
nsIAtom* aName,
nsIAtom* aValue,
nsCaseTreatment aCaseSensitive) const
{
return IsElement() &&
AsElement()->AttrValueIs(aNameSpaceID, aName, aValue, aCaseSensitive);
}
const nsAttrValue*
FragmentOrElement::DoGetClasses() const
{