Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Friends
nsFrameConstructorState Class Reference
Collaboration diagram for nsFrameConstructorState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFrameConstructorState (nsIPresShell *aPresShell, nsIFrame *aFixedContainingBlock, nsIFrame *aAbsoluteContainingBlock, nsIFrame *aFloatContainingBlock, nsILayoutHistoryState *aHistoryState)
 nsFrameConstructorState (nsIPresShell *aPresShell, nsIFrame *aFixedContainingBlock, nsIFrame *aAbsoluteContainingBlock, nsIFrame *aFloatContainingBlock)
 ~nsFrameConstructorState ()
void PushAbsoluteContainingBlock (nsIFrame *aNewAbsoluteContainingBlock, nsFrameConstructorSaveState &aSaveState)
void PushFloatContainingBlock (nsIFrame *aNewFloatContainingBlock, nsFrameConstructorSaveState &aSaveState, PRBool aFirstLetterStyle, PRBool aFirstLineStyle)
nsIFrameGetGeometricParent (const nsStyleDisplay *aStyleDisplay, nsIFrame *aContentParentFrame)
nsresult AddChild (nsIFrame *aNewFrame, nsFrameItems &aFrameItems, const nsStyleDisplay *aStyleDisplay, nsIContent *aContent, nsStyleContext *aStyleContext, nsIFrame *aParentFrame, PRBool aCanBePositioned=PR_TRUE, PRBool aCanBeFloated=PR_TRUE)
 Function to add a new frame to the right frame list.
void PushAnonymousContentCreator (nsIFrame *aCreator, nsIContent *aContent, PRBool aIsBlock, nsFrameConstructorInsertionState &aSaveState)

Public Attributes

nsPresContextmPresContext
nsIPresShellmPresShell
nsFrameManagermFrameManager
nsAbsoluteItems mFixedItems
nsAbsoluteItems mAbsoluteItems
nsAbsoluteItems mFloatedItems
PRBool mFirstLetterStyle
PRBool mFirstLineStyle
nsCOMPtr< nsILayoutHistoryStatemFrameState
nsPseudoFrames mPseudoFrames
nsIFramemAnonymousCreator
nsIContentmInsertionContent
PRBool mCreatorIsBlock

Protected Member Functions

void ProcessFrameInsertions (nsAbsoluteItems &aFrameItems, nsIAtom *aChildListName)
 ProcessFrameInsertions takes the frames in aFrameItems and adds them as kids to the aChildListName child list of |aFrameItems.containingBlock|.

Friends

class nsFrameConstructorSaveState
class nsFrameConstructorInsertionState

Detailed Description

Definition at line 1083 of file nsCSSFrameConstructor.cpp.


Constructor & Destructor Documentation

nsFrameConstructorState::nsFrameConstructorState ( nsIPresShell aPresShell,
nsIFrame aFixedContainingBlock,
nsIFrame aAbsoluteContainingBlock,
nsIFrame aFloatContainingBlock,
nsILayoutHistoryState aHistoryState 
)

Definition at line 1194 of file nsCSSFrameConstructor.cpp.

  : mPresContext(aPresShell->GetPresContext()),
    mPresShell(aPresShell),
    mFrameManager(aPresShell->FrameManager()),
    mFixedItems(aFixedContainingBlock),
    mAbsoluteItems(aAbsoluteContainingBlock),
    mFloatedItems(aFloatContainingBlock),
    mFirstLetterStyle(PR_FALSE),
    mFirstLineStyle(PR_FALSE),
    mFrameState(aHistoryState),
    mPseudoFrames(),
    mAnonymousCreator(nsnull),
    mInsertionContent(nsnull),
    mCreatorIsBlock(PR_FALSE)
{
}
nsFrameConstructorState::nsFrameConstructorState ( nsIPresShell aPresShell,
nsIFrame aFixedContainingBlock,
nsIFrame aAbsoluteContainingBlock,
nsIFrame aFloatContainingBlock 
)

Definition at line 1215 of file nsCSSFrameConstructor.cpp.

  : mPresContext(aPresShell->GetPresContext()),
    mPresShell(aPresShell),
    mFrameManager(aPresShell->FrameManager()),
    mFixedItems(aFixedContainingBlock),
    mAbsoluteItems(aAbsoluteContainingBlock),
    mFloatedItems(aFloatContainingBlock),
    mFirstLetterStyle(PR_FALSE),
    mFirstLineStyle(PR_FALSE),
    mPseudoFrames(),
    mAnonymousCreator(nsnull),
    mInsertionContent(nsnull),
    mCreatorIsBlock(PR_FALSE)
{
  mFrameState = aPresShell->GetDocument()->GetLayoutHistoryState();
}

