Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsTextNode.cpp File Reference
#include "nsGenericDOMDataNode.h"
#include "nsIDOMText.h"
#include "nsLayoutAtoms.h"
#include "nsContentUtils.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMMutationEvent.h"
#include "nsIAttribute.h"
#include "nsIDocument.h"

Go to the source code of this file.

Classes

class  nsTextNode
 Class used to implement DOM text nodes. More...
class  nsAttributeTextNode
 class used to implement attr() generated content More...
class  nsAttributeTextNode::nsAttrChangeListener

Functions

nsresult NS_NewTextNode (nsITextContent **aInstancePtrResult, nsNodeInfoManager *aNodeInfoManager)
 aNodeInfoManager must not be null.
 NS_IMPL_ISUPPORTS1 (nsAttributeTextNode::nsAttrChangeListener, nsIDOMEventListener) NS_IMETHODIMP nsAttributeTextNode
nsresult NS_NewAttributeContent (nsNodeInfoManager *aNodeInfoManager, PRInt32 aNameSpaceID, nsIAtom *aAttrName, nsIContent **aResult)

Function Documentation

Definition at line 276 of file nsTextNode.cpp.

{
  // If mContent is null while we still get events, something is very wrong
  NS_ENSURE_TRUE(mContent, NS_ERROR_UNEXPECTED);
  
  nsCOMPtr<nsIDOMMutationEvent> event(do_QueryInterface(aEvent));
  NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);

  nsCOMPtr<nsIDOMEventTarget> target;
  event->GetTarget(getter_AddRefs(target));
  // Can't compare as an nsIDOMEventTarget, since that's implemented via a
  // tearoff...
  nsCOMPtr<nsIContent> targetContent(do_QueryInterface(target));
  if (targetContent != mContent->GetParent()) {
    // not the right node
    return NS_OK;
  }
  
  nsCOMPtr<nsIDOMNode> relatedNode;
  event->GetRelatedNode(getter_AddRefs(relatedNode));
  NS_ENSURE_TRUE(relatedNode, NS_ERROR_UNEXPECTED);
  nsCOMPtr<nsIAttribute> attr(do_QueryInterface(relatedNode));
  NS_ENSURE_TRUE(attr, NS_ERROR_UNEXPECTED);

  if (attr->NodeInfo()->Equals(mAttrName, mNameSpaceID)) {
    nsAutoString value;
    targetContent->GetAttr(mNameSpaceID, mAttrName, value);
    mContent->SetText(value, PR_TRUE);
  }
  
  return NS_OK;
}

Here is the call graph for this function:

nsresult NS_NewAttributeContent ( nsNodeInfoManager aNodeInfoManager,
PRInt32  aNameSpaceID,
nsIAtom aAttrName,
nsIContent **  aResult 
)

Definition at line 314 of file nsTextNode.cpp.

{
  NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager");
  NS_PRECONDITION(aAttrName, "Must have an attr name");
  NS_PRECONDITION(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
  
  *aResult = nsnull;
  
  nsRefPtr<nsAttributeTextNode> textNode =
    new nsAttributeTextNode(aNodeInfoManager);
  if (!textNode) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  textNode->mListener =
    new nsAttributeTextNode::nsAttrChangeListener(aNameSpaceID,
                                                  aAttrName,
                                                  textNode);
  NS_ENSURE_TRUE(textNode->mListener, NS_ERROR_OUT_OF_MEMORY);

  NS_ADDREF(*aResult = textNode);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewTextNode ( nsITextContent **  aInstancePtrResult,
nsNodeInfoManager aNodeInfoManager 
)

aNodeInfoManager must not be null.

Definition at line 135 of file nsTextNode.cpp.

{
  NS_PRECONDITION(aNodeInfoManager, "Missing nodeInfoManager");

  *aInstancePtrResult = nsnull;

  nsCOMPtr<nsITextContent> instance = new nsTextNode(aNodeInfoManager);
  if (!instance) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(*aInstancePtrResult = instance);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: