Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Attributes
nsGenConList Class Reference

#include <nsGenConList.h>

Inheritance diagram for nsGenConList:
Inheritance graph
[legend]
Collaboration diagram for nsGenConList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsGenConList ()
 ~nsGenConList ()
void Clear ()
void Insert (nsGenConNode *aNode)
PRBool DestroyNodesFor (nsIFrame *aFrame)
void Remove (nsGenConNode *aNode)
PRBool IsLast (nsGenConNode *aNode)

Static Public Member Functions

static nsGenConNodeNext (nsGenConNode *aNode)
static nsGenConNodePrev (nsGenConNode *aNode)
static PRBool NodeAfter (const nsGenConNode *aNode1, const nsGenConNode *aNode2)

Protected Attributes

nsGenConNodemFirstNode
PRUint32 mSize

Detailed Description

Definition at line 86 of file nsGenConList.h.


Constructor & Destructor Documentation

Definition at line 91 of file nsGenConList.h.

Definition at line 92 of file nsGenConList.h.

{ Clear(); }

Here is the call graph for this function:


Member Function Documentation

Definition at line 43 of file nsGenConList.cpp.

{
  //Delete entire list
  if (!mFirstNode)
    return;
  for (nsGenConNode *node = Next(mFirstNode); node != mFirstNode;
       node = Next(mFirstNode))
  {
    Remove(node);
    delete node;
  }
  delete mFirstNode;

  mFirstNode = nsnull;
  mSize = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 61 of file nsGenConList.cpp.

{
  if (!mFirstNode)
    return PR_FALSE; // list empty
  nsGenConNode* node;
  PRBool destroyed = PR_FALSE;
  while (mFirstNode->mPseudoFrame == aFrame) {
    destroyed = PR_TRUE;
    node = Next(mFirstNode);
    if (node == mFirstNode) { // Last link
      mFirstNode = nsnull;
      delete node;
      return PR_TRUE;
    }
    else {
      Remove(mFirstNode);
      delete mFirstNode;
      mFirstNode = node;
    }
  }
  node = Next(mFirstNode);
  while (node != mFirstNode) {
    if (node->mPseudoFrame == aFrame) {
      destroyed = PR_TRUE;
      nsGenConNode *nextNode = Next(node);
      Remove(node);
      delete node;
      node = nextNode;
    } else {
      node = Next(node);
    }
  }
  return destroyed;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 142 of file nsGenConList.cpp.

{
  if (mFirstNode) {
    // Check for append.
    if (NodeAfter(aNode, Prev(mFirstNode))) {
      PR_INSERT_BEFORE(aNode, mFirstNode);
    }
    else {
      // Binary search.

      // the range of indices at which |aNode| could end up.
      PRUint32 first = 0, last = mSize - 1;

      // A cursor to avoid walking more than the length of the list.
      nsGenConNode *curNode = Prev(mFirstNode);
      PRUint32 curIndex = mSize - 1;

      while (first != last) {
        PRUint32 test = (first + last) / 2;
        if (last == curIndex) {
          for ( ; curIndex != test; --curIndex)
            curNode = Prev(curNode);
        } else {
          for ( ; curIndex != test; ++curIndex)
            curNode = Next(curNode);
        }

        if (NodeAfter(aNode, curNode)) {
          first = test + 1;
          // if we exit the loop, we need curNode to be right
          ++curIndex;
          curNode = Next(curNode);
        } else {
          last = test;
        }
      }
      PR_INSERT_BEFORE(aNode, curNode);
      if (curNode == mFirstNode) {
        mFirstNode = aNode;
      }
    }
  }
  else {
    // initialize list with first node
    PR_INIT_CLIST(aNode);
    mFirstNode = aNode;
  }
  ++mSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsGenConList::IsLast ( nsGenConNode aNode) [inline]

Definition at line 109 of file nsGenConList.h.

{ return (Next(aNode) == mFirstNode); }

Here is the call graph for this function:

Here is the caller graph for this function:

static nsGenConNode* nsGenConList::Next ( nsGenConNode aNode) [inline, static]

Definition at line 94 of file nsGenConList.h.

                                                 {
    return NS_STATIC_CAST(nsGenConNode*, PR_NEXT_LINK(aNode));
  }

Here is the caller graph for this function:

PRBool nsGenConList::NodeAfter ( const nsGenConNode aNode1,
const nsGenConNode aNode2 
) [static]

Definition at line 108 of file nsGenConList.cpp.

{
  nsIFrame *frame1 = aNode1->mPseudoFrame;
  nsIFrame *frame2 = aNode2->mPseudoFrame;
  if (frame1 == frame2) {
    NS_ASSERTION(aNode2->mContentIndex != aNode1->mContentIndex, "identical");
    return aNode1->mContentIndex > aNode2->mContentIndex;
  }
  PRInt32 pseudoType1 = PseudoCompareType(frame1);
  PRInt32 pseudoType2 = PseudoCompareType(frame2);
  nsIContent *content1 = frame1->GetContent();
  nsIContent *content2 = frame2->GetContent();
  if (pseudoType1 == 0 || pseudoType2 == 0) {
    if (content1 == content2) {
      NS_ASSERTION(pseudoType1 != pseudoType2, "identical");
      return pseudoType2 == 0;
    }
    // We want to treat an element as coming before its :before (preorder
    // traversal), so treating both as :before now works.
    if (pseudoType1 == 0) pseudoType1 = -1;
    if (pseudoType2 == 0) pseudoType2 = -1;
  } else {
    if (content1 == content2) {
      NS_ASSERTION(pseudoType1 != pseudoType2, "identical");
      return pseudoType1 == 1;
    }
  }
  PRInt32 cmp = nsLayoutUtils::DoCompareTreePosition(content1, content2,
                                                     pseudoType1, -pseudoType2);
  NS_ASSERTION(cmp != 0, "same content, different frames");
  return cmp > 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsGenConNode* nsGenConList::Prev ( nsGenConNode aNode) [inline, static]

Definition at line 97 of file nsGenConList.h.

                                                 {
    return NS_STATIC_CAST(nsGenConNode*, PR_PREV_LINK(aNode));
  }

Here is the caller graph for this function:

void nsGenConList::Remove ( nsGenConNode aNode) [inline]

Definition at line 108 of file nsGenConList.h.

{ PR_REMOVE_LINK(aNode); mSize--; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 88 of file nsGenConList.h.

Definition at line 89 of file nsGenConList.h.


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