Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsFrameContentIterator.cpp File Reference
#include "nsCOMPtr.h"
#include "nsIContentIterator.h"
#include "nsPresContext.h"
#include "nsIFrame.h"
#include "nsIContent.h"
#include "nsIEnumerator.h"
#include "nsFrameList.h"

Go to the source code of this file.

Classes

class  nsFrameContentIterator

Functions

static nsIFrameGetNextChildFrame (nsPresContext *aPresContext, nsIFrame *aFrame)
static nsIFrameGetPrevChildFrame (nsPresContext *aPresContext, nsIFrame *aFrame)
nsresult NS_NewFrameContentIterator (nsPresContext *aPresContext, nsIFrame *aFrame, nsIContentIterator **aIterator)

Function Documentation

static nsIFrame* GetNextChildFrame ( nsPresContext aPresContext,
nsIFrame aFrame 
) [static]

Definition at line 112 of file nsFrameContentIterator.cpp.

{
  NS_PRECONDITION(aFrame, "null pointer");

  // Get the last-in-flow
  aFrame = aFrame->GetLastInFlow();

  // Get its next sibling
  nsIFrame* nextSibling = aFrame->GetNextSibling();

  // If there's no next sibling, then check if the parent frame
  // has a next-in-flow and look there
  if (!nextSibling) {
    nsIFrame* parent = aFrame->GetParent()->GetNextInFlow();

    if (parent) {
      nextSibling = parent->GetFirstChild(nsnull);
    }
  }

  return nextSibling;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIFrame* GetPrevChildFrame ( nsPresContext aPresContext,
nsIFrame aFrame 
) [static]

Definition at line 169 of file nsFrameContentIterator.cpp.

{
  NS_PRECONDITION(aFrame, "null pointer");

  // Get its previous sibling. Because we have a singly linked list we
  // need to search from the first child
  nsIFrame* parent = aFrame->GetParent();
  nsIFrame* prevSibling;
  nsIFrame* firstChild = parent->GetFirstChild(nsnull);

  NS_ASSERTION(firstChild, "parent has no first child");
  nsFrameList frameList(firstChild);
  prevSibling = frameList.GetPrevSiblingFor(aFrame);

  // If there's no previous sibling, then check if the parent frame
  // has a prev-in-flow and look there
  if (!prevSibling) {
    parent = parent->GetPrevInFlow();

    if (parent) {
      firstChild = parent->GetFirstChild(nsnull);
      frameList.SetFrames(firstChild);
      prevSibling = frameList.LastChild();
    }
  }
  
  // Get the first-in-flow
  while (PR_TRUE) {
    nsIFrame* prevInFlow = prevSibling->GetPrevInFlow();
    if (prevInFlow) {
      prevSibling = prevInFlow;
    } else {
      break;
    }
  }

  return prevSibling;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewFrameContentIterator ( nsPresContext aPresContext,
nsIFrame aFrame,
nsIContentIterator **  aIterator 
)

Definition at line 266 of file nsFrameContentIterator.cpp.

{
  NS_ENSURE_ARG_POINTER(aIterator);
  if (!aIterator) {
    return NS_ERROR_NULL_POINTER;
  }
  NS_ENSURE_ARG_POINTER(aFrame);
  if (!aFrame) {
    return NS_ERROR_NULL_POINTER;
  }
  
  // Make sure the frame corresponds to generated content
  NS_ASSERTION(aFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT, "unexpected frame");

  nsFrameContentIterator* it = new nsFrameContentIterator(aPresContext, aFrame);
  if (!it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  return it->QueryInterface(NS_GET_IID(nsIContentIterator), (void **)aIterator);
}

Here is the call graph for this function:

Here is the caller graph for this function: