mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 281575: Don't bother supporting attributes not implementing nsIAttribute since there are no longer any such nodes.
r/sr=peterv
This commit is contained in:
parent
0925c4ec99
commit
9d0763eb6e
@ -886,9 +886,13 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode)
|
||||
|
||||
if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) {
|
||||
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(aNode);
|
||||
if (attr) {
|
||||
nsIContent *parent = attr->GetContent();
|
||||
NS_ASSERTION(attr, "doesn't implement nsIAttribute");
|
||||
|
||||
nsINodeInfo *nodeInfo = attr->NodeInfo();
|
||||
nsIContent *parent = attr->GetContent();
|
||||
if (!parent) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> attName, attPrefix;
|
||||
PRInt32 attNS;
|
||||
@ -901,46 +905,6 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode)
|
||||
return new txXPathNode(parent, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// XUL attributes don't implement nsIAttribute, so this sucks.
|
||||
nsCOMPtr<nsIDOMAttr> attrNode = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(attrNode, nsnull);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
attrNode->GetOwnerElement(getter_AddRefs(element));
|
||||
nsCOMPtr<nsIContent> parent = do_QueryInterface(element);
|
||||
NS_ENSURE_TRUE(parent, nsnull);
|
||||
|
||||
nsAutoString name, namespaceURI;
|
||||
|
||||
nsresult rv = aNode->GetLocalName(name);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(name);
|
||||
NS_ENSURE_TRUE(nameAtom, nsnull);
|
||||
|
||||
rv = aNode->GetNamespaceURI(namespaceURI);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
PRInt32 namespaceID;
|
||||
rv = gTxNameSpaceManager->GetNameSpaceID(namespaceURI,
|
||||
&namespaceID);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsCOMPtr<nsIAtom> attName, attPrefix;
|
||||
PRInt32 attNS;
|
||||
|
||||
PRUint32 i, total = parent->GetAttrCount();
|
||||
for (i = 0; i < total; ++i) {
|
||||
parent->GetAttrNameAt(i, &attNS, getter_AddRefs(attName),
|
||||
getter_AddRefs(attPrefix));
|
||||
if (attName == nameAtom && attNS == namespaceID) {
|
||||
return new txXPathNode(parent, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_ERROR("Couldn't find the attribute in its parent!");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user