Logo Search packages:      
Sourcecode: xulrunner version File versions  Download package

void nsContentList::PopulateWithStartingAfter ( nsIContent aStartRoot,
nsIContent aStartChild,
PRUint32 &  aElementsToAppend 
) [protected]

Populate our list starting at the child of aStartRoot that comes after aStartChild (if such exists) and continuing in document order. Stop once we've picked up aElementsToAppend elements. This function enforces the invariant that |aElementsToAppend + mElements.Count()| is a constant.

aStartRoot the node with whose children we want to start traversal
aStartChild the child after which we want to start
aElementsToAppend how many elements to append to the list before stopping

Definition at line 788 of file nsContentList.cpp.

References nsIContent::GetChildAt(), nsIContent::GetChildCount(), nsIContent::GetParent(), nsIContent::IndexOf(), mDeep, and PopulateWith().

Referenced by PopulateSelf().

  NS_PRECONDITION(mDeep || aStartRoot == mRootContent ||
                  (aStartRoot->GetParent() == mRootContent &&
                   aStartChild == nsnull),
                  "Bogus aStartRoot or aStartChild");

  if (mDeep || aStartRoot == mRootContent) {
#ifdef DEBUG
    PRUint32 invariant = aElementsToAppend + mElements.Count();
    PRInt32 i = 0;
    if (aStartChild) {
      i = aStartRoot->IndexOf(aStartChild);
      NS_ASSERTION(i >= 0, "The start child must be a child of the start root!");
      ++i;  // move to one past

    PRUint32 childCount = aStartRoot->GetChildCount();
    for ( ; ((PRUint32)i) < childCount; ++i) {
      PopulateWith(aStartRoot->GetChildAt(i), PR_TRUE, aElementsToAppend);
      NS_ASSERTION(aElementsToAppend + mElements.Count() == invariant,
                   "Something is awry in PopulateWith!");
      if (aElementsToAppend == 0)

  // We want to make sure we don't move up past our root node. So if
  // we're there, don't move to the parent.
  if (aStartRoot == mRootContent)
  nsIContent* parent = aStartRoot->GetParent();
  if (parent)
    PopulateWithStartingAfter(parent, aStartRoot, aElementsToAppend);

Generated by  Doxygen 1.6.0   Back to index