Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions
txXPathNativeNode Class Reference

#include <txXPathTreeWalker.h>

List of all members.

Static Public Member Functions

static txXPathNodecreateXPathNode (nsIDOMNode *aNode)
static txXPathNodecreateXPathNode (nsIDOMDocument *aDocument)
static nsresult getNode (const txXPathNode &aNode, nsIDOMNode **aResult)
static nsIContentgetContent (const txXPathNode &aNode)
static nsIDocumentgetDocument (const txXPathNode &aNode)
static void addRef (const txXPathNode &aNode)
static void release (const txXPathNode &aNode)

Detailed Description

Definition at line 157 of file txXPathTreeWalker.h.


Member Function Documentation

static void txXPathNativeNode::addRef ( const txXPathNode aNode) [inline, static]

Definition at line 165 of file txXPathTreeWalker.h.

    {
        // Hopefully it's ok to access mContent through mDocument.
        NS_ADDREF(aNode.mDocument);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 882 of file txMozillaXPathTreeWalker.cpp.

{
    PRUint16 nodeType;
    aNode->GetNodeType(&nodeType);

    if (nodeType == nsIDOMNode::ATTRIBUTE_NODE) {
        nsCOMPtr<nsIAttribute> attr = do_QueryInterface(aNode);
        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;

        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!");

        return nsnull;
    }

    if (nodeType == nsIDOMNode::DOCUMENT_NODE) {
        nsCOMPtr<nsIDocument> document = do_QueryInterface(aNode);
        return new txXPathNode(document);
    }

    nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
    return new txXPathNode(content);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 925 of file txMozillaXPathTreeWalker.cpp.

{
    nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
    return new txXPathNode(document);
}

Here is the call graph for this function:

Definition at line 963 of file txMozillaXPathTreeWalker.cpp.

{
    NS_ASSERTION(aNode.isContent(),
                 "Only call getContent on nsIContent wrappers!");
    return aNode.mContent;
}

Here is the call graph for this function:

Definition at line 972 of file txMozillaXPathTreeWalker.cpp.

{
    NS_ASSERTION(aNode.isDocument(),
                 "Only call getDocument on nsIDocument wrappers!");
    return aNode.mDocument;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txXPathNativeNode::getNode ( const txXPathNode aNode,
nsIDOMNode **  aResult 
) [static]

Definition at line 933 of file txMozillaXPathTreeWalker.cpp.

{
    if (aNode.isDocument()) {
        return CallQueryInterface(aNode.mDocument, aResult);
    }

    if (aNode.isContent()) {
        return CallQueryInterface(aNode.mContent, aResult);
    }

    PRInt32 namespaceID;
    nsCOMPtr<nsIAtom> name, prefix;
    aNode.mContent->GetAttrNameAt(aNode.mIndex, &namespaceID,
                                  getter_AddRefs(name),
                                  getter_AddRefs(prefix));

    nsAutoString namespaceURI, localname;
    gTxNameSpaceManager->GetNameSpaceURI(namespaceID, namespaceURI);
    name->ToString(localname);

    nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode.mContent);
    nsCOMPtr<nsIDOMAttr> attr;
    element->GetAttributeNodeNS(namespaceURI, localname,
                                getter_AddRefs(attr));

    return CallQueryInterface(attr, aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void txXPathNativeNode::release ( const txXPathNode aNode) [inline, static]

Definition at line 170 of file txXPathTreeWalker.h.

    {
        // Hopefully it's ok to access mContent through mDocument.
        nsISupports *node = aNode.mDocument;
        NS_RELEASE(node);
    }

The documentation for this class was generated from the following files: