Back to index

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

Author: Eric D Vaughan. More...

#include <nsGridRowLeafLayout.h>

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

List of all members.

Public Member Functions

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 CastToGridRowLeaf (nsGridRowLeafLayout **aGridRowLeaf)
NS_IMETHOD ChildBecameDirty (nsIBox *aBox, nsBoxLayoutState &aState, nsIBox *aChild)
NS_IMETHOD BecameDirty (nsIBox *aBox, nsBoxLayoutState &aState)
NS_IMETHOD ChildAddedOrRemoved (nsIBox *aBox, nsBoxLayoutState &aState)
 If a child is added or removed or changes size.
NS_IMETHOD Layout (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState)
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)
NS_IMETHOD GetRowCount (PRInt32 &aRowCount)
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
CastToRowGroupLayout (nsGridRowGroupLayout **aRowGroup)
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 GetTotalMargin (nsIBox *aBox, nsMargin &aMargin, PRBool aIsHorizontal)
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)
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

virtual void PopulateBoxSizes (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsBoxSize *&aBoxSizes, nsComputedBoxSize *&aComputedBoxSizes, nscoord &aMinSize, nscoord &aMaxSize, PRInt32 &aFlexes)
virtual void ComputeChildSizes (nsIBox *aBox, nsBoxLayoutState &aState, nscoord &aGivenSize, nsBoxSize *aBoxSizes, nsComputedBoxSize *&aComputedBoxSizes)
 nsGridRowLeafLayout (nsIPresShell *aShell)
virtual ~nsGridRowLeafLayout ()
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 InvalidateComputedSizes (nsComputedBoxSize *aComputedBoxSizes)
virtual PRBool GetDefaultFlex (PRInt32 &aFlex)
virtual void GetFrameState (nsIBox *aBox, nsFrameState &aState)

Friends

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

Detailed Description

Author: Eric D Vaughan.

Definition at line 51 of file nsGridRowLeafLayout.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsGridRowLeafLayout.cpp.

                                                                :nsGridRowLayout(aPresShell)
{
}

Definition at line 68 of file nsGridRowLeafLayout.cpp.

{
}

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:

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

Reimplemented from nsBoxLayout.

Definition at line 153 of file nsGridRowLeafLayout.cpp.

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

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

  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridRowLeafLayout::BuildRows ( nsIBox *  aBox,
nsGridRow aRows,
PRInt32 aCount 
) [virtual]

Implements nsIGridPart.

Definition at line 408 of file nsGridRowLeafLayout.cpp.

{ 
  if (aBox) {
      aRows[0].Init(aBox, PR_FALSE);
      *aCount = 1;
      return NS_OK;
  }

  *aCount = 0;

  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;
}

Definition at line 73 of file nsGridRowLeafLayout.cpp.

{
  *aGridRowLeaf = this;
  return NS_OK;
}

Implements nsIGridPart.

Reimplemented in nsGridRowGroupLayout.

Definition at line 188 of file nsGridRowLayout.cpp.

{
  (*aRowGroup) = nsnull;
  return NS_OK;
}
NS_IMETHODIMP nsGridRowLeafLayout::ChildAddedOrRemoved ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual]

If a child is added or removed or changes size.

Implements nsGridRowLayout.

Definition at line 169 of file nsGridRowLeafLayout.cpp.

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

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

  return NS_OK;
}

Here is the call graph for this function:

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

Reimplemented from nsBoxLayout.

Definition at line 136 of file nsGridRowLeafLayout.cpp.

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

  if (grid) {
    PRInt32 columnIndex = -1;
    aBox->GetIndexOf(aChild, &columnIndex);
    grid->RowChildIsDirty(aState, index, columnIndex, isHorizontal);
  }

  return NS_OK;
}

Here is the call graph for this function:

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 nsGridRowLeafLayout::ComputeChildSizes ( nsIBox *  aBox,
nsBoxLayoutState aState,
nscoord aGivenSize,
nsBoxSize aBoxSizes,
nsComputedBoxSize *&  aComputedBoxSizes 
) [protected, virtual]

Reimplemented from nsSprocketLayout.

Definition at line 305 of file nsGridRowLeafLayout.cpp.