Here is the call graph for this function:

Definition at line 1235 of file nsCSSFrameConstructor.cpp.

{
  ProcessFrameInsertions(mAbsoluteItems, nsLayoutAtoms::absoluteList);
  ProcessFrameInsertions(mFixedItems, nsLayoutAtoms::fixedList);
  ProcessFrameInsertions(mFloatedItems, nsLayoutAtoms::floatList);
}

Here is the call graph for this function:


Member Function Documentation

nsresult nsFrameConstructorState::AddChild ( nsIFrame aNewFrame,
nsFrameItems aFrameItems,
const nsStyleDisplay aStyleDisplay,
nsIContent aContent,
nsStyleContext aStyleContext,
nsIFrame aParentFrame,
PRBool  aCanBePositioned = PR_TRUE,
PRBool  aCanBeFloated = PR_TRUE 
)

Function to add a new frame to the right frame list.

This MUST be called on frames before their children have been processed if the frames might conceivably be out-of-flow; otherwise cleanup in error cases won't work right. Also, this MUST be called on frames after they have been initialized.

Parameters:
aNewFramethe frame to add
aFrameItemsthe list to add in-flow frames to
aStyleDisplaythe display struct for aNewFrame
aContentthe content pointer for aNewFrame
aStyleContextthe style context of aNewFrame
aParentFramethe parent frame for the content if it were in-flow
aCanBePositionedpass false if the frame isn't allowed to be positioned
aCanBeFloatedpass false if the frame isn't allowed to be floated
Exceptions:
NS_ERROR_OUT_OF_MEMORYif it happens.
Note:
If this method throws, that means that aNewFrame was not inserted into any frame lists. Furthermore, this method will handle cleanup of aNewFrame (via calling CleanupFrameReferences() and Destroy() on it).

Definition at line 1335 of file nsCSSFrameConstructor.cpp.

