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

void nsContentList::PopulateSelf ( PRUint32  aNeededLength  )  [protected]

Populate our list. Stop once we have at least aNeededLength elements. At the end of PopulateSelf running, either the last node we examined is the last node in our array or we have traversed the whole document (or both). If mDocument is null, the caller of PopulateSelf is responsible for calling SetDirty once it's gotten the information it wants from the list.

Parameters:
aNeededLength the length the list should have when we are done (unless it exhausts the document)

Definition at line 831 of file nsContentList.cpp.

References mState, PopulateWith(), and PopulateWithStartingAfter().

Referenced by BringSelfUpToDate().

{
  if (mState == LIST_DIRTY) {
    Reset();
  }
  PRUint32 count = mElements.Count();
  NS_ASSERTION(mState != LIST_DIRTY || count == 0,
               "Reset() not called when setting state to LIST_DIRTY?");

  if (count >= aNeededLength) // We're all set
    return;

  PRUint32 elementsToAppend = aNeededLength - count;
#ifdef DEBUG
  PRUint32 invariant = elementsToAppend + mElements.Count();
#endif
  if (count != 0) {
    PopulateWithStartingAfter(mElements[count - 1], nsnull, elementsToAppend);
    NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
                 "Something is awry in PopulateWithStartingAfter!");
  } else if (mRootContent) {
    PopulateWith(mRootContent, PR_FALSE, elementsToAppend);
    NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
                 "Something is awry in PopulateWith!");
  }
  else if (mDocument) {
    nsIContent *root = mDocument->GetRootContent();
    if (root) {
      PopulateWith(root, PR_TRUE, elementsToAppend);
      NS_ASSERTION(elementsToAppend + mElements.Count() == invariant,
                   "Something is awry in PopulateWith!");
    }
  }

  if (mDocument) {
    if (elementsToAppend != 0)
      mState = LIST_UP_TO_DATE;
    else
      mState = LIST_LAZY;
  }
  // Else no document, so we have to stay on our toes since we don't get
  // content notifications.  Caller will call SetDirty(); see documentation for
  // PopulateSelf() in the header.
}


Generated by  Doxygen 1.6.0   Back to index