Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions
nsFirstLetterFrame Class Reference

List of all members.

Public Member Functions

 nsFirstLetterFrame ()
NS_IMETHOD Init (nsPresContext *aPresContext, nsIContent *aContent, nsIFrame *aParent, nsStyleContext *aContext, nsIFrame *aPrevInFlow)
NS_IMETHOD SetInitialChildList (nsPresContext *aPresContext, nsIAtom *aListName, nsIFrame *aChildList)
virtual nsIAtomGetType () const
NS_IMETHOD Paint (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, const nsRect &aDirtyRect, nsFramePaintLayer aWhichLayer, PRUint32 aFlags=0)
NS_IMETHOD Reflow (nsPresContext *aPresContext, nsHTMLReflowMetrics &aDesiredSize, const nsHTMLReflowState &aReflowState, nsReflowStatus &aStatus)
NS_IMETHOD CanContinueTextRun (PRBool &aContinueTextRun) const
NS_IMETHOD SetSelected (nsPresContext *aPresContext, nsIDOMRange *aRange, PRBool aSelected, nsSpread aSpread)
NS_IMETHOD GetChildFrameContainingOffset (PRInt32 inContentOffset, PRBool inHint, PRInt32 *outFrameContentOffset, nsIFrame **outChildFrame)

Protected Member Functions

virtual PRIntn GetSkipSides () const
void DrainOverflowFrames (nsPresContext *aPresContext)

Detailed Description

Definition at line 51 of file nsFirstLetterFrame.cpp.

Constructor & Destructor Documentation

Definition at line 108 of file nsFirstLetterFrame.cpp.


Member Function Documentation

Definition at line 331 of file nsFirstLetterFrame.cpp.

  // We can continue a text run through a first-letter frame.
  aContinueTextRun = PR_TRUE;
  return NS_OK;

