Make GetElementsByAttribute compare to the qualified name, like it used to, not

just to the localName.  Bug 319421, r+sr=sicking
This commit is contained in:
bzbarsky%mit.edu 2006-06-22 02:37:06 +00:00
Родитель 282ad6509b
Коммит e6259982ea
2 изменённых файлов: 30 добавлений и 7 удалений

Просмотреть файл

@ -505,7 +505,7 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute,
this,
PR_TRUE,
attrAtom,
kNameSpaceID_None);
kNameSpaceID_Unknown);
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aReturn = list);

Просмотреть файл

@ -1153,7 +1153,7 @@ nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute,
nsnull,
PR_TRUE,
attrAtom,
kNameSpaceID_None);
kNameSpaceID_Unknown);
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aReturn = list);
@ -2015,10 +2015,33 @@ nsXULDocument::MatchAttribute(nsIContent* aContent,
{
NS_PRECONDITION(aContent, "Must have content node to work with!");
if (aNamespaceID != kNameSpaceID_Unknown) {
return aAttrValue.EqualsLiteral("*") ?
aContent->HasAttr(aNamespaceID, aAttrName) :
aContent->AttrValueIs(aNamespaceID, aAttrName, aAttrValue,
eCaseMatters);
}
// Qualified name match. This takes more work.
PRUint32 count = aContent->GetAttrCount();
for (PRUint32 i = 0; i < count; ++i) {
const nsAttrName* name = aContent->GetAttrNameAt(i);
PRBool nameMatch;
if (name->IsAtom()) {
nameMatch = name->Atom() == aAttrName;
} else {
nameMatch = name->NodeInfo()->QualifiedNameEquals(aAttrName);
}
if (nameMatch) {
return aAttrValue.EqualsLiteral("*") ||
aContent->AttrValueIs(name->NamespaceID(), name->LocalName(),
aAttrValue, eCaseMatters);
}
}
return PR_FALSE;
}
nsresult