Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Attributes
nsChildElementIterator Class Reference

#include <nsDOMUtils.h>

Collaboration diagram for nsChildElementIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsChildElementIterator (nsIDOMElement *aParent)
 nsChildElementIterator (nsIDOMElement *aParent, const nsAString &aNamespace)
 nsChildElementIterator (nsIDOMElement *aParent, const char **aNamespaceArray, PRUint32 aNumNamespaces)
 ~nsChildElementIterator ()
void SetElement (nsIDOMElement *aParent)
PRUint32 GetCurrentIndex ()
void Reset (PRUint32 aIndex=0)
PRBool HasChildNodes ()
nsresult GetNextChild (nsIDOMElement **aChildElement, nsIAtom **aElementName)

Private Attributes

nsCOMPtr< nsIDOMNodeListmNodeList
PRUint32 mIndex
PRUint32 mLength
nsString mNamespace
const char ** mNamespaceArray
PRUint32 mNumNamespaces

Detailed Description

Definition at line 62 of file nsDOMUtils.h.


Constructor & Destructor Documentation

Definition at line 72 of file nsDOMUtils.h.

                                                 :
    mIndex(0), mLength(0), mNumNamespaces(0)
  {
    SetElement(aParent);
  }    

Here is the call graph for this function:

nsChildElementIterator::nsChildElementIterator ( nsIDOMElement aParent,
const nsAString &  aNamespace 
) [inline]

Definition at line 78 of file nsDOMUtils.h.

                                                      :
    mIndex(0), mLength(0), mNamespace(aNamespace), mNumNamespaces(0)
  {
    SetElement(aParent);
  }

Here is the call graph for this function:

nsChildElementIterator::nsChildElementIterator ( nsIDOMElement aParent,
const char **  aNamespaceArray,
PRUint32  aNumNamespaces 
) [inline]

Definition at line 85 of file nsDOMUtils.h.

                                                  :
    mIndex(0), mLength(0), mNamespaceArray(aNamespaceArray), 
    mNumNamespaces(aNumNamespaces)
  {
    SetElement(aParent);    
  }

Here is the call graph for this function:

Definition at line 94 of file nsDOMUtils.h.

{}

Member Function Documentation

Definition at line 106 of file nsDOMUtils.h.

{ return mIndex; }

Here is the caller graph for this function:

nsresult nsChildElementIterator::GetNextChild ( nsIDOMElement **  aChildElement,
nsIAtom **  aElementName 
) [inline]

Definition at line 112 of file nsDOMUtils.h.

  {
    *aChildElement = nsnull;
    
    if (!mNodeList) {
      return NS_ERROR_FAILURE;
    }

    nsCOMPtr<nsIDOMNode> child; 
    while (mIndex < mLength) {
      mNodeList->Item(mIndex++, getter_AddRefs(child));
      nsCOMPtr<nsIDOMElement> childElement(do_QueryInterface(child));
      if (!childElement) {
        continue;
      }
      
      // Confirm that the element is an element of the specified namespace
      nsAutoString namespaceURI;           
      childElement->GetNamespaceURI(namespaceURI);  
      if (!mNamespace.IsEmpty()) {
        if (!namespaceURI.Equals(mNamespace)) {
          continue;
        }
      }
      else if (mNumNamespaces) {
        PRUint32 i;
        for (i = 0; i < mNumNamespaces; i++) {
          if (!namespaceURI.Equals(NS_ConvertASCIItoUCS2(mNamespaceArray[i]))) {
            continue;
          }
        }
      }
      
      nsCOMPtr<nsIContent> content(do_QueryInterface(childElement));
      NS_ASSERTION(content, "Element is not content");
      if (!content) {
        return NS_ERROR_FAILURE;
      }
      
      nsINodeInfo *nodeInfo = content->GetNodeInfo();
      if (!nodeInfo) {
        return NS_ERROR_FAILURE;
      }

      NS_ADDREF(*aElementName = nodeInfo->NameAtom());

      *aChildElement = childElement;
      NS_ADDREF(*aChildElement);
      break;
    }
    
    return NS_OK;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file nsDOMUtils.h.

{ return mLength; }

Here is the caller graph for this function:

void nsChildElementIterator::Reset ( PRUint32  aIndex = 0) [inline]

Definition at line 108 of file nsDOMUtils.h.

{ mIndex = aIndex; }

Here is the caller graph for this function:

Definition at line 96 of file nsDOMUtils.h.

  {
    aParent->GetChildNodes(getter_AddRefs(mNodeList));
    if (mNodeList) {
      mNodeList->GetLength(&mLength);
      // if we change the element, reset the index
      mIndex = 0;
    }    
  }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 65 of file nsDOMUtils.h.

Definition at line 66 of file nsDOMUtils.h.

Definition at line 67 of file nsDOMUtils.h.

Definition at line 68 of file nsDOMUtils.h.

Definition at line 64 of file nsDOMUtils.h.

Definition at line 69 of file nsDOMUtils.h.


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