Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends
nsListBoxLayout Class Reference

#include <nsListBoxLayout.h>

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

List of all members.

Public Member Functions

 nsListBoxLayout (nsIPresShell *aShell)
NS_IMETHOD Layout (nsIBox *aBox, nsBoxLayoutState &aState)
NS_IMETHOD GetPrefSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
NS_IMETHOD GetMinSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
NS_IMETHOD GetMaxSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
NS_IMETHOD CastToRowGroupLayout (nsGridRowGroupLayout **aRowGroup)
NS_IMETHOD CountRowsColumns (nsIBox *aBox, PRInt32 &aRowCount, PRInt32 &aComputedColumnCount)
NS_IMETHOD DirtyRows (nsIBox *aBox, nsBoxLayoutState &aState)
NS_IMETHOD BuildRows (nsIBox *aBox, nsGridRow *aRows, PRInt32 *aCount)
 Fill out the given row structure recursively.
NS_IMETHOD GetTotalMargin (nsIBox *aBox, nsMargin &aMargin, PRBool aIsHorizontal)
NS_IMETHOD GetRowCount (PRInt32 &aRowCount)
NS_IMETHOD CastToGridLayout (nsGridLayout2 **aGrid)
NS_IMETHOD GetGrid (nsIBox *aBox, nsGrid **aList, PRInt32 *aIndex, nsGridRowLayout *aRequestor=nsnull)
NS_IMETHOD GetParentGridPart (nsIBox *aBox, nsIBox **aParentBox, nsIGridPart **aParentGridRow)
NS_IMETHOD ChildrenInserted (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aPrevBox, nsIBox *aChildList)
NS_IMETHOD ChildrenAppended (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChildList)
NS_IMETHOD ChildrenRemoved (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChildList)
NS_IMETHOD ChildrenSet (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChildList)
NS_IMETHOD GetFlex (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nscoord &aFlex)
NS_IMETHOD GetAscent (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nscoord &aAscent)
NS_IMETHOD IsCollapsed (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, PRBool &aCollapsed)
NS_IMETHOD ChildBecameDirty (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChild)
NS_IMETHOD BecameDirty (nsIBox *aBox, nsBoxLayoutState &aState)
virtual void GetParentLayout (nsIBox *aBox, nsIBoxLayout **aParent)
virtual void AddBorderAndPadding (nsIBox *aBox, nsSize &aSize)
virtual void AddInset (nsIBox *aBox, nsSize &aSize)
virtual void AddMargin (nsIBox *aChild, nsSize &aSize)
virtual void AddMargin (nsSize &aSize, const nsMargin &aMargin)

Static Public Member Functions

static void Shutdown ()
static PRBool IsHorizontal (nsIBox *aBox)
static void SetLargestSize (nsSize &aSize1, const nsSize &aSize2, PRBool aIsHorizontal)
static void SetSmallestSize (nsSize &aSize1, const nsSize &aSize2, PRBool aIsHorizontal)
static void AddLargestSize (nsSize &aSize, const nsSize &aSizeToAdd, PRBool aIsHorizontal)
static void AddLargestSize (nsSize &aSize, const nsSize &aToAdd)
static void AddSmallestSize (nsSize &aSize, const nsSize &aSizeToAdd, PRBool aIsHorizontal)
static void AddSmallestSize (nsSize &aSize, const nsSize &aToAdd)
static void AddCoord (nscoord &aCoord, nscoord aCoordToAdd)

Protected Member Functions

NS_IMETHOD LayoutInternal (nsIBox *aBox, nsBoxLayoutState &aState)
 Called to layout our our children.
NS_IMETHOD ChildAddedOrRemoved (nsIBox *aBox, nsBoxLayoutState &aState)
virtual void ComputeChildsNextPosition (nsIBox *aBox, nsIBox *aChild, nscoord &aCurX, nscoord &aCurY, nscoord &aNextX, nscoord &aNextY, const nsRect &aChildSize, const nsRect &aContainingRect, nscoord childAscent, nscoord aMaxAscent)
virtual void ChildResized (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChild, nsBoxSize *aChildBoxSize, nsComputedBoxSize *aChildComputedBoxSize, nsBoxSize *aBoxSizes, nsComputedBoxSize *aComputedBoxSizes, const nsRect &aChildLayoutRect, nsRect &aChildActualRect, nsRect &aContainingRect, PRInt32 aFlexes, PRBool &aFinished)
virtual void ComputeChildSizes (nsIBox *aBox, nsBoxLayoutState &aState, nscoord &aGivenSize, nsBoxSize *aBoxSizes, nsComputedBoxSize *&aComputedBoxSizes)
virtual void PopulateBoxSizes (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsBoxSize *&aBoxSizes, nsComputedBoxSize *&aComputedBoxSizes, nscoord &aMinSize, nscoord &aMaxSize, PRInt32 &aFlexes)
virtual void InvalidateComputedSizes (nsComputedBoxSize *aComputedBoxSizes)
virtual PRBool GetDefaultFlex (PRInt32 &aFlex)
virtual void GetFrameState (nsIBox *aBox, nsFrameState &aState)

Static Protected Member Functions

static void AddWidth (nsSize &aSize, nscoord aSize2, PRBool aIsHorizontal)

Friends

nsresult NS_NewGridRowGroupLayout (nsIPresShell *aPresShell, nsIBoxLayout **aNewLayout)
nsresult NS_NewSprocketLayout (nsIPresShell *aPresShell, nsCOMPtr< nsIBoxLayout > &aNewLayout)

Detailed Description

Definition at line 48 of file nsListBoxLayout.h.


Constructor & Destructor Documentation

Definition at line 51 of file nsListBoxLayout.cpp.

  : nsGridRowGroupLayout(aPresShell)
{
}

Member Function Documentation

void nsBoxLayout::AddBorderAndPadding ( nsIBox *  aBox,
nsSize aSize 
) [virtual, inherited]

Definition at line 76 of file nsBoxLayout.cpp.

{
  nsBox::AddBorderAndPadding(aBox, aSize);
}

Here is the caller graph for this function:

void nsSprocketLayout::AddCoord ( nscoord aCoord,
nscoord  aCoordToAdd 
) [static, inherited]

Definition at line 1662 of file nsSprocketLayout.cpp.

{
  if (aCoord != NS_INTRINSICSIZE) 
  {
    if (aCoordToAdd == NS_INTRINSICSIZE)
      aCoord = aCoordToAdd;
    else
      aCoord += aCoordToAdd;
  }
}

Here is the caller graph for this function:

