Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Private Attributes | Friends
nsDocumentObserverList Class Reference

nsDocumentObserverList is the list of nsIDocumentObservers for a document. More...

#include <nsDocument.h>

Collaboration diagram for nsDocumentObserverList:
Collaboration graph

List of all members.


class  ForwardIterator
class  Iterator
class  ReverseIterator

Public Member Functions

 nsDocumentObserverList ()
PRBool PrependElement (nsIDocumentObserver *aObserver)
PRInt32 Contains (nsIDocumentObserver *aPossibleObserver) const
PRBool AppendElement (nsIDocumentObserver *aElement)
PRBool RemoveElement (nsIDocumentObserver *aElement)
void Clear ()

Private Attributes

nsAutoVoidArray mObservers


class Iterator

Detailed Description

nsDocumentObserverList is the list of nsIDocumentObservers for a document.

It doesn't allow direct reading of the list; all access must take place through stack-allocated nsDocumentObserverList::ForwardIterator or nsDocumentObserverList::ReverseIterator objects.

Definition at line 276 of file nsDocument.h.

Constructor & Destructor Documentation

Definition at line 279 of file nsDocument.h.

Member Function Documentation

Definition at line 345 of file nsDocument.h.

    return mObservers.AppendElement(aElement);

Definition at line 687 of file nsDocument.cpp.


  // Reset all iterators to a bogus position so they don't return
  // anything next time they're called.
  for (Iterator* iter = mIterators; iter; iter = iter->mNext) {
    iter->mPosition = -1;

Here is the caller graph for this function:

PRInt32 nsDocumentObserverList::Contains ( nsIDocumentObserver aPossibleObserver) const [inline]

Definition at line 341 of file nsDocument.h.

    return mObservers.IndexOf(aPossibleObserver) != -1;

Definition at line 642 of file nsDocument.cpp.

  PRBool prepended = mObservers.InsertElementAt(aObserver, 0);

  // This introduces an inconsistency -- forward iterators will not see the new
  // element, while backwards ones will.  That's kinda inherent in the
  // different iteration orders, though.
  if (prepended) {
    for (Iterator* iter = mIterators; iter; iter = iter->mNext) {

  return prepended;

Definition at line 659 of file nsDocument.cpp.

  PRInt32 index = mObservers.IndexOf(aElement);
  if (index == -1) {
    return PR_FALSE;

#ifdef DEBUG
  PRBool removed =
  NS_ASSERTION(removed, "How could we fail to remove by index?");

  for (Iterator* iter = mIterators; iter; iter = iter->mNext) {
    // If iter->mPosition == index then forward iterators are safe, since in
    // that case the position is not affected by the removal; all that's
    // affected is what element is at that position.  Backward iterators,
    // however, need to decrement mPosition in that case.
    if (iter->mPosition > index ||
        (iter->mPosition == index && iter->mStep < 0)) {
  return PR_TRUE;

Friends And Related Function Documentation

friend class Iterator [friend]

Definition at line 283 of file nsDocument.h.

Member Data Documentation

Definition at line 355 of file nsDocument.h.

nsAutoVoidArray nsDocumentObserverList::mObservers [private]

Definition at line 354 of file nsDocument.h.

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