From 9d0763eb6e5a5cdfd48fbc4114edc3833d5eeb70 Mon Sep 17 00:00:00 2001 From: "cvshook%sicking.cc" Date: Tue, 8 Feb 2005 23:49:11 +0000 Subject: [PATCH] Bug 281575: Don't bother supporting attributes not implementing nsIAttribute since there are no longer any such nodes. r/sr=peterv --- .../source/xpath/txMozillaXPathTreeWalker.cpp | 68 +++++-------------- 1 file changed, 16 insertions(+), 52 deletions(-) diff --git a/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp b/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp index 43d2647a1c81..a6908434d013 100644 --- a/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp +++ b/extensions/transformiix/source/xpath/txMozillaXPathTreeWalker.cpp @@ -886,61 +886,25 @@ txXPathNativeNode::createXPathNode(nsIDOMNode* aNode) if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) { nsCOMPtr attr = do_QueryInterface(aNode); - if (attr) { - nsIContent *parent = attr->GetContent(); - nsINodeInfo *nodeInfo = attr->NodeInfo(); + NS_ASSERTION(attr, "doesn't implement nsIAttribute"); - nsCOMPtr 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 (nodeInfo->Equals(attName, attNS)) { - return new txXPathNode(parent, i); - } - } - } - else { - // XUL attributes don't implement nsIAttribute, so this sucks. - nsCOMPtr attrNode = do_QueryInterface(aNode); - NS_ENSURE_TRUE(attrNode, nsnull); - - nsCOMPtr element; - attrNode->GetOwnerElement(getter_AddRefs(element)); - nsCOMPtr parent = do_QueryInterface(element); - NS_ENSURE_TRUE(parent, nsnull); - - nsAutoString name, namespaceURI; - - nsresult rv = aNode->GetLocalName(name); - NS_ENSURE_SUCCESS(rv, nsnull); - - nsCOMPtr 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 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); - } - } + nsINodeInfo *nodeInfo = attr->NodeInfo(); + nsIContent *parent = attr->GetContent(); + if (!parent) { + return nsnull; } + nsCOMPtr 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 (nodeInfo->Equals(attName, attNS)) { + return new txXPathNode(parent, i); + } + } NS_ERROR("Couldn't find the attribute in its parent!");