Definition at line 339 of file nsFirstLetterFrame.cpp.

  nsIFrame* overflowFrames;

  // Check for an overflow list with our prev-in-flow
  nsFirstLetterFrame* prevInFlow = (nsFirstLetterFrame*)mPrevInFlow;
  if (nsnull != prevInFlow) {
    overflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
    if (overflowFrames) {
      NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list");

      // When pushing and pulling frames we need to check for whether any
      // views need to be reparented.
      nsIFrame* f = overflowFrames;
      while (f) {
        nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
        f = f->GetNextSibling();
      mFrames.InsertFrames(this, nsnull, overflowFrames);

  // It's also possible that we have an overflow list for ourselves
  overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
  if (overflowFrames) {
    NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
    mFrames.AppendFrames(nsnull, overflowFrames);

  // Now repair our first frames style context (since we only reflow
  // one frame there is no point in doing any other ones until they
  // are reflowed)
  nsIFrame* kid = mFrames.FirstChild();
  if (kid) {
    nsRefPtr<nsStyleContext> sc;
    nsIContent* kidContent = kid->GetContent();
    if (kidContent) {
                   "should contain only text nodes");
      sc = aPresContext->StyleSet()->ResolveStyleForNonElement(mStyleContext);
      if (sc) {
        kid->SetStyleContext(aPresContext, sc);

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsFirstLetterFrame::GetChildFrameContainingOffset ( PRInt32  inContentOffset,
PRBool  inHint,
PRInt32 outFrameContentOffset,
nsIFrame **  outChildFrame 

Definition at line 189 of file nsFirstLetterFrame.cpp.

  nsIFrame *kid = mFrames.FirstChild();
  if (kid)
    return kid->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
    return nsFrame::GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);

Here is the call graph for this function:

PRIntn nsFirstLetterFrame::GetSkipSides ( ) const [protected, virtual]

Definition at line 127 of file nsFirstLetterFrame.cpp.

  return 0;
nsIAtom * nsFirstLetterFrame::GetType ( void  ) const [virtual]

Definition at line 121 of file nsFirstLetterFrame.cpp.

  return nsLayoutAtoms::letterFrame;
NS_IMETHODIMP nsFirstLetterFrame::Init ( nsPresContext aPresContext,
nsIContent aContent,
nsIFrame aParent,
nsStyleContext aContext,
nsIFrame aPrevInFlow 

Definition at line 133 of file nsFirstLetterFrame.cpp.

  nsresult rv;
  nsRefPtr<nsStyleContext> newSC;
  if (aPrevInFlow) {
    // Get proper style context for ourselves.  We're creating the frame
    // that represents everything *except* the first letter, so just create
    // a style context like we would for a text node.
    nsStyleContext* parentStyleContext = aContext->GetParent();
    if (parentStyleContext) {
      newSC = aPresContext->StyleSet()->
      if (newSC)
        aContext = newSC;
  rv = nsFirstLetterFrameSuper::Init(aPresContext, aContent, aParent,
                                     aContext, aPrevInFlow);
  return rv;

Here is the call graph for this function:

NS_IMETHODIMP nsFirstLetterFrame::Paint ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
const nsRect aDirtyRect,
nsFramePaintLayer  aWhichLayer,
PRUint32  aFlags = 0 

Definition at line 204 of file nsFirstLetterFrame.cpp.

  if (NS_FRAME_IS_UNFLOWABLE & mState) {
    return NS_OK;

  // Paint inline element backgrounds in the foreground layer.
    PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
  PaintDecorationsAndChildren(aPresContext, aRenderingContext, aDirtyRect,
                              aWhichLayer, PR_FALSE, aFlags);
  return NS_OK;
NS_IMETHODIMP nsFirstLetterFrame::Reflow ( nsPresContext aPresContext,
nsHTMLReflowMetrics aDesiredSize,
const nsHTMLReflowState aReflowState,
nsReflowStatus aStatus 

Definition at line 226 of file nsFirstLetterFrame.cpp.

  DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame", aReflowState.reason);
  DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
  nsresult rv = NS_OK;

  // Grab overflow list

  nsIFrame* kid = mFrames.FirstChild();

  // Setup reflow state for our child
  nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
  const nsMargin& bp = aReflowState.mComputedBorderPadding;
  nscoord lr = bp.left + bp.right;
  nscoord tb = + bp.bottom;
  if (NS_UNCONSTRAINEDSIZE != availSize.width) {
    availSize.width -= lr;
  if (NS_UNCONSTRAINEDSIZE != availSize.height) {
    availSize.height -= tb;

  // Reflow the child
  if (!aReflowState.mLineLayout) {
    // When there is no lineLayout provided, we provide our own. The
    // only time that the first-letter-frame is not reflowing in a
    // line context is when its floating.
    nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
    nsLineLayout ll(aPresContext, nsnull, &aReflowState,
                       PR_FALSE, PR_TRUE);
    rs.mLineLayout = &ll;

    kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);

  else {
    // Pretend we are a span and reflow the child frame
    nsLineLayout* ll = aReflowState.mLineLayout;
    PRBool        pushedFrame;

    ll->BeginSpan(this, &aReflowState, bp.left, availSize.width);
    ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
    nsSize size;
    ll->EndSpan(this, size,
                aMetrics.mComputeMEW ? &aMetrics.mMaxElementWidth : nsnull);

  // Place and size the child and update the output metrics
  kid->SetRect(nsRect(bp.left,, aMetrics.width, aMetrics.height));
  kid->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
  aMetrics.width += lr;
  aMetrics.height += tb;
  aMetrics.ascent +=;
  aMetrics.descent += bp.bottom;
  if (aMetrics.mComputeMEW) {
    aMetrics.mMaxElementWidth += lr;

  // Create a continuation or remove existing continuations based on
  // the reflow completion status.
  if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
    nsIFrame* kidNextInFlow = kid->GetNextInFlow();
    if (kidNextInFlow) {
      // Remove all of the childs next-in-flows
      NS_STATIC_CAST(nsContainerFrame*, kidNextInFlow->GetParent())
        ->DeleteNextInFlowChild(aPresContext, kidNextInFlow);
  else {
    // Create a continuation for the child frame if it doesn't already
    // have one.
    nsIFrame* nextInFlow;
    rv = CreateNextInFlow(aPresContext, this, kid, nextInFlow);
    if (NS_FAILED(rv)) {
      return rv;

    // And then push it to our overflow list
    if (nextInFlow) {
      SetOverflowFrames(aPresContext, nextInFlow);
    else {
      nsIFrame* nextSib = kid->GetNextSibling();
      if (nextSib) {
        SetOverflowFrames(aPresContext, nextSib);

  NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
  return rv;

Here is the call graph for this function:

NS_IMETHODIMP nsFirstLetterFrame::SetInitialChildList ( nsPresContext aPresContext,
nsIAtom aListName,
nsIFrame aChildList 

Definition at line 159 of file nsFirstLetterFrame.cpp.

  nsFrameManager *frameManager = aPresContext->FrameManager();

  for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) {
    NS_ASSERTION(frame->GetParent() == this, "Unexpected parent");
  return NS_OK;

Here is the call graph for this function:

NS_IMETHODIMP nsFirstLetterFrame::SetSelected ( nsPresContext aPresContext,
nsIDOMRange aRange,
PRBool  aSelected,
nsSpread  aSpread 

Definition at line 174 of file nsFirstLetterFrame.cpp.

  if (aSelected && ParentDisablesSelection())
    return NS_OK;
  nsIFrame *child = GetFirstChild(nsnull);
  while (child)
    child->SetSelected(aPresContext, aRange, aSelected, aSpread);
    // don't worry about result. there are more frames to come
    child = child->GetNextSibling();
  return NS_OK;

Here is the call graph for this function:

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