{ 
  // see if we are in a scrollable frame. If we are then there could be scrollbars present
  // if so we need to subtract them out to make sure our columns line up.
  if (aBox) {

     // go up the parent chain looking for scrollframes
     PRBool isHorizontal = PR_FALSE;
     aBox->GetOrientation(isHorizontal);

     nsIBox* scrollbox = nsnull;
     aBox->GetParentBox(&aBox);
     scrollbox = nsGrid::GetScrollBox(aBox);
       
       nsCOMPtr<nsIScrollableFrame> scrollable = do_QueryInterface(scrollbox);
       if (scrollable) {
          nsMargin scrollbarSizes = scrollable->GetActualScrollbarSizes();

          nsRect ourRect(scrollbox->GetRect());
          nsMargin padding(0,0,0,0);
          scrollbox->GetBorderAndPadding(padding);
          ourRect.Deflate(padding);
          scrollbox->GetInset(padding);
          ourRect.Deflate(padding);

          nscoord diff;
          if (isHorizontal) {
            diff = scrollbarSizes.left + scrollbarSizes.right;
          } else {
            diff = scrollbarSizes.top + scrollbarSizes.bottom;
          }

          if (diff > 0) {
            aGivenSize += diff;

            nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);

            aGivenSize -= diff;

            nsComputedBoxSize* s    = aComputedBoxSizes;
            nsComputedBoxSize* last = aComputedBoxSizes;
            while(s)
            {
              last = s;
              s = s->next;
            }
  
            if (last) 
                last->size -= diff;                         
          }
       }
  }
      
  nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);

}

Here is the call 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 nsGridRowLeafLayout::CountRowsColumns ( nsIBox *  aBox,
PRInt32 aRowCount,
PRInt32 aComputedColumnCount 
) [virtual]

Implements nsIGridPart.

Definition at line 384 of file nsGridRowLeafLayout.cpp.

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

    // count the children
    PRInt32 columnCount = 0;
    while(child) {
      child->GetNextBox(&child);
      columnCount++;
    }

    // if our count is greater than the current column count
    if (columnCount > aComputedColumnCount) 
      aComputedColumnCount = columnCount;

    aRowCount++;
  }

  return NS_OK;
}
NS_IMETHODIMP nsGridRowLeafLayout::DirtyRows ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual]

Implements nsIGridPart.

Definition at line 373 of file nsGridRowLeafLayout.cpp.

{
  if (aBox) {
    // mark us dirty
    aBox->MarkDirty(aState);
  }

  return NS_OK;
}
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 nsGridRowLeafLayout::GetMaxSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsSprocketLayout.

Definition at line 118 of file nsGridRowLeafLayout.cpp.

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

  if (!grid)
    return nsGridRowLayout::GetMaxSize(aBox, aState, aSize); 
  else {
    nsresult rv = grid->GetMaxRowSize(aState, index, aSize, isHorizontal);
    AddBorderAndPadding(aBox, aSize);
    AddInset(aBox, aSize);
    return rv;
  }
}

Here is the call graph for this function:

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

Reimplemented from nsSprocketLayout.

Definition at line 100 of file nsGridRowLeafLayout.cpp.

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

  if (!grid)
    return nsGridRowLayout::GetMinSize(aBox, aState, aSize); 
  else {
    nsresult rv = grid->GetMinRowSize(aState, index, aSize, isHorizontal);
    AddBorderAndPadding(aBox, aSize);
    AddInset(aBox, aSize);
    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 nsGridRowLeafLayout::GetPrefSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsSprocketLayout.

Definition at line 80 of file nsGridRowLeafLayout.cpp.

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

  // If we are not in a grid. Then we just work like a box. But if we are in a grid
  // ask the grid for our size.
  if (!grid)
    return nsGridRowLayout::GetPrefSize(aBox, aState, aSize); 
  else {
    nsresult rv = grid->GetPrefRowSize(aState, index, aSize, isHorizontal);
    //AddBorderAndPadding(aBox, aSize);
    //AddInset(aBox, aSize);
    return rv;
  }
}

Here is the call graph for this function:

Implements nsIGridPart.

Definition at line 422 of file nsGridRowLeafLayout.cpp.

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

Implements nsIGridPart.

Reimplemented in nsGridRowGroupLayout.

Definition at line 202 of file nsGridRowLayout.cpp.

{
  // get our parents margin
  nsMargin margin(0,0,0,0);
  nsCOMPtr<nsIGridPart> part;
  nsIBox* parent = nsnull;
  GetParentGridPart(aBox, &parent, getter_AddRefs(part));

  if (part && parent) {
    // if we are the first or last child walk upward and add margins.

    nsIBox* next = nsnull;
    nsIBox* child = nsnull;

    // make sure we check for a scrollbox
    aBox = nsGrid::GetScrollBox(aBox);

    // see if we have a next to see if we are last
    aBox->GetNextBox(&next);

    // get the parent first child to see if we are first
    parent->GetChildBox(&child);

    part->GetTotalMargin(parent,margin,aIsHorizontal);

    // if first or last
    if (child == aBox || next == nsnull) {

       // if its not the first child remove the top margin
       // we don't need it.
       if (child != aBox)
       {
          if (aIsHorizontal)
              margin.top = 0;
          else 
              margin.left = 0;
       }

       // if its not the last child remove the bottom margin
       // we don't need it.
       if (next != nsnull)
       {
          if (aIsHorizontal)
              margin.bottom = 0;
          else 
              margin.right = 0;
       }

    }
  }
    
  aMargin = margin;

  // add ours to it.
  aBox->GetMargin(margin);
  aMargin += margin;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller 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 nsGridRowLeafLayout::Layout ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState 
) [virtual]

Reimplemented from nsSprocketLayout.

Definition at line 367 of file nsGridRowLeafLayout.cpp.

{
  return nsGridRowLayout::Layout(aBox, aBoxLayoutState);
}
void nsGridRowLeafLayout::PopulateBoxSizes ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsBoxSize *&  aBoxSizes,
nsComputedBoxSize *&  aComputedBoxSizes,
nscoord aMinSize,
nscoord aMaxSize,
PRInt32 aFlexes 
) [protected, virtual]

Reimplemented from nsSprocketLayout.

Definition at line 183 of file nsGridRowLeafLayout.cpp.

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

  // Our base class SprocketLayout is giving us a chance to change the box sizes before layout
  // If we are a row lets change the sizes to match our columns. If we are a column then do the opposite
  // and make them match or rows.
  if (grid) {
   nsGridRow* column;
   PRInt32 count = grid->GetColumnCount(isHorizontal); 
   nsBoxSize* start = nsnull;
   nsBoxSize* last = nsnull;
   nsBoxSize* current = nsnull;
   nsIBox* child = nsnull;
   aBox->GetChildBox(&child);
   for (int i=0; i < count; i++)
   {
     column = grid->GetColumnAt(i,isHorizontal); 

     // make sure the value was computed before we use it.
     nscoord pref = 0;
     nscoord min  = 0;
     nscoord max  = 0;
     nscoord flex  = 0;
     nscoord left  = 0;
     nscoord right  = 0;

     current = new (aState) nsBoxSize();

     // !isHorizontal is passed in to invert the behavor of these methods.
     grid->GetPrefRowHeight(aState, i, pref, !isHorizontal); // GetPrefColumnWidth
     grid->GetMinRowHeight(aState, i, min, !isHorizontal);   // GetMinColumnWidth
     grid->GetMaxRowHeight(aState, i, max, !isHorizontal);   // GetMaxColumnWidth
     grid->GetRowFlex(aState, i, flex, !isHorizontal);       // GetColumnFlex
     grid->GetRowOffsets(aState, i, left, right, !isHorizontal); // GetColumnOffsets
     nsIBox* box = column->GetBox();
     nscoord collapsed = PR_FALSE;
     nscoord topMargin = column->mTopMargin;
     nscoord bottomMargin = column->mBottomMargin;

     if (box) 
       box->IsCollapsed(aState, collapsed);

     pref = pref - (left + right);
     if (pref < 0)
       pref = 0;

     // if this is the first or last column. Take into account that
     // our row could have a border that could affect our left or right
     // padding from our columns. If the row has padding subtract it.
     // would should always be able to garentee that our margin is smaller
     // or equal to our left or right
      PRInt32 firstIndex = 0;
      PRInt32 lastIndex = 0;
      nsGridRow* firstRow = nsnull;
      nsGridRow* lastRow = nsnull;
      grid->GetFirstAndLastRow(aState, firstIndex, lastIndex, firstRow, lastRow, !isHorizontal);

      if (i == firstIndex || i == lastIndex) {
        nsMargin offset(0,0,0,0);
        GetTotalMargin(aBox, offset, isHorizontal);

        nsMargin border(0,0,0,0);
        // can't call GetBorderPadding we will get into recursion
        aBox->GetBorder(border);
        offset += border;
        aBox->GetPadding(border);
        offset += border;

        // subtract from out left and right
        if (i == firstIndex) 
        {
          if (isHorizontal)
           left -= offset.left;
          else
           left -= offset.top;
        }

        if (i == lastIndex)
        {
          if (isHorizontal)
           right -= offset.right;
          else
           right -= offset.bottom;
        }
      }
    
     // initialize the box size here 
     nsBox::BoundsCheck(min, pref, max);
   

     current->pref = pref;
     current->min = min;
     current->max = max;
     current->flex = flex;
     current->bogus = column->mIsBogus;
     current->left = left + topMargin;
     current->right = right + bottomMargin;
     current->collapsed = collapsed;

     if (!start) {
        start = current;
        last = start;
     } else {
        last->next = current;
        last = current;
     }

     if (child)
       child->GetNextBox(&child);

   }
   aBoxSizes = start;
  }

  nsSprocketLayout::PopulateBoxSizes(aBox, aState, aBoxSizes, aComputedBoxSizes, aMinSize, aMaxSize, aFlexes);
}

Here is the call 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_NewGridRowLeafLayout ( nsIPresShell aPresShell,
nsIBoxLayout **  aNewLayout 
) [friend]

Definition at line 55 of file nsGridRowLeafLayout.cpp.

{
  *aNewLayout = new nsGridRowLeafLayout(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: