Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsRange.h File Reference
#include "nsIDOMRange.h"
#include "nsIRangeUtils.h"
#include "nsIDOMNSRange.h"
#include "nsCOMPtr.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIContent.h"
#include "nsIDOMNode.h"
#include "prmon.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nsRangeUtils
class  nsRange

Functions

nsresult NS_NewRange (nsIDOMRange **aInstancePtrResult)
nsresult NS_NewRangeUtils (nsIRangeUtils **aInstancePtrResult)
PRBool GetNodeBracketPoints (nsIContent *aNode, nsCOMPtr< nsIDOMNode > *outParent, PRInt32 *outStartOffset, PRInt32 *outEndOffset)

Function Documentation

PRBool GetNodeBracketPoints ( nsIContent aNode,
nsCOMPtr< nsIDOMNode > *  outParent,
PRInt32 outStartOffset,
PRInt32 outEndOffset 
)

Definition at line 249 of file nsRange.cpp.

{
  if (!aNode) 
    return PR_FALSE;
  if (!outParent) 
    return PR_FALSE;
  if (!outStartOffset)
    return PR_FALSE;
  if (!outEndOffset)
    return PR_FALSE;
    
  nsIContent* parent = aNode->GetParent();

  if (!parent) // special case for root node
  {
    // can't make a parent/offset pair to represent start or 
    // end of the root node, becasue it has no parent.
    // so instead represent it by (node,0) and (node,numChildren)
    *outParent = do_QueryInterface(aNode);
    PRUint32 indx = aNode->GetChildCount();
    if (!indx)
      return PR_FALSE;
    *outStartOffset = 0;
    *outEndOffset = indx;
  }
  else
  {
    *outParent = do_QueryInterface(parent);
    *outStartOffset = parent->IndexOf(aNode);
    *outEndOffset = *outStartOffset+1;
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewRange ( nsIDOMRange **  aInstancePtrResult)

Definition at line 366 of file nsRange.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);

  nsRange * range = new nsRange();
  if (!range) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  return CallQueryInterface(range, aResult);
}
nsresult NS_NewRangeUtils ( nsIRangeUtils **  aInstancePtrResult)

Definition at line 300 of file nsRange.cpp.

{
  NS_ENSURE_ARG_POINTER(aResult);

  nsRangeUtils* rangeUtil = new nsRangeUtils();
  if (!rangeUtil) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  return CallQueryInterface(rangeUtil, aResult);
}