Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
Attr Class Reference

#include <dom.h>

Inheritance diagram for Attr:
Inheritance graph
[legend]
Collaboration diagram for Attr:
Collaboration graph
[legend]

List of all members.

Public Types

enum  NodeType {
  ELEMENT_NODE = 1, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE,
  ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE,
  DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE
}

Public Member Functions

virtual ~Attr ()
void setNodeValue (const nsAString &aValue)
nsresult getNodeValue (nsAString &aValue)
NodeappendChild (Node *newChild)
MBool getLocalName (nsIAtom **aLocalName)
PRInt32 getNamespaceID ()
NodegetXPathParent ()
nsresult getNodeName (nsAString &aName) const
unsigned short getNodeType () const
NodegetParentNode () const
NodegetFirstChild () const
NodegetLastChild () const
NodegetPreviousSibling () const
NodegetNextSibling () const
virtual NamedNodeMapgetAttributes ()
DocumentgetOwnerDocument () const
MBool hasChildNodes () const
virtual nsresult getBaseURI (nsAString &aURI)
nsresult getNamespaceURI (nsAString &aNSURI)
virtual PRInt32 lookupNamespaceID (nsIAtom *)
virtual PRInt32 compareDocumentPosition (Node *aOther)
Nodeitem (PRUint32 index)
PRUint32 getLength ()
void appendData (const PRUnichar *aData, int aLength)

Public Attributes

char * function
unsigned count
unsigned hits
Nodenext

Protected Member Functions

NodeDefinitionimplAppendChild (NodeDefinition *newChild)
NodeDefinitionimplRemoveChild (NodeDefinition *oldChild)
void DeleteChildren ()

Protected Attributes

nsString nodeName
nsString nodeValue
PRUint32 length

Private Member Functions

 Attr (const nsAString &name, Document *owner)
 Attr (const nsAString &aNamespaceURI, const nsAString &aName, Document *aOwner)

Private Attributes

ElementownerElement
nsCOMPtr< nsIAtommLocalName
PRInt32 mNamespaceID

Friends

class Document
class AttrMap
class Element
class txXPathTreeWalker
class txXPathNodeUtils

Detailed Description

Definition at line 493 of file dom.h.


Member Enumeration Documentation

enum Node::NodeType [inherited]
Enumerator:
ELEMENT_NODE 
ATTRIBUTE_NODE 
TEXT_NODE 
CDATA_SECTION_NODE 
ENTITY_REFERENCE_NODE 
ENTITY_NODE 
PROCESSING_INSTRUCTION_NODE 
COMMENT_NODE 
DOCUMENT_NODE 
DOCUMENT_TYPE_NODE 
DOCUMENT_FRAGMENT_NODE 
NOTATION_NODE 

Definition at line 90 of file dom.h.


Constructor & Destructor Documentation

Attr::~Attr ( ) [virtual]

Definition at line 94 of file Attr.cpp.

{
}
Attr::Attr ( const nsAString &  name,
Document owner 
) [private]

Definition at line 51 of file Attr.cpp.

                                                :
      NodeDefinition(Node::ATTRIBUTE_NODE, name, EmptyString(), owner)
{
  int idx = nodeName.FindChar(':');
  if (idx == kNotFound) {
    mLocalName = do_GetAtom(nodeName);
    if (mLocalName == txXMLAtoms::xmlns)
      mNamespaceID = kNameSpaceID_XMLNS;
    else
      mNamespaceID = kNameSpaceID_None;
  }
  else {
    mLocalName = do_GetAtom(Substring(nodeName, idx + 1,
                                      nodeName.Length() - (idx + 1)));
    // namespace handling has to be handled late, the attribute must
    // be added to the tree to resolve the prefix, unless it's
    // xmlns or xml, try to do that here
    nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
    if (prefixAtom == txXMLAtoms::xmlns)
      mNamespaceID = kNameSpaceID_XMLNS;
    else if (prefixAtom == txXMLAtoms::xml)
      mNamespaceID = kNameSpaceID_XML;
    else
      mNamespaceID = kNameSpaceID_Unknown;
  }
}

Here is the call graph for this function:

Attr::Attr ( const nsAString &  aNamespaceURI,
const nsAString &  aName,
Document aOwner 
) [private]

Definition at line 78 of file Attr.cpp.

Here is the call graph for this function:


Member Function Documentation

Node * Attr::appendChild ( Node newChild) [virtual]

Reimplemented from NodeDefinition.

Definition at line 112 of file Attr.cpp.

{
  NS_ASSERTION(0, "not implemented");
  return nsnull;
}
void NodeDefinition::appendData ( const PRUnichar aData,
int  aLength 
) [inline, inherited]

Definition at line 282 of file dom.h.

    {
      nodeValue.Append(aData, aLength);
    };
PRInt32 NodeDefinition::compareDocumentPosition ( Node aOther) [virtual, inherited]

Implements Node.

Definition at line 409 of file NodeDefinition.cpp.

{
  OrderInfo* myOrder = getOrderInfo();
  OrderInfo* otherOrder = ((NodeDefinition*)aOther)->getOrderInfo();
  if (!myOrder || !otherOrder)
      return -1;

  if (myOrder->mRoot == otherOrder->mRoot) {
    int c = 0;
    while (c < myOrder->mSize && c < otherOrder->mSize) {
      if (myOrder->mOrder[c] < otherOrder->mOrder[c])
        return -1;
      if (myOrder->mOrder[c] > otherOrder->mOrder[c])
        return 1;
      ++c;
    }
    if (c < myOrder->mSize)
      return 1;
    if (c < otherOrder->mSize)
      return -1;
    return 0;
  }

  if (myOrder->mRoot < otherOrder->mRoot)
    return -1;

  return 1;
}

Here is the call graph for this function:

void NodeDefinition::DeleteChildren ( ) [protected, inherited]

Definition at line 130 of file NodeDefinition.cpp.

{
  NodeDefinition* pCurrent = firstChild;
  NodeDefinition* pDestroyer;

  while (pCurrent)
    {
      pDestroyer = pCurrent;
      pCurrent = pCurrent->nextSibling;
      delete pDestroyer;
    }

  length = 0;
  firstChild = nsnull;
  lastChild = nsnull;
}

Here is the caller graph for this function:

NamedNodeMap * NodeDefinition::getAttributes ( ) [virtual, inherited]

Implements Node.

Reimplemented in Element.

Definition at line 189 of file NodeDefinition.cpp.

{
  return 0;
}
nsresult NodeDefinition::getBaseURI ( nsAString &  aURI) [virtual, inherited]

Implements Node.

Reimplemented in Document.

Definition at line 367 of file NodeDefinition.cpp.

{
  Node* node = this;
  nsStringArray baseUrls;
  nsAutoString url;

  while (node) {
    switch (node->getNodeType()) {
      case Node::ELEMENT_NODE :
        if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
                                      url))
          baseUrls.AppendString(url);
        break;

      case Node::DOCUMENT_NODE :
        node->getBaseURI(url);
        baseUrls.AppendString(url);
        break;
    
      default:
        break;
    }
    node = node->getXPathParent();
  }

  PRInt32 count = baseUrls.Count();
  if (count) {
    baseUrls.StringAt(--count, aURI);

    while (count > 0) {
      nsAutoString dest;
      URIUtils::resolveHref(*baseUrls[--count], aURI, dest);
      aURI = dest;
    }
  }
  
  return NS_OK;
} // getBaseURI

Here is the call graph for this function:

Here is the caller graph for this function:

Node * NodeDefinition::getFirstChild ( ) const [virtual, inherited]

Implements Node.

Definition at line 169 of file NodeDefinition.cpp.

{
  return firstChild;
}

Here is the caller graph for this function:

Node * NodeDefinition::getLastChild ( ) const [virtual, inherited]

Implements Node.

Definition at line 174 of file NodeDefinition.cpp.

{
  return lastChild;
}
PRUint32 NodeDefinition::getLength ( ) [virtual, inherited]

Implements NodeList.

Definition at line 215 of file NodeDefinition.cpp.

{
  return length;
}
MBool Attr::getLocalName ( nsIAtom **  aLocalName) [virtual]

Reimplemented from NodeDefinition.

Definition at line 121 of file Attr.cpp.

{
  if (!aLocalName)
    return MB_FALSE;
  *aLocalName = mLocalName;
  NS_ADDREF(*aLocalName);
  return MB_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from NodeDefinition.

Definition at line 135 of file Attr.cpp.

{
  if (mNamespaceID >= 0)
    return mNamespaceID;

  mNamespaceID = kNameSpaceID_None;
  PRInt32 idx = nodeName.FindChar(':');
  if (idx != kNotFound) {
    nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
    mNamespaceID = lookupNamespaceID(prefixAtom);
  }
  return mNamespaceID;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NodeDefinition::getNamespaceURI ( nsAString &  aNSURI) [virtual, inherited]

Implements Node.

Definition at line 293 of file NodeDefinition.cpp.

Here is the call graph for this function:

Node * NodeDefinition::getNextSibling ( ) const [virtual, inherited]

Implements Node.

Definition at line 184 of file NodeDefinition.cpp.

{
  return nextSibling;
}
nsresult NodeDefinition::getNodeName ( nsAString &  aName) const [virtual, inherited]

Implements Node.

Definition at line 147 of file NodeDefinition.cpp.

{
  aName = nodeName;
  return NS_OK;
}
unsigned short NodeDefinition::getNodeType ( ) const [virtual, inherited]

Implements Node.

Definition at line 159 of file NodeDefinition.cpp.

{
  return nodeType;
}

Here is the caller graph for this function:

nsresult Attr::getNodeValue ( nsAString &  aValue) [virtual]

Reimplemented from NodeDefinition.

Definition at line 103 of file Attr.cpp.

{
  aValue = nodeValue;
  return NS_OK;
}

Here is the caller graph for this function:

Document * NodeDefinition::getOwnerDocument ( ) const [virtual, inherited]

Implements Node.

Definition at line 194 of file NodeDefinition.cpp.

{
  return ownerDocument;
}

Here is the caller graph for this function:

Node * NodeDefinition::getParentNode ( ) const [virtual, inherited]

Implements Node.

Definition at line 164 of file NodeDefinition.cpp.

{
  return parentNode;
}

Here is the caller graph for this function:

Node * NodeDefinition::getPreviousSibling ( ) const [virtual, inherited]

Implements Node.

Definition at line 179 of file NodeDefinition.cpp.

{
  return previousSibling;
}
Node * Attr::getXPathParent ( ) [virtual]

Reimplemented from NodeDefinition.

Definition at line 152 of file Attr.cpp.

{
  return ownerElement;
}
MBool NodeDefinition::hasChildNodes ( ) const [virtual, inherited]

Implements Node.

Definition at line 277 of file NodeDefinition.cpp.

{
  if (firstChild)
    return MB_TRUE;
  else
    return MB_FALSE;
}
NodeDefinition * NodeDefinition::implAppendChild ( NodeDefinition newChild) [protected, inherited]

Definition at line 230 of file NodeDefinition.cpp.

{
  // The new child should not be a child of any other node
  if (!newChild->previousSibling && !newChild->nextSibling &&
      !newChild->parentNode)
    {
      newChild->previousSibling = lastChild;

      if (lastChild)
        lastChild->nextSibling = newChild;

      lastChild = newChild;

      newChild->parentNode = this;

      if (!newChild->previousSibling)
        firstChild = newChild;

      ++length;

      return newChild;
    }

  return nsnull;
}

Here is the caller graph for this function:

NodeDefinition * NodeDefinition::implRemoveChild ( NodeDefinition oldChild) [protected, inherited]

Definition at line 256 of file NodeDefinition.cpp.

{
  if (oldChild != firstChild)
    oldChild->previousSibling->nextSibling = oldChild->nextSibling;
  else
    firstChild = oldChild->nextSibling;

  if (oldChild != lastChild)
    oldChild->nextSibling->previousSibling = oldChild->previousSibling;
  else
    lastChild = oldChild->previousSibling;

  oldChild->nextSibling = nsnull;
  oldChild->previousSibling = nsnull;
  oldChild->parentNode = nsnull;

  --length;

  return oldChild;
}

Here is the caller graph for this function:

Node * NodeDefinition::item ( PRUint32  index) [virtual, inherited]

Implements NodeList.

Definition at line 199 of file NodeDefinition.cpp.

{
  PRUint32 selectLoop;
  NodeDefinition* pSelectNode = firstChild;

  if (index < length)
    {
      for (selectLoop=0;selectLoop<index;selectLoop++)
        pSelectNode = pSelectNode->nextSibling;

      return pSelectNode;
    }

  return nsnull;
}

Here is the caller graph for this function:

PRInt32 NodeDefinition::lookupNamespaceID ( nsIAtom aPrefix) [virtual, inherited]

Implements Node.

Definition at line 310 of file NodeDefinition.cpp.

{
  // this is http://www.w3.org/2000/xmlns/,
  // ID = kNameSpaceID_XMLNS, see txStandaloneNamespaceManager::Init
  if (aPrefix == txXMLAtoms::xmlns)
    return kNameSpaceID_XMLNS; 
  // this is http://www.w3.org/XML/1998/namespace,
  // ID = kNameSpaceID_XML, see txStandaloneNamespaceManager::Init
  if (aPrefix == txXMLAtoms::xml)
    return kNameSpaceID_XML; 

  Node* node = this;
  if (node->getNodeType() != Node::ELEMENT_NODE)
    node = node->getXPathParent();

  nsAutoString name(NS_LITERAL_STRING("xmlns:"));
  if (aPrefix && (aPrefix != txXMLAtoms::_empty)) {
      //  We have a prefix, search for xmlns:prefix attributes.
      nsAutoString prefixString;
      aPrefix->ToString(prefixString);
      name.Append(prefixString);
  }
  else {
      // No prefix, look up the default namespace by searching for xmlns
      // attributes. Remove the trailing :, set length to 5 (xmlns).
      name.Truncate(5);
  }
  Attr* xmlns;
  while (node && node->getNodeType() == Node::ELEMENT_NODE) {
    if ((xmlns = ((Element*)node)->getAttributeNode(name))) {
      /*
       * xmlns:foo = "" makes "" a valid URI, so get that.
       * xmlns = "" resolves to 0 (null Namespace) (caught above)
       * in Element::getNamespaceID()
       */
      nsAutoString nsURI;
      xmlns->getNodeValue(nsURI);
      return txStandaloneNamespaceManager::getNamespaceID(nsURI);
    }
    node = node->getXPathParent();
  }
  if (!aPrefix || (aPrefix == txXMLAtoms::_empty))
      return kNameSpaceID_None;
  return kNameSpaceID_Unknown;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Attr::setNodeValue ( const nsAString &  aValue) [virtual]

Reimplemented from NodeDefinition.

Definition at line 98 of file Attr.cpp.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class AttrMap [friend]

Definition at line 518 of file dom.h.

friend class Document [friend]

Reimplemented from NodeDefinition.

Definition at line 512 of file dom.h.

friend class Element [friend]

Definition at line 519 of file dom.h.

friend class txXPathNodeUtils [friend, inherited]

Definition at line 290 of file dom.h.

friend class txXPathTreeWalker [friend, inherited]

Definition at line 289 of file dom.h.


Member Data Documentation

unsigned Node::count [inherited]

Definition at line 112 of file trace.cpp.

char* Node::function [inherited]

Definition at line 110 of file trace.cpp.

unsigned Node::hits [inherited]

Definition at line 113 of file trace.cpp.

PRUint32 NodeList::length [protected, inherited]

Definition at line 154 of file dom.h.

Definition at line 523 of file dom.h.

Definition at line 524 of file dom.h.

Node* Node::next [inherited]

Definition at line 114 of file trace.cpp.

nsString NodeDefinition::nodeName [protected, inherited]

Definition at line 299 of file dom.h.

nsString NodeDefinition::nodeValue [protected, inherited]

Definition at line 300 of file dom.h.

Definition at line 521 of file dom.h.


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