{
  // The comments in GetGeometricParent regarding root table frames
  // all apply here, unfortunately.

  PRBool needPlaceholder = PR_FALSE;
  nsFrameItems* frameItems = &aFrameItems;
  if (aCanBeFloated && aStyleDisplay->IsFloating() &&
      mFloatedItems.containingBlock) {
    NS_ASSERTION(aNewFrame->GetParent() == mFloatedItems.containingBlock,
                 "Float whose parent is not the float containing block?");
    needPlaceholder = PR_TRUE;
    frameItems = &mFloatedItems;
  } else if (aCanBePositioned) {
    if (aStyleDisplay->mPosition == NS_STYLE_POSITION_ABSOLUTE &&
        mAbsoluteItems.containingBlock) {
      NS_ASSERTION(aNewFrame->GetParent() == mAbsoluteItems.containingBlock,
                   "Abs pos whose parent is not the abs pos containing block?");
      needPlaceholder = PR_TRUE;
      frameItems = &mAbsoluteItems;
    }
    if (aStyleDisplay->mPosition == NS_STYLE_POSITION_FIXED &&
        mFixedItems.containingBlock) {
      NS_ASSERTION(aNewFrame->GetParent() == mFixedItems.containingBlock,
                   "Fixed pos whose parent is not the fixed pos containing block?");
      needPlaceholder = PR_TRUE;
      frameItems = &mFixedItems;
    }
  }

  if (needPlaceholder) {
    NS_ASSERTION(frameItems != &aFrameItems,
                 "Putting frame in-flow _and_ want a placeholder?");
    nsIFrame* placeholderFrame;
    nsresult rv =
      nsCSSFrameConstructor::CreatePlaceholderFrameFor(mPresShell,
                                                       mPresContext,
                                                       mFrameManager,
                                                       aContent,
                                                       aNewFrame,
                                                       aStyleContext,
                                                       aParentFrame,
                                                       &placeholderFrame);
    if (NS_FAILED(rv)) {
      // Note that aNewFrame could be the top frame for a scrollframe setup,
      // hence already set as the primary frame.  So we have to clean up here.
      // But it shouldn't have any out-of-flow kids.
      // XXXbz Maybe add a utility function to assert that?
      CleanupFrameReferences(mPresContext, mFrameManager,
                             aNewFrame);
      aNewFrame->Destroy(mPresContext);
      return rv;
    }

    // Add the placeholder frame to the flow
    aFrameItems.AddChild(placeholderFrame);
  }
#ifdef DEBUG
  else {
    NS_ASSERTION(aNewFrame->GetParent() == aParentFrame,
                 "In-flow frame has wrong parent");
  }
#endif

  frameItems->AddChild(aNewFrame);

  // Now add the special siblings too.
  nsIFrame* specialSibling = aNewFrame;
  while (specialSibling && IsFrameSpecial(specialSibling)) {
    GetSpecialSibling(mFrameManager, specialSibling, &specialSibling);
    if (specialSibling) {
      NS_ASSERTION(frameItems == &aFrameItems,
                   "IB split ending up in an out-of-flow childlist?");
      frameItems->AddChild(specialSibling);
    }
  }
  
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIFrame * nsFrameConstructorState::GetGeometricParent ( const nsStyleDisplay aStyleDisplay,
nsIFrame aContentParentFrame 
)

Definition at line 1294 of file nsCSSFrameConstructor.cpp.

{
  NS_PRECONDITION(aStyleDisplay, "Must have display struct!");

  // If there is no container for a fixed, absolute, or floating root
  // frame, we will ignore the positioning.  This hack is originally
  // brought to you by the letter T: tables, since other roots don't
  // even call into this code.  See bug 178855.
  //
  // XXX Disabling positioning in this case is a hack.  If one was so inclined,
  // one could support this either by (1) inserting a dummy block between the
  // table and the canvas or (2) teaching the canvas how to reflow positioned
  // elements. (1) has the usual problems when multiple frames share the same
  // content (notice all the special cases in this file dealing with inner
  // tables and outer tables which share the same content). (2) requires some
  // work and possible factoring.
  //
  // XXXbz couldn't we just force position to "static" on roots and
  // float to "none"?  That's OK per CSS 2.1, as far as I can tell.
  
  if (aStyleDisplay->IsFloating() && mFloatedItems.containingBlock) {
    NS_ASSERTION(!aStyleDisplay->IsAbsolutelyPositioned(),
                 "Absolutely positioned _and_ floating?");
    return mFloatedItems.containingBlock;
  }

  if (aStyleDisplay->mPosition == NS_STYLE_POSITION_ABSOLUTE &&
      mAbsoluteItems.containingBlock) {
    return mAbsoluteItems.containingBlock;
  }

  if (aStyleDisplay->mPosition == NS_STYLE_POSITION_FIXED &&
      mFixedItems.containingBlock) {
    return mFixedItems.containingBlock;
  }

  return aContentParentFrame;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFrameConstructorState::ProcessFrameInsertions ( nsAbsoluteItems aFrameItems,
nsIAtom aChildListName 
) [protected]

ProcessFrameInsertions takes the frames in aFrameItems and adds them as kids to the aChildListName child list of |aFrameItems.containingBlock|.

Definition at line 1440 of file nsCSSFrameConstructor.cpp.

{
  NS_PRECONDITION((&aFrameItems == &mFloatedItems &&
                   aChildListName == nsLayoutAtoms::floatList) ||
                  (&aFrameItems == &mAbsoluteItems &&
                   aChildListName == nsLayoutAtoms::absoluteList) ||
                  (&aFrameItems == &mFixedItems &&
                   aChildListName == nsLayoutAtoms::fixedList),
                  "Unexpected aFrameItems/aChildListName combination");

  nsIFrame* firstNewFrame = aFrameItems.childList;
  
  if (!firstNewFrame) {
    return;
  }
  
  nsIFrame* containingBlock = aFrameItems.containingBlock;

  NS_ASSERTION(containingBlock,
               "Child list without containing block?");
  
  // Insert the frames hanging out in aItems.  We can use SetInitialChildList()
  // if the containing block hasn't been reflown yet (so NS_FRAME_FIRST_REFLOW
  // is set) and doesn't have any frames in the aChildListName child list yet.
  nsIFrame* firstChild = containingBlock->GetFirstChild(aChildListName);
  nsresult rv = NS_OK;
  if (!firstChild && (containingBlock->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
    rv = containingBlock->SetInitialChildList(mPresContext,
                                              aChildListName,
                                              firstNewFrame);
  } else {
    // Note that whether the frame construction context is doing an append or
    // not is not helpful here, since it could be appending to some frame in
    // the middle of the document, which means we're not necessarily
    // appending to the children of the containing block.
    //
    // We need to make sure the 'append to the end of document' case is fast.
    // So first test the last child of the containing block
    nsIFrame* lastChild = nsLayoutUtils::GetLastSibling(firstChild);

    if (!lastChild ||
        nsLayoutUtils::CompareTreePosition(lastChild->GetContent(),
                                           firstNewFrame->GetContent(),
                                           containingBlock->GetContent()) < 0) {
      // no lastChild, or lastChild comes before the new children, so just append
      rv = containingBlock->AppendFrames(aChildListName, firstNewFrame);
    } else {
      nsIFrame* insertionPoint = nsnull;
      // try the other children
      for (nsIFrame* f = firstChild; f != lastChild; f = f->GetNextSibling()) {
        if (nsLayoutUtils::CompareTreePosition(f->GetContent(),
                                               firstNewFrame->GetContent(),
                                               containingBlock->GetContent()) > 0) {
          // f comes after the new children, so stop here and insert after
          // the previous frame
          break;
        }
        insertionPoint = f;
      }

      rv = containingBlock->InsertFrames(aChildListName, insertionPoint,
                                         firstNewFrame);
    }
  }
  aFrameItems.childList = nsnull;
  // XXXbz And if NS_FAILED(rv), what?  I guess we need to clean up the list
  // and deal with all the placeholders... but what if the placeholders aren't
  // in the document yet?  Could that happen?
  NS_ASSERTION(NS_SUCCEEDED(rv), "Frames getting lost!");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1255 of file nsCSSFrameConstructor.cpp.

{
  aSaveState.mItems = &mAbsoluteItems;
  aSaveState.mSavedItems = mAbsoluteItems;
  aSaveState.mChildListName = nsLayoutAtoms::absoluteList;
  aSaveState.mState = this;
  mAbsoluteItems = 
    nsAbsoluteItems(AdjustAbsoluteContainingBlock(mPresContext,
                                                  aNewAbsoluteContainingBlock));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1423 of file nsCSSFrameConstructor.cpp.

{
  NS_ASSERTION(aCreator || !aContent, "Must have a frame if there is an insertion node");
  aSaveState.mAnonymousCreator = mAnonymousCreator;
  aSaveState.mInsertionContent = mInsertionContent;
  aSaveState.mCreatorIsBlock = mCreatorIsBlock;
  aSaveState.mState = this;

  mAnonymousCreator = aCreator;
  mInsertionContent = aContent;
  mCreatorIsBlock = aIsBlock;
}

Here is the caller graph for this function:

void nsFrameConstructorState::PushFloatContainingBlock ( nsIFrame aNewFloatContainingBlock,
nsFrameConstructorSaveState aSaveState,
PRBool  aFirstLetterStyle,
PRBool  aFirstLineStyle 
)

Definition at line 1268 of file nsCSSFrameConstructor.cpp.

{
  // XXXbz we should probably just be able to assert that
  // aNewFloatContainingBlock is a float containing block... see XXX comment at
  // the top of ProcessChildren.
  NS_PRECONDITION(!aNewFloatContainingBlock ||
                  aNewFloatContainingBlock->GetContentInsertionFrame()->
                    IsFloatContainingBlock(),
                  "Please push a real float containing block!");
  aSaveState.mItems = &mFloatedItems;
  aSaveState.mFirstLetterStyle = &mFirstLetterStyle;
  aSaveState.mFirstLineStyle = &mFirstLineStyle;
  aSaveState.mSavedItems = mFloatedItems;
  aSaveState.mSavedFirstLetterStyle = mFirstLetterStyle;
  aSaveState.mSavedFirstLineStyle = mFirstLineStyle;
  aSaveState.mChildListName = nsLayoutAtoms::floatList;
  aSaveState.mState = this;
  mFloatedItems = nsAbsoluteItems(aNewFloatContainingBlock);
  mFirstLetterStyle = aFirstLetterStyle;
  mFirstLineStyle = aFirstLineStyle;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsFrameConstructorInsertionState [friend]

Definition at line 1184 of file nsCSSFrameConstructor.cpp.

friend class nsFrameConstructorSaveState [friend]

Definition at line 1183 of file nsCSSFrameConstructor.cpp.


Member Data Documentation

Definition at line 1091 of file nsCSSFrameConstructor.cpp.

Definition at line 1099 of file nsCSSFrameConstructor.cpp.

Definition at line 1103 of file nsCSSFrameConstructor.cpp.

Definition at line 1093 of file nsCSSFrameConstructor.cpp.

Definition at line 1094 of file nsCSSFrameConstructor.cpp.

Definition at line 1090 of file nsCSSFrameConstructor.cpp.

Definition at line 1092 of file nsCSSFrameConstructor.cpp.

Definition at line 1087 of file nsCSSFrameConstructor.cpp.

Definition at line 1095 of file nsCSSFrameConstructor.cpp.

Definition at line 1101 of file nsCSSFrameConstructor.cpp.

Definition at line 1085 of file nsCSSFrameConstructor.cpp.

Definition at line 1086 of file nsCSSFrameConstructor.cpp.

Definition at line 1096 of file nsCSSFrameConstructor.cpp.


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