void nsBoxLayout::AddInset ( nsIBox *  aBox,
nsSize aSize 
) [virtual, inherited]

Definition at line 94 of file nsBoxLayout.cpp.

{
  nsBox::AddInset(aBox, aSize);
}

Here is the caller graph for this function:

void nsBoxLayout::AddLargestSize ( nsSize aSize,
const nsSize aToAdd 
) [static, inherited]

Definition at line 159 of file nsBoxLayout.cpp.

{
  if (aSize2.width > aSize.width)
     aSize.width = aSize2.width;

  if (aSize2.height > aSize.height)
     aSize.height = aSize2.height;
}

Here is the caller graph for this function:

void nsSprocketLayout::AddLargestSize ( nsSize aSize,
const nsSize aSizeToAdd,
PRBool  aIsHorizontal 
) [static, inherited]

Definition at line 1651 of file nsSprocketLayout.cpp.

{
  if (aIsHorizontal)
    AddCoord(aSize.width, aSizeToAdd.width);
  else
    AddCoord(aSize.height, aSizeToAdd.height);

  SetLargestSize(aSize, aSizeToAdd, aIsHorizontal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsBoxLayout::AddMargin ( nsIBox *  aChild,
nsSize aSize 
) [virtual, inherited]

Definition at line 82 of file nsBoxLayout.cpp.

{
  nsBox::AddMargin(aBox, aSize);
}

Here is the caller graph for this function:

void nsBoxLayout::AddMargin ( nsSize aSize,
const nsMargin aMargin 
) [virtual, inherited]

Definition at line 88 of file nsBoxLayout.cpp.

{
  nsBox::AddMargin(aSize, aMargin);
}

Here is the call graph for this function:

void nsBoxLayout::AddSmallestSize ( nsSize aSize,
const nsSize aToAdd 
) [static, inherited]

Definition at line 169 of file nsBoxLayout.cpp.

{
  if (aSize2.width < aSize.width)
     aSize.width = aSize2.width;

  if (aSize2.height < aSize.height)
     aSize.height = aSize2.height;
}

Here is the caller graph for this function:

void nsSprocketLayout::AddSmallestSize ( nsSize aSize,
const nsSize aSizeToAdd,
PRBool  aIsHorizontal 
) [static, inherited]

Definition at line 1673 of file nsSprocketLayout.cpp.

{
  if (aIsHorizontal)
    AddCoord(aSize.width, aSizeToAdd.width);
  else
    AddCoord(aSize.height, aSizeToAdd.height);
    
  SetSmallestSize(aSize, aSizeToAdd, aIsHorizontal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsGridRowGroupLayout::AddWidth ( nsSize aSize,
nscoord  aSize2,
PRBool  aIsHorizontal 
) [static, protected, inherited]

Definition at line 90 of file nsGridRowGroupLayout.cpp.

{
  nscoord& size = GET_WIDTH(aSize, aIsHorizontal);

  if (size == NS_INTRINSICSIZE || aSize2 == NS_INTRINSICSIZE)
    size = NS_INTRINSICSIZE;
  else
    size += aSize2;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsBoxLayout::BecameDirty ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual, inherited]

Implements nsIBoxLayout.

Reimplemented in nsGridRowLeafLayout.

Definition at line 209 of file nsBoxLayout.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsGridRowGroupLayout::BuildRows ( nsIBox *  aBox,
nsGridRow aRows,
PRInt32 aCount 
) [virtual, inherited]

Fill out the given row structure recursively.

Implements nsIGridPart.

Definition at line 283 of file nsGridRowGroupLayout.cpp.

{ 
  PRInt32 rowCount = 0;

  if (aBox) {
    nsIBox* child = nsnull;
    aBox->GetChildBox(&child); 

    while(child) {
      
      // first see if it is a scrollframe. If so walk down into it and get the scrolled child
      nsIBox* deepChild = nsGrid::GetScrolledBox(child);

      nsCOMPtr<nsIBoxLayout> layout;
      // deepChild might be null if child is a scrollframe around a non-box.
      // But in that case there's nothing special that needs doing there.
      if (deepChild) {
        deepChild->GetLayoutManager(getter_AddRefs(layout));
      }
      if (layout) {
        nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
        if (monument) {
          PRInt32 count = 0;
          monument->BuildRows(deepChild, &aRows[rowCount], &count);
          rowCount += count;
          child->GetNextBox(&child);
          deepChild = child;
          continue;
        }
      }

      aRows[rowCount].Init(child, PR_TRUE);

      child->GetNextBox(&child);

      // if not a monument. Then count it. It will be a bogus row
      rowCount++;
    }
  }

  *aCount = rowCount;

  return NS_OK;
}

Here is the call graph for this function:

Implements nsIGridPart.

Definition at line 195 of file nsGridRowLayout.cpp.

{
  (*aGridLayout) = nsnull;
  return NS_OK;
}

Reimplemented from nsGridRowLayout.

Definition at line 329 of file nsGridRowGroupLayout.cpp.

{
  (*aRowGroup) = this;
  return NS_OK;
}
NS_IMETHODIMP nsGridRowGroupLayout::ChildAddedOrRemoved ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [protected, virtual, inherited]

Implements nsGridRowLayout.

Definition at line 76 of file nsGridRowGroupLayout.cpp.

{
  nsGrid* grid = nsnull;
  PRInt32 index = 0;
  GetGrid(aBox, &grid, &index);
  PRInt32 isHorizontal = IsHorizontal(aBox);

  if (grid)
    grid->RowAddedOrRemoved(aState, index, isHorizontal);

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsBoxLayout::ChildBecameDirty ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChild 
) [virtual, inherited]

Implements nsIBoxLayout.

Reimplemented in nsGridRowLeafLayout.

Definition at line 203 of file nsBoxLayout.cpp.

{
  return NS_OK;
}
NS_IMETHODIMP nsGridRowLayout::ChildrenAppended ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChildList 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 63 of file nsGridRowLayout.cpp.

{
  return ChildAddedOrRemoved(aBox, aState);
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowLayout::ChildrenInserted ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aPrevBox,
nsIBox *  aChildList 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 57 of file nsGridRowLayout.cpp.

{
  return ChildAddedOrRemoved(aBox, aState);
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowLayout::ChildrenRemoved ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChildList 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 69 of file nsGridRowLayout.cpp.

{
  return ChildAddedOrRemoved(aBox, aState);
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowLayout::ChildrenSet ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChildList 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 75 of file nsGridRowLayout.cpp.

{
  return ChildAddedOrRemoved(aBox, aState);
}

Here is the call graph for this function:

void nsSprocketLayout::ChildResized ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChild,
nsBoxSize aChildBoxSize,
nsComputedBoxSize aChildComputedBoxSize,
nsBoxSize aBoxSizes,
nsComputedBoxSize aComputedBoxSizes,
const nsRect aChildLayoutRect,
nsRect aChildActualRect,
nsRect aContainingRect,
PRInt32  aFlexes,
PRBool aFinished 
) [protected, virtual, inherited]

Definition at line 1047 of file nsSprocketLayout.cpp.

{
      nsRect childCurrentRect(aChildLayoutRect);

      PRBool isHorizontal = IsHorizontal(aBox);
      nscoord childLayoutWidth  = GET_WIDTH(aChildLayoutRect,isHorizontal);
      nscoord& childActualWidth  = GET_WIDTH(aChildActualRect,isHorizontal);
      nscoord& containingWidth   = GET_WIDTH(aContainingRect,isHorizontal);   
      
      //nscoord childLayoutHeight = GET_HEIGHT(aChildLayoutRect,isHorizontal);
      nscoord& childActualHeight = GET_HEIGHT(aChildActualRect,isHorizontal);
      nscoord& containingHeight  = GET_HEIGHT(aContainingRect,isHorizontal);

      PRBool recompute = PR_FALSE;

      // if we are a horizontal box see if the child will fit inside us.
      if ( childActualHeight > containingHeight) {
            // if we are a horizontal box and the the child it bigger than our height

            // ok if the height changed then we need to reflow everyone but us at the new height
            // so we will set the changed index to be us. And signal that we need a new pass.

            nsSize max(0,0);
            nsSize min(0,0);
            aChild->GetMaxSize(aState, max);
            aChild->GetMinSize(aState, min);
            nsBox::BoundsCheckMinMax(min, max);
            AddMargin(aChild, max);

            if (isHorizontal)
              childActualHeight = max.height < childActualHeight ? max.height : childActualHeight;
            else
              childActualHeight = max.width < childActualHeight ? max.width : childActualHeight;

            // only set if it changes
            if (childActualHeight > containingHeight) {
                 containingHeight = childActualHeight;

              // remember we do not need to clear the resized list because changing the height of a horizontal box
              // will not affect the width of any of its children because block flow left to right, top to bottom. Just trust me
              // on this one.
              aFinished = PR_FALSE;

              // only recompute if there are flexes.
              if (aFlexes > 0) {
                // relayout everything
                recompute = PR_TRUE;
                InvalidateComputedSizes(aComputedBoxSizes);
                nsComputedBoxSize* node = aComputedBoxSizes;

                while(node) {
                  node->resized = PR_FALSE;
                  node = node->next;
                }

              }              
            }
      } 
      
      if (childActualWidth > childLayoutWidth) {
            nsSize max(0,0);
            nsSize min(0,0);
            aChild->GetMinSize(aState, min);
            aChild->GetMaxSize(aState, max);
            nsBox::BoundsCheckMinMax(min, max);
            AddMargin(aChild, max);

            // our width now becomes the new size

            if (isHorizontal)
              childActualWidth = max.width < childActualWidth ? max.width : childActualWidth;
            else
              childActualWidth = max.height < childActualWidth ? max.height : childActualWidth;

            if (childActualWidth > childLayoutWidth) {
               aChildComputedSize->size = childActualWidth;
               aChildBoxSize->min = childActualWidth;
               if (aChildBoxSize->pref < childActualWidth)
                  aChildBoxSize->pref = childActualWidth;

              // if we have flexible elements with us then reflex things. Otherwise we can skip doing it.
              if (aFlexes > 0) {
                InvalidateComputedSizes(aComputedBoxSizes);

                nsComputedBoxSize* node = aComputedBoxSizes;
                aChildComputedSize->resized = PR_TRUE;

                while(node) {
                  if (node->resized)
                      node->valid = PR_TRUE;
                
                  node = node->next;
                }

                recompute = PR_TRUE;
                aFinished = PR_FALSE;
              } else {
                containingWidth += aChildComputedSize->size - childLayoutWidth;
              }              
            }
      }

      if (recompute)
            ComputeChildSizes(aBox, aState, containingWidth, aBoxSizes, aComputedBoxSizes);

      if (childCurrentRect != aChildActualRect) {
        // the childRect includes the margin
        // make sure we remove it before setting 
        // the bounds.
        nsMargin margin(0,0,0,0);
        aChild->GetMargin(margin);
        nsRect rect(aChildActualRect);
        if (rect.width >= margin.left + margin.right && rect.height >= margin.top + margin.bottom) 
          rect.Deflate(margin);

        aChild->SetBounds(aState, rect);
        aChild->Layout(aState);
      }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSprocketLayout::ComputeChildSizes ( nsIBox *  aBox,
nsBoxLayoutState aState,
nscoord aGivenSize,
nsBoxSize aBoxSizes,
nsComputedBoxSize *&  aComputedBoxSizes 
) [protected, virtual, inherited]

Reimplemented in nsGridRowLeafLayout.

Definition at line 1190 of file nsSprocketLayout.cpp.

{  

  //nscoord onePixel = aState.PresContext()->IntScaledPixelsToTwips(1);

  PRInt32 sizeRemaining            = aGivenSize;
  PRInt32 spacerConstantsRemaining = 0;

   // ----- calculate the spacers constants and the size remaining -----

  if (!aComputedBoxSizes)
      aComputedBoxSizes = new (aState) nsComputedBoxSize();
  
  nsBoxSize*         boxSizes = aBoxSizes;
  nsComputedBoxSize* computedBoxSizes = aComputedBoxSizes;
  PRInt32 count = 0;
  PRInt32 validCount = 0;

  while (boxSizes) 
  {

    NS_ASSERTION((boxSizes->min <= boxSizes->pref && boxSizes->pref <= boxSizes->max),"bad pref, min, max size");

    
     // ignore collapsed children
  //  if (boxSizes->collapsed) 
  //  {
    //  computedBoxSizes->valid = PR_TRUE;
    //  computedBoxSizes->size = boxSizes->pref;
     // validCount++;
  //      boxSizes->flex = 0;
   // }// else {
    
      if (computedBoxSizes->valid) { 
        sizeRemaining -= computedBoxSizes->size;
        validCount++;
      } else {
          if (boxSizes->flex == 0)
          {
            computedBoxSizes->valid = PR_TRUE;
            computedBoxSizes->size = boxSizes->pref;
            validCount++;
          }

          spacerConstantsRemaining += boxSizes->flex;
          sizeRemaining -= boxSizes->pref;
      }

      sizeRemaining -= (boxSizes->left + boxSizes->right);

    //} 

    boxSizes = boxSizes->next;

    if (boxSizes && !computedBoxSizes->next) 
      computedBoxSizes->next = new (aState) nsComputedBoxSize();

    computedBoxSizes = computedBoxSizes->next;
    count++;
  }

  // everything accounted for?
  if (validCount < count)
  {
    // ----- Ok we are give a size to fit into so stretch or squeeze to fit
    // ----- Make sure we look at our min and max size
    PRBool limit = PR_TRUE;
    for (int pass=1; PR_TRUE == limit; pass++) 
    {
      limit = PR_FALSE;
      boxSizes = aBoxSizes;
      computedBoxSizes = aComputedBoxSizes;

      while (boxSizes) { 

        // ignore collapsed spacers

   //    if (!boxSizes->collapsed) {
      
          nscoord pref = 0;
          nscoord max  = NS_INTRINSICSIZE;
          nscoord min  = 0;
          nscoord flex = 0;

          pref = boxSizes->pref;
          min  = boxSizes->min;
          max  = boxSizes->max;
          flex = boxSizes->flex;

          // ----- look at our min and max limits make sure we aren't too small or too big -----
          if (!computedBoxSizes->valid) {
            PRInt32 newSize = pref + sizeRemaining*flex/spacerConstantsRemaining; //NSToCoordRound(float((sizeRemaining*flex)/spacerConstantsRemaining));

            if (newSize<=min) {
              computedBoxSizes->size = min;
              computedBoxSizes->valid = PR_TRUE;
              spacerConstantsRemaining -= flex;
              sizeRemaining += pref;
              sizeRemaining -= min;
              limit = PR_TRUE;
            } else if (newSize>=max) {
              computedBoxSizes->size = max;
              computedBoxSizes->valid = PR_TRUE;
              spacerConstantsRemaining -= flex;
              sizeRemaining += pref;
              sizeRemaining -= max;
              limit = PR_TRUE;
            }
          }
       // }
        boxSizes         = boxSizes->next;
        computedBoxSizes = computedBoxSizes->next;
      }
    }
  }          

  // ---- once we have removed and min and max issues just stretch us out in the remaining space
  // ---- or shrink us. Depends on the size remaining and the spacer constants
  aGivenSize = 0;
  boxSizes = aBoxSizes;
  computedBoxSizes = aComputedBoxSizes;

  while (boxSizes) { 

    // ignore collapsed spacers
  //  if (!(boxSizes && boxSizes->collapsed)) {
    
      nscoord pref = 0;
      nscoord flex = 0;
      pref = boxSizes->pref;
      flex = boxSizes->flex;

      if (!computedBoxSizes->valid) {
        computedBoxSizes->size = pref + flex*sizeRemaining/spacerConstantsRemaining; //NSToCoordFloor(float((flex*sizeRemaining)/spacerConstantsRemaining));
        computedBoxSizes->valid = PR_TRUE;
      }

      aGivenSize += (boxSizes->left + boxSizes->right);
      aGivenSize += computedBoxSizes->size;

   // }

    boxSizes         = boxSizes->next;
    computedBoxSizes = computedBoxSizes->next;
  }
}

Here is the caller graph for this function:

void nsSprocketLayout::ComputeChildsNextPosition ( nsIBox *  aBox,
nsIBox *  aChild,
nscoord aCurX,
nscoord aCurY,
nscoord aNextX,
nscoord aNextY,
const nsRect aChildSize,
const nsRect aContainingRect,
nscoord  childAscent,
nscoord  aMaxAscent 
) [protected, virtual, inherited]

Definition at line 968 of file nsSprocketLayout.cpp.

{
  nsFrameState frameState = 0;
  GetFrameState(aBox, frameState);

  nsIBox::Halignment halign;
  nsIBox::Valignment valign;
  aBox->GetVAlign(valign);
  aBox->GetHAlign(halign);

  if (IsHorizontal(aBox)) {
    // Handle alignment of a horizontal box's children.
    if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
      aNextX = aCurX + aCurrentChildSize.width;
    else aNextX = aCurX - aCurrentChildSize.width;

    if (frameState & NS_STATE_AUTO_STRETCH)
      aCurY = aBoxRect.y;
    else {
      switch (valign) 
      {
         case nsBoxFrame::vAlign_BaseLine:
             aCurY = aBoxRect.y + (aMaxAscent - childAscent);
         break;

         case nsBoxFrame::vAlign_Top:
             aCurY = aBoxRect.y;
             break;
         case nsBoxFrame::vAlign_Middle:
             aCurY = aBoxRect.y + (aBoxRect.height/2 - aCurrentChildSize.height/2);
             break;
         case nsBoxFrame::vAlign_Bottom:
             aCurY = aBoxRect.y + aBoxRect.height - aCurrentChildSize.height;
             break;
      }
    }
  } else {
    // Handle alignment of a vertical box's children.
    if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
      aNextY = aCurY + aCurrentChildSize.height;
    else
      aNextY = aCurY - aCurrentChildSize.height;

    if (frameState & NS_STATE_AUTO_STRETCH)
      aCurX = aBoxRect.x;
    else {
      PRUint8 frameDirection = GetFrameDirection(aBox);
      switch (halign) 
      {
         case nsBoxFrame::hAlign_Left:
           if (frameDirection == NS_STYLE_DIRECTION_LTR)
             aCurX = aBoxRect.x;
           else
             aCurX = aBoxRect.x + aBoxRect.width - aCurrentChildSize.width;
           break;
         case nsBoxFrame::hAlign_Center:
             aCurX = aBoxRect.x + (aBoxRect.width/2 - aCurrentChildSize.width/2);
             break;
         case nsBoxFrame::hAlign_Right:
           if (frameDirection == NS_STYLE_DIRECTION_LTR)
             aCurX = aBoxRect.x + aBoxRect.width - aCurrentChildSize.width;
           else
             aCurX = aBoxRect.x;
           break;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsGridRowGroupLayout::CountRowsColumns ( nsIBox *  aBox,
PRInt32 aRowCount,
PRInt32 aComputedColumnCount 
) [virtual, inherited]

Implements nsIGridPart.

Definition at line 229 of file nsGridRowGroupLayout.cpp.

{
  if (aBox) {
    PRInt32 startCount = aRowCount;

    nsIBox* child = nsnull;
    aBox->GetChildBox(&child); 

    while(child) {
      
      // first see if it is a scrollframe. If so walk down into it and get the scrolled child
      nsIBox* deepChild = nsGrid::GetScrolledBox(child);

      nsCOMPtr<nsIBoxLayout> layout;
      // deepChild might be null if child is a scrollframe around a non-box.
      // But in that case I guess we can count this as a single grid row.  Or
      // something.
      if (deepChild) {
        deepChild->GetLayoutManager(getter_AddRefs(layout));
      }
      if (layout) {
        nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
        if (monument) {
          monument->CountRowsColumns(deepChild, aRowCount, aComputedColumnCount);
          child->GetNextBox(&child);
          deepChild = child;
          continue;
        }
      }

      child->GetNextBox(&child);

      // if not a monument. Then count it. It will be a bogus row
      aRowCount++;
    }

    mRowCount = aRowCount - startCount;
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowGroupLayout::DirtyRows ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual, inherited]

Implements nsIGridPart.

Definition at line 194 of file nsGridRowGroupLayout.cpp.

{
  if (aBox) {
    // mark us dirty
    aBox->MarkDirty(aState);
    nsIBox* child = nsnull;
    aBox->GetChildBox(&child); 

    while(child) {

      // walk into scrollframes
      nsIBox* deepChild = nsGrid::GetScrolledBox(child);

      // walk into other monuments
      nsCOMPtr<nsIBoxLayout> layout;
      // deepChild might be null if child is a scrollframe around a non-box.
      // But in that case there's nothing to do here, really.
      if (deepChild) {
        deepChild->GetLayoutManager(getter_AddRefs(layout));
      }
      if (layout) {
        nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
        if (monument) 
          monument->DirtyRows(deepChild, aState);
      }

      child->GetNextBox(&child);
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsSprocketLayout::GetAscent ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nscoord aAscent 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 1565 of file nsSprocketLayout.cpp.

{

  PRBool isHorizontal = IsHorizontal(aBox);

   aAscent = 0;

   // run through all the children and get there min, max, and preferred sizes
   // return us the size of the box
   
   nsIBox* child = nsnull;
   aBox->GetChildBox(&child);
   
   while (child) 
   {  
      // ignore collapsed children
      //PRBool isCollapsed = PR_FALSE;
      //aBox->IsCollapsed(aState, isCollapsed);

      //if (!isCollapsed)
      //{
        // if completely redefined don't even ask our child for its size.
        nscoord ascent = 0;
        child->GetAscent(aState, ascent);

        nsMargin margin;
        child->GetMargin(margin);
        ascent += margin.top;

        if (isHorizontal)
        {
          if (ascent > aAscent)
            aAscent = ascent;
        } else {
          if (aAscent == 0)
            aAscent = ascent;
        }
      //}
      child->GetNextBox(&child);
      
   }

  return NS_OK;
}

Here is the call graph for this function:

PRBool nsSprocketLayout::GetDefaultFlex ( PRInt32 aFlex) [protected, virtual, inherited]

Definition at line 1684 of file nsSprocketLayout.cpp.

{
    aFlex = 0;
    return PR_TRUE;
}
NS_IMETHODIMP nsSprocketLayout::GetFlex ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nscoord aFlex 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 1611 of file nsSprocketLayout.cpp.

{
  return aBox->GetFlex(aState, aFlex);
}
void nsSprocketLayout::GetFrameState ( nsIBox *  aBox,
nsFrameState aState 
) [protected, virtual, inherited]

Definition at line 99 of file nsSprocketLayout.cpp.

{
   aState = aBox->GetStateBits();
}

Here is the caller graph for this function:

NS_IMETHODIMP nsGridRowLayout::GetGrid ( nsIBox *  aBox,
nsGrid **  aList,
PRInt32 aIndex,
nsGridRowLayout aRequestor = nsnull 
) [virtual, inherited]

Implements nsIGridPart.

Definition at line 115 of file nsGridRowLayout.cpp.

{

   if (aRequestor == nsnull)
   {
      nsCOMPtr<nsIGridPart> parent;
      nsIBox* parentBox; // nsIBox is implemented by nsIFrame and is not refcounted.
      GetParentGridPart(aBox, &parentBox, getter_AddRefs(parent));
      if (parent)
         return parent->GetGrid(parentBox, aList, aIndex, this);
      else
         return NS_OK;
   }

   nsresult rv = NS_OK;

   PRInt32 index = -1;
   nsIBox* child = nsnull;
   aBox->GetChildBox(&child);
   PRInt32 count = 0;
   while(child)
   {
     // if there is a scrollframe walk inside it to its child
     nsIBox* childBox = nsGrid::GetScrolledBox(child);

     nsCOMPtr<nsIBoxLayout> layout;
     // childBox might be null if child is a scrollframe around a non-box.  But
     // in that case I guess we can count this as a single grid row.  Or
     // something.
     if (childBox) {
       childBox->GetLayoutManager(getter_AddRefs(layout));
     }
     
     // find our requester
     nsCOMPtr<nsIGridPart> gridRow = do_QueryInterface(layout, &rv);
     if (NS_SUCCEEDED(rv) && gridRow) 
     {
       if (layout == aRequestor) {
          index = count;
          break;
       }

       PRInt32 c = 0;
       gridRow->GetRowCount(c);
       count += c;
     } else 
       count++;

     child->GetNextBox(&child);
   }

   // if we didn't find ourselves then the tree isn't properly formed yet
   // this could happen during initial construction so lets just
   // fail.
   if (index == -1) {
     *aList = nsnull;
     *aIndex = -1;
     return NS_OK;
   }

   (*aIndex) += index;

   nsCOMPtr<nsIGridPart> parent;
   nsIBox* parentBox; // nsIBox is implemented by nsIFrame and is not refcounted.
   GetParentGridPart(aBox, &parentBox, getter_AddRefs(parent));

   if (parent)
      parent->GetGrid(parentBox, aList, aIndex, this);

   return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsListBoxLayout::GetMaxSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsGridRowGroupLayout.

Definition at line 113 of file nsListBoxLayout.cpp.

{
  nsresult rv = nsGridRowGroupLayout::GetMaxSize(aBox, aBoxLayoutState, aSize);

  nsListBoxBodyFrame* frame = NS_STATIC_CAST(nsListBoxBodyFrame*, aBox);
  if (frame) {
    nscoord rowheight = frame->GetRowHeightTwips();
    aSize.height = frame->GetRowCount() * rowheight;
    // Pad the height.
    nscoord y = frame->GetAvailableHeight();
    if (aSize.height > y && y > 0 && rowheight > 0) {
      nscoord m = (aSize.height-y)%rowheight;
      nscoord remainder = m == 0 ? 0 : rowheight - m;
      aSize.height += remainder;
    }
  }
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsListBoxLayout::GetMinSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsGridRowGroupLayout.

Definition at line 86 of file nsListBoxLayout.cpp.

{
  nsresult rv = nsGridRowGroupLayout::GetMinSize(aBox, aBoxLayoutState, aSize);

  nsListBoxBodyFrame* frame = NS_STATIC_CAST(nsListBoxBodyFrame*, aBox);
  if (frame) {
    nscoord rowheight = frame->GetRowHeightTwips();
    aSize.height = frame->GetRowCount() * rowheight;
    // Pad the height.
    nscoord y = frame->GetAvailableHeight();
    if (aSize.height > y && y > 0 && rowheight > 0) {
      nscoord m = (aSize.height-y)%rowheight;
      nscoord remainder = m == 0 ? 0 : rowheight - m;
      aSize.height += remainder;
    }
    nsAutoString sizeMode;
    frame->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode);
    if (!sizeMode.IsEmpty()) {
      nscoord width = frame->ComputeIntrinsicWidth(aBoxLayoutState);
      if (width > aSize.width)
        aSize.width = width;
    }
  }
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowLayout::GetParentGridPart ( nsIBox *  aBox,
nsIBox **  aParentBox,
nsIGridPart **  aParentGridRow 
) [virtual, inherited]

Implements nsIGridPart.

Definition at line 81 of file nsGridRowLayout.cpp.

{
  // go up and find our parent gridRow. Skip and non gridRow
  // parents.
  nsCOMPtr<nsIBoxLayout> layout;
  nsCOMPtr<nsIGridPart> parentGridRow;
  nsresult rv = NS_OK;
  *aParentGridPart = nsnull;
  
  // walk up through any scrollboxes
  aBox = nsGrid::GetScrollBox(aBox);

  // get the parent
  if (aBox)
      aBox->GetParentBox(&aBox);

  if (aBox)
  {
      aBox->GetLayoutManager(getter_AddRefs(layout));
      parentGridRow = do_QueryInterface(layout);
      *aParentGridPart = parentGridRow.get();
      *aParentBox = aBox;
      NS_IF_ADDREF(*aParentGridPart);
      return NS_OK;
  }

  *aParentGridPart = nsnull;
  *aParentBox = nsnull;
  
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsBoxLayout::GetParentLayout ( nsIBox *  aBox,
nsIBoxLayout **  aParent 
) [virtual, inherited]

Definition at line 62 of file nsBoxLayout.cpp.

{
  nsIBox* parent = nsnull;
  aBox->GetParentBox(&parent);
  if (parent)
  {
    parent->GetLayoutManager(aParent);
    return;
  }

  *aParent = nsnull;
}
NS_IMETHODIMP nsListBoxLayout::GetPrefSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsGridRowGroupLayout.

Definition at line 59 of file nsListBoxLayout.cpp.

{
  nsresult rv = nsGridRowGroupLayout::GetPrefSize(aBox, aBoxLayoutState, aSize);

  nsListBoxBodyFrame* frame = NS_STATIC_CAST(nsListBoxBodyFrame*, aBox);
  if (frame) {
    nscoord rowheight = frame->GetRowHeightTwips();
    aSize.height = frame->GetRowCount() * rowheight;
    // Pad the height.
    nscoord y = frame->GetAvailableHeight();
    if (aSize.height > y && y > 0 && rowheight > 0) {
      nscoord m = (aSize.height-y)%rowheight;
      nscoord remainder = m == 0 ? 0 : rowheight - m;
      aSize.height += remainder;
    }
    nsAutoString sizeMode;
    frame->GetContent()->GetAttr(kNameSpaceID_None, nsXULAtoms::sizemode, sizeMode);
    if (!sizeMode.IsEmpty()) {
      nscoord width = frame->ComputeIntrinsicWidth(aBoxLayoutState);
      if (width > aSize.width)
        aSize.width = width;
    }
  }
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowGroupLayout::GetRowCount ( PRInt32 aRowCount) [virtual, inherited]

Implements nsIGridPart.

Definition at line 272 of file nsGridRowGroupLayout.cpp.

{
  aRowCount = mRowCount;
  return NS_OK;
}
NS_IMETHODIMP nsGridRowGroupLayout::GetTotalMargin ( nsIBox *  aBox,
nsMargin aMargin,
PRBool  aIsHorizontal 
) [virtual, inherited]

Reimplemented from nsGridRowLayout.

Definition at line 336 of file nsGridRowGroupLayout.cpp.

{
  // group have border and padding added to the total margin

  nsresult rv = nsGridRowLayout::GetTotalMargin(aBox, aMargin, aIsHorizontal);
  
  // make sure we have the scrollframe on the outside if it has one.
  // thats where the border it.
  aBox = nsGrid::GetScrollBox(aBox);

  // add our border/padding to it
  nsMargin borderPadding(0,0,0,0);
  aBox->GetBorderAndPadding(borderPadding);

  aMargin += borderPadding;
  aBox->GetInset(borderPadding);

  aMargin += borderPadding;

  return rv;
}

Here is the call graph for this function:

void nsSprocketLayout::InvalidateComputedSizes ( nsComputedBoxSize aComputedBoxSizes) [protected, virtual, inherited]

Definition at line 1181 of file nsSprocketLayout.cpp.

{
  while(aComputedBoxSizes) {
      aComputedBoxSizes->valid = PR_FALSE;
      aComputedBoxSizes = aComputedBoxSizes->next;
  }
}

Here is the caller graph for this function:

NS_IMETHODIMP nsSprocketLayout::IsCollapsed ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
PRBool aCollapsed 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 1618 of file nsSprocketLayout.cpp.

{
  return aBox->IsCollapsed(aState, aIsCollapsed);
}
PRBool nsSprocketLayout::IsHorizontal ( nsIBox *  aBox) [static, inherited]

Definition at line 93 of file nsSprocketLayout.cpp.

{
   return (aBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsListBoxLayout::Layout ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual]

Reimplemented from nsSprocketLayout.

Definition at line 133 of file nsListBoxLayout.cpp.

{
  nsListBoxBodyFrame* frame = NS_STATIC_CAST(nsListBoxBodyFrame*, aBox);

  // Always ensure an accurate scrollview position
  // This is an edge case that was caused by the row height
  // changing after a scroll had occurred.  (Bug #51084)
  PRInt32 index;
  frame->GetIndexOfFirstVisibleRow(&index);
  if (index > 0) {
    nscoord pos = frame->GetYPosition();
    PRInt32 rowHeight = frame->GetRowHeightTwips();
    if (pos != (rowHeight*index)) {
      frame->VerticalScroll(rowHeight*index);
      frame->Redraw(aState, nsnull, PR_FALSE);
    }
  }

  nsresult rv = LayoutInternal(aBox, aState);
  if (NS_FAILED(rv)) return rv;

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsListBoxLayout::LayoutInternal ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [protected]

Called to layout our our children.

Does no frame construction

Definition at line 164 of file nsListBoxLayout.cpp.

{
  PRInt32 redrawStart = -1;

  // Get the start y position.
  nsListBoxBodyFrame* body = NS_STATIC_CAST(nsListBoxBodyFrame*, aBox);
  if (!body) {
    NS_ERROR("Frame encountered that isn't a listboxbody!\n");
    return NS_ERROR_FAILURE;
  }

  nsMargin margin;

  // Get our client rect.
  nsRect clientRect;
  aBox->GetClientRect(clientRect);

  // Get the starting y position and the remaining available
  // height.
  nscoord availableHeight = body->GetAvailableHeight();
  nscoord yOffset = body->GetYPosition();
  
  if (availableHeight <= 0) {
    PRBool fixed = (body->GetFixedRowSize() != -1);
    if (fixed)
      availableHeight = 10;
    else
      return NS_OK;
  }

  // run through all our currently created children
  nsIBox* box = nsnull;
  body->GetChildBox(&box);

  // if the reason is resize or initial we must relayout.
  PRBool relayout = (aState.LayoutReason() == nsBoxLayoutState::Resize || aState.LayoutReason() == nsBoxLayoutState::Initial);
  nscoord rowHeight = body->GetRowHeightTwips();

  while (box) {
    // If this box is dirty or if it has dirty children, we
    // call layout on it.
    PRBool dirty = PR_FALSE;           
    PRBool dirtyChildren = PR_FALSE;           
    box->IsDirty(dirty);
    box->HasDirtyChildren(dirtyChildren);
       
    nsRect childRect(box->GetRect());
    box->GetMargin(margin);
    
    // relayout if we must or we are dirty or some of our children are dirty
    //   or the client area is wider than us
    if (relayout || dirty || dirtyChildren || childRect.width < clientRect.width) {
      childRect.x = 0;
      childRect.y = yOffset;
      childRect.width = clientRect.width;
      
      nsSize size;
      box->GetPrefSize(aState, size);
      body->SetRowHeight(size.height);
      
      childRect.height = rowHeight;

      childRect.Deflate(margin);
      box->SetBounds(aState, childRect);
      box->Layout(aState);
    } else {
      // if the child did not need to be relayed out. Then its easy.
      // Place the child by just grabbing its rect and adjusting the y.
      PRInt32 newPos = yOffset+margin.top;

      // are we pushing down or pulling up any rows?
      // Then we may have to redraw everything below the the moved 
      // rows.
      if (redrawStart == -1 && childRect.y != newPos)
        redrawStart = newPos;

      childRect.y = newPos;
      box->SetBounds(aState, childRect);
    }

    // Ok now the available size gets smaller and we move the
    // starting position of the next child down some.
    nscoord size = childRect.height + margin.top + margin.bottom;

    yOffset += size;
    availableHeight -= size;
    
    box->GetNextBox(&box);
  }
  
  // We have enough available height left to add some more rows
  // Since we can't do this during layout, we post a callback
  // that will be processed after the reflow completes.
  body->PostReflowCallback();
    
  // if rows were pushed down or pulled up because some rows were added
  // before them then redraw everything under the inserted rows. The inserted
  // rows will automatically be redrawn because the were marked dirty on insertion.
  if (redrawStart > -1) {
    nsRect bounds(aBox->GetRect());
    nsRect tempRect(0,redrawStart,bounds.width, bounds.height - redrawStart);
    aBox->Redraw(aState, &tempRect);
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSprocketLayout::PopulateBoxSizes ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsBoxSize *&  aBoxSizes,
nsComputedBoxSize *&  aComputedBoxSizes,
nscoord aMinSize,
nscoord aMaxSize,
PRInt32 aFlexes 
) [protected, virtual, inherited]

Reimplemented in nsGridRowLeafLayout.

Definition at line 724 of file nsSprocketLayout.cpp.

{
  // used for the equal size flag
  nscoord biggestPrefWidth = 0;
  nscoord biggestMinWidth = 0;
  nscoord smallestMaxWidth = NS_INTRINSICSIZE;

  nsFrameState frameState = 0;
  GetFrameState(aBox, frameState);

  //if (frameState & NS_STATE_CURRENTLY_IN_DEBUG)
  //   printf("In debug\n");

  aMinSize = 0;
  aMaxSize = NS_INTRINSICSIZE;

  PRBool isHorizontal;

  if (IsHorizontal(aBox))
     isHorizontal = PR_TRUE;
  else
     isHorizontal = PR_FALSE;

  // this is a nice little optimization
  // it turns out that if we only have 1 flexable child
  // then it does not matter what its preferred size is
  // there is nothing to flex it relative. This is great
  // because we can avoid asking for a preferred size in this
  // case. Why is this good? Well you might have html inside it
  // and asking html for its preferred size is rather expensive.
  // so we can just optimize it out this way.

  // set flexes
  nsIBox* child = nsnull;
  aBox->GetChildBox(&child);

  aFlexes = 0;
  nsBoxSize* currentBox = nsnull;

#if 0
  nsBoxSize* start = aBoxSizes;
  
  while(child)
  {
    // ok if we started with a list move down the list
    // until we reach the end. Then start looking at childen.
    // This feature is used extensively for Grid.
    nscoord flex = 0;    

    if (!start) {
      if (!currentBox) {
        aBoxSizes      = new (aState) nsBoxSize();
        currentBox      = aBoxSizes;
      } else {
        currentBox->next      = new (aState) nsBoxSize();
        currentBox      = currentBox->next;
      }
    

      child->GetFlex(aState, flex);
      PRBool collapsed = PR_FALSE;    
      child->IsCollapsed(aState, collapsed);

      currentBox->flex = flex;
      currentBox->collapsed = collapsed;
    } else {
      flex = start->flex;
      start = start->next;
    }
    
    if (flex > 0) 
       aFlexes++;
   
    child->GetNextBox(&child);
  }
#endif

  // get pref, min, max
  aBox->GetChildBox(&child);
  currentBox = aBoxSizes;
  nsBoxSize* last = nsnull;

  nscoord maxFlex = 0;
  PRInt32 childCount = 0;

  while(child)
  {
    ++childCount;
    nsSize pref(0,0);
    nsSize min(0,0);
    nsSize max(NS_INTRINSICSIZE,NS_INTRINSICSIZE);
    nscoord ascent = 0;

    PRBool collapsed = PR_FALSE;    
    child->IsCollapsed(aState, collapsed);

    if (!collapsed) {
    // only one flexible child? Cool we will just make its preferred size
    // 0 then and not even have to ask for it.
    //if (flexes != 1)  {

      child->GetPrefSize(aState, pref);
      child->GetMinSize(aState, min);
      child->GetMaxSize(aState, max);
      child->GetAscent(aState, ascent);
      nsMargin margin;
      child->GetMargin(margin);
      ascent += margin.top;
    //}

      nsBox::BoundsCheck(min, pref, max);

      AddMargin(child, pref);
      AddMargin(child, min);
      AddMargin(child, max);
    }

    if (!currentBox) {
      // create one.
      currentBox = new (aState) nsBoxSize();
      if (!aBoxSizes) {
        aBoxSizes = currentBox;
        last = aBoxSizes;
      } else {
        last->next = currentBox;
        last = currentBox;
      }

      nscoord minWidth;
      nscoord maxWidth;
      nscoord prefWidth;

      // get sizes from child
      if (isHorizontal) {
          minWidth  = min.width;
          maxWidth  = max.width;
          prefWidth = pref.width;
      } else {
          minWidth = min.height;
          maxWidth = max.height;
          prefWidth = pref.height;
      }

      nscoord flex = 0;
      child->GetFlex(aState, flex);

      // set them if you collapsed you are not flexible.
      if (collapsed) {
        currentBox->flex = 0;
      }
      else {
        if (flex > maxFlex) {
          maxFlex = flex;
        }
        currentBox->flex = flex;
      }

      // we we specified all our children are equal size;
      if (frameState & NS_STATE_EQUAL_SIZE) {

        if (prefWidth > biggestPrefWidth) 
          biggestPrefWidth = prefWidth;

        if (minWidth > biggestMinWidth) 
          biggestMinWidth = minWidth;

        if (maxWidth < smallestMaxWidth) 
          smallestMaxWidth = maxWidth;
      } else { // not we can set our children right now.
        currentBox->pref    = prefWidth;
        currentBox->min     = minWidth;
        currentBox->max     = maxWidth;
      }

      NS_ASSERTION(minWidth <= prefWidth && prefWidth <= maxWidth,"Bad min, pref, max widths!");

    }

    if (!isHorizontal) {
      if (min.width > aMinSize)
        aMinSize = min.width;

      if (max.width < aMaxSize)
        aMaxSize = max.width;

    } else {
      if (min.height > aMinSize)
        aMinSize = min.height;

      if (max.height < aMaxSize)
        aMaxSize = max.height;
    }

    currentBox->ascent  = ascent;
    currentBox->collapsed = collapsed;
    aFlexes += currentBox->flex;

    child->GetNextBox(&child);

    last = currentBox;
    currentBox = currentBox->next;

  }

  if (childCount > 0) {
    nscoord maxAllowedFlex = nscoord_MAX / childCount;
  
    if (NS_UNLIKELY(maxFlex > maxAllowedFlex)) {
      // clamp all the flexes
      currentBox = aBoxSizes;
      while (currentBox) {
        currentBox->flex = PR_MIN(currentBox->flex, maxAllowedFlex);
        currentBox = currentBox->next;      
      }
    }
  }
#ifdef DEBUG
  else {
    NS_ASSERTION(maxFlex == 0, "How did that happen?");
  }
#endif

  // we we specified all our children are equal size;
  if (frameState & NS_STATE_EQUAL_SIZE) {
    currentBox = aBoxSizes;

    while(currentBox)
    {
      if (!currentBox->collapsed) {
        currentBox->pref = biggestPrefWidth;
        currentBox->min = biggestMinWidth;
        currentBox->max = smallestMaxWidth;
      } else {
        currentBox->pref = 0;
        currentBox->min = 0;
        currentBox->max = 0;
      }
      currentBox = currentBox->next;
    }
  }

}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsSprocketLayout::SetLargestSize ( nsSize aSize1,
const nsSize aSize2,
PRBool  aIsHorizontal 
) [static, inherited]

Definition at line 1624 of file nsSprocketLayout.cpp.

{
  if (aIsHorizontal)
  {
    if (aSize1.height < aSize2.height)
       aSize1.height = aSize2.height;
  } else {
    if (aSize1.width < aSize2.width)
       aSize1.width = aSize2.width;
  }
}

Here is the caller graph for this function:

void nsSprocketLayout::SetSmallestSize ( nsSize aSize1,
const nsSize aSize2,
PRBool  aIsHorizontal 
) [static, inherited]

Definition at line 1637 of file nsSprocketLayout.cpp.

{
  if (aIsHorizontal)
  {
    if (aSize1.height > aSize2.height)
       aSize1.height = aSize2.height;
  } else {
    if (aSize1.width > aSize2.width)
       aSize1.width = aSize2.width;

  }
}

Here is the caller graph for this function:

void nsSprocketLayout::Shutdown ( ) [static, inherited]

Definition at line 83 of file nsSprocketLayout.cpp.


Friends And Related Function Documentation

nsresult NS_NewGridRowGroupLayout ( nsIPresShell aPresShell,
nsIBoxLayout **  aNewLayout 
) [friend, inherited]

Definition at line 58 of file nsGridRowGroupLayout.cpp.

{
  *aNewLayout = new nsGridRowGroupLayout(aPresShell);
  NS_IF_ADDREF(*aNewLayout);

  return NS_OK;
  
} 
nsresult NS_NewSprocketLayout ( nsIPresShell aPresShell,
nsCOMPtr< nsIBoxLayout > &  aNewLayout 
) [friend, inherited]

Definition at line 71 of file nsSprocketLayout.cpp.

{
  if (!nsSprocketLayout::gInstance) {
    nsSprocketLayout::gInstance = new nsSprocketLayout();
    NS_IF_ADDREF(nsSprocketLayout::gInstance);
  }
  // we have not instance variables so just return our static one.
  aNewLayout = nsSprocketLayout::gInstance;
  return NS_OK;
} 

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