Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Types | Private Attributes
RangeSubtreeIterator Class Reference
Collaboration diagram for RangeSubtreeIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RangeSubtreeIterator ()
 ~RangeSubtreeIterator ()
nsresult Init (nsIDOMRange *aRange)
already_AddRefed< nsIDOMNodeGetCurrentNode ()
void First ()
void Last ()
void Next ()
void Prev ()
PRBool IsDone ()

Private Types

enum  RangeSubtreeIterState { eDone = 0, eUseStartCData, eUseIterator, eUseEndCData }

Private Attributes

nsCOMPtr< nsIContentIteratormIter
RangeSubtreeIterState mIterState
nsCOMPtr< nsIDOMCharacterDatamStartCData
nsCOMPtr< nsIDOMCharacterDatamEndCData

Detailed Description

Definition at line 1115 of file nsRange.cpp.


Member Enumeration Documentation

Enumerator:
eDone 
eUseStartCData 
eUseIterator 
eUseEndCData 

Definition at line 1119 of file nsRange.cpp.


Constructor & Destructor Documentation

Definition at line 1132 of file nsRange.cpp.

    : mIterState(eDone)
  {
  }

Definition at line 1136 of file nsRange.cpp.

  {
  }

Member Function Documentation

Definition at line 1237 of file nsRange.cpp.

Here is the caller graph for this function:

Definition at line 1216 of file nsRange.cpp.

{
  nsIDOMNode *node = nsnull;

  if (mIterState == eUseStartCData && mStartCData) {
    NS_ADDREF(node = mStartCData);
  } else if (mIterState == eUseEndCData && mEndCData)
    NS_ADDREF(node = mEndCData);
  else if (mIterState == eUseIterator && mIter)
  {
    nsIContent *content = mIter->GetCurrentNode();

    if (content) {
      CallQueryInterface(content, &node);
    }
  }

  return node;
}

Here is the call graph for this function:

Definition at line 1154 of file nsRange.cpp.

{
  mIterState = eDone;

  nsCOMPtr<nsIDOMNode> node;

  // Grab the start point of the range and QI it to
  // a CharacterData pointer. If it is CharacterData store
  // a pointer to the node.

  nsresult res = aRange->GetStartContainer(getter_AddRefs(node));
  if (!node) return NS_ERROR_FAILURE;

  mStartCData = do_QueryInterface(node);

  // Grab the end point of the range and QI it to
  // a CharacterData pointer. If it is CharacterData store
  // a pointer to the node.

  res = aRange->GetEndContainer(getter_AddRefs(node));
  if (!node) return NS_ERROR_FAILURE;

  mEndCData = do_QueryInterface(node);

  if (mStartCData && mStartCData == mEndCData)
  {
    // The range starts and stops in the same CharacterData
    // node. Null out the end pointer so we only visit the
    // node once!

    mEndCData = nsnull;
  }
  else
  {
    // Now create a Content Subtree Iterator to be used
    // for the subtrees between the end points!

    res = NS_NewContentSubtreeIterator(getter_AddRefs(mIter));
    if (NS_FAILED(res)) return res;

    res = mIter->Init(aRange);
    if (NS_FAILED(res)) return res;

    if (mIter->IsDone())
    {
      // The subtree iterator thinks there's nothing
      // to iterate over, so just free it up so we
      // don't accidentally call into it.

      mIter = nsnull;
    }
  }

  // Initialize the iterator by calling First().
  // Note that we are ignoring the return value on purpose!

  First();

  return NS_OK;
}

Here is the call graph for this function:

Definition at line 1147 of file nsRange.cpp.

  {
    return mIterState == eDone;
  }

Definition at line 1254 of file nsRange.cpp.

Definition at line 1271 of file nsRange.cpp.

{
  if (mIterState == eUseStartCData)
  {
    if (mIter)
    {
      mIter->First();

      mIterState = eUseIterator;
    }
    else if (mEndCData)
      mIterState = eUseEndCData;
    else
      mIterState = eDone;
  }
  else if (mIterState == eUseIterator)
  {
    mIter->Next();

    if (mIter->IsDone())
    {
      if (mEndCData)
        mIterState = eUseEndCData;
      else
        mIterState = eDone;
    }
  }
  else
    mIterState = eDone;
}

Definition at line 1303 of file nsRange.cpp.

{
  if (mIterState == eUseEndCData)
  {
    if (mIter)
    {
      mIter->Last();

      mIterState = eUseIterator;
    }
    else if (mStartCData)
      mIterState = eUseStartCData;
    else
      mIterState = eDone;
  }
  else if (mIterState == eUseIterator)
  {
    mIter->Prev();

    if (mIter->IsDone())
    {
      if (mStartCData)
        mIterState = eUseStartCData;
      else
        mIterState = eDone;
    }
  }
  else
    mIterState = eDone;
}

Member Data Documentation

Definition at line 1128 of file nsRange.cpp.

Definition at line 1124 of file nsRange.cpp.

Definition at line 1125 of file nsRange.cpp.

Definition at line 1127 of file nsRange.cpp.


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