Fix bug 307600 for XTF and XUL too. r+sr=peterv
git-svn-id: svn://10.0.0.236/trunk@180027 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
33ce4ab8e2
commit
15785a7269
@ -57,6 +57,7 @@ REQUIRES = xpcom \
|
||||
necko \
|
||||
xpconnect \
|
||||
webshell \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXTFService.h"
|
||||
#include "nsDOMAttributeMap.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
nsXTFElementWrapper::nsXTFElementWrapper(nsINodeInfo* aNodeInfo)
|
||||
: nsXTFElementWrapperBase(aNodeInfo),
|
||||
@ -317,6 +318,57 @@ nsXTFElementWrapper::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXTFElementWrapper::AttrValueIs(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
nsCaseTreatment aCaseSensitive) const
|
||||
{
|
||||
NS_ASSERTION(aName, "Must have attr name");
|
||||
NS_ASSERTION(aNameSpaceID != kNameSpaceID_Unknown, "Must have namespace");
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && HandledByInner(aName)) {
|
||||
nsAutoString ourVal;
|
||||
nsresult rv = GetAttr(aNameSpaceID, aName, ourVal);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
return aCaseSensitive == eCaseMatters ?
|
||||
aValue.Equals(ourVal) :
|
||||
aValue.Equals(ourVal, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
return nsXTFElementWrapperBase::AttrValueIs(aNameSpaceID, aName, aValue,
|
||||
aCaseSensitive);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXTFElementWrapper::AttrValueIs(PRInt32 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");
|
||||
|
||||
if (aNameSpaceID == kNameSpaceID_None && HandledByInner(aName)) {
|
||||
nsAutoString ourVal;
|
||||
nsresult rv = GetAttr(aNameSpaceID, aName, ourVal);
|
||||
if (rv == NS_CONTENT_ATTR_NOT_THERE) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
if (aCaseSensitive == eCaseMatters) {
|
||||
return aValue->Equals(ourVal);
|
||||
}
|
||||
nsAutoString val;
|
||||
aValue->ToString(val);
|
||||
return val.Equals(ourVal, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
return nsXTFElementWrapperBase::AttrValueIs(aNameSpaceID, aName, aValue,
|
||||
aCaseSensitive);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXTFElementWrapper::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
|
||||
|
||||
@ -93,6 +93,12 @@ public:
|
||||
nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const;
|
||||
PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
nsCaseTreatment aCaseSensitive) const;
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aValue,
|
||||
nsCaseTreatment aCaseSensitive) const;
|
||||
nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttr,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
|
||||
|
||||
@ -1602,6 +1602,34 @@ nsXULElement::HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const
|
||||
FindPrototypeAttribute(aNameSpaceID, aName);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXULElement::AttrValueIs(PRInt32 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 = FindLocalOrProtoAttr(aNameSpaceID, aName);
|
||||
return val && val->Equals(aValue, aCaseSensitive);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXULElement::AttrValueIs(PRInt32 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 = FindLocalOrProtoAttr(aNameSpaceID, aName);
|
||||
return val && val->Equals(aValue, aCaseSensitive);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
|
||||
{
|
||||
|
||||
@ -488,6 +488,12 @@ public:
|
||||
virtual nsresult GetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsAString& aResult) const;
|
||||
virtual PRBool HasAttr(PRInt32 aNameSpaceID, nsIAtom* aName) const;
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsAString& aValue,
|
||||
nsCaseTreatment aCaseSensitive) const;
|
||||
virtual PRBool AttrValueIs(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
nsIAtom* aValue,
|
||||
nsCaseTreatment aCaseSensitive) const;
|
||||
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
PRBool aNotify);
|
||||
virtual nsresult GetAttrNameAt(PRUint32 aIndex, PRInt32* aNameSpaceID,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user