Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
nsGridLayout2 Class Reference

#include <nsGridLayout2.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
Layout (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState)
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 **aParentGridPart)
NS_IMETHOD GetMinSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
NS_IMETHOD GetPrefSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
NS_IMETHOD GetMaxSize (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nsSize &aSize)
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 GetTotalMargin (nsIBox *aBox, nsMargin &aMargin, PRBool aIsHorizontal)
NS_IMETHOD GetRowCount (PRInt32 &aRowCount)
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 GetAscent (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nscoord &aAscent)
NS_IMETHOD GetFlex (nsIBox *aBox, nsBoxLayoutState &aBoxLayoutState, nscoord &aFlex)
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 AddOffset (nsBoxLayoutState &aState, nsIBox *aChild, nsSize &aSize)
static void AddLargestSize (nsSize &aSize, const nsSize &aToAdd)
static void AddSmallestSize (nsSize &aSize, const nsSize &aToAdd)

Protected Member Functions

 nsGridLayout2 (nsIPresShell *aShell)

Protected Attributes

nsGrid mGrid

Private Member Functions

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

Friends

nsresult NS_NewGridLayout2 (nsIPresShell *aPresShell, nsIBoxLayout **aNewLayout)
nsresult NS_NewStackLayout (nsIPresShell *aPresShell, nsCOMPtr< nsIBoxLayout > &aNewLayout)
 Eric D Vaughan A frame that can have multiple children.

Detailed Description

Definition at line 55 of file nsGridLayout2.h.


Constructor & Destructor Documentation

nsGridLayout2::nsGridLayout2 ( nsIPresShell aShell) [protected]

Definition at line 61 of file nsGridLayout2.cpp.

                                                    :nsStackLayout()
{
}

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 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 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:

PRBool nsStackLayout::AddOffset ( nsBoxLayoutState aState,
nsIBox *  aChild,
nsSize aSize 
) [static, inherited]

Definition at line 192 of file nsStackLayout.cpp.

{
  nsSize offset(0,0);
  
  // get the left and top offsets
  
  // As an optimization, we cache the fact that we are not positioned to avoid
  // wasting time fetching attributes and checking style data.
  if (aChild->GetStateBits() & NS_STATE_STACK_NOT_POSITIONED)
    return PR_FALSE;
  
  PRBool offsetSpecified = PR_FALSE;
  const nsStylePosition* pos = aChild->GetStylePosition();
  if (eStyleUnit_Coord == pos->mOffset.GetLeftUnit()) {
     nsStyleCoord left = 0;
     pos->mOffset.GetLeft(left);
     offset.width = left.GetCoordValue();
     offsetSpecified = PR_TRUE;
  }

  if (eStyleUnit_Coord == pos->mOffset.GetTopUnit()) {
     nsStyleCoord top = 0;
     pos->mOffset.GetTop(top);
     offset.height = top.GetCoordValue();
     offsetSpecified = PR_TRUE;
  }

  nsIContent* content = aChild->GetContent();

  if (content) {
    nsPresContext* presContext = aState.PresContext();
    nsAutoString value;
    PRInt32 error;

    if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::left, value)) {
      value.Trim("%");
      offset.width = NSIntPixelsToTwips(value.ToInteger(&error),
                                        presContext->ScaledPixelsToTwips());
      offsetSpecified = PR_TRUE;
    }

    if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::top, value)) {
      value.Trim("%");
      offset.height = NSIntPixelsToTwips(value.ToInteger(&error),
                                         presContext->ScaledPixelsToTwips());
      offsetSpecified = PR_TRUE;
    }
  }

  aSize += offset;

  if (!offsetSpecified) {
    // If no offset was specified at all, then we cache this fact to avoid requerying
    // CSS or the content model.
    aChild->AddStateBits(NS_STATE_STACK_NOT_POSITIONED);
  }
  
  return offsetSpecified;
}

Here is the call graph for this function:

Here is the caller 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 nsGridLayout2::AddWidth ( nsSize aSize,
nscoord  aSize2,
PRBool  aIsHorizontal 
) [private]

Definition at line 92 of file nsGridLayout2.cpp.

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

  if (size != NS_INTRINSICSIZE) {
    if (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 nsGridLayout2::BuildRows ( nsIBox *  aBox,
nsGridRow aRows,
PRInt32 aCount 
) [virtual]

Implements nsIGridPart.

Definition at line 250 of file nsGridLayout2.cpp.

{
  NS_ERROR("Should not be called");
  return NS_ERROR_FAILURE;
}

Implements nsIGridPart.

Definition at line 264 of file nsGridLayout2.cpp.

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

Implements nsIGridPart.

Definition at line 257 of file nsGridLayout2.cpp.

{
  (*aRowGroup) = nsnull;
  return NS_OK;
}
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 nsGridLayout2::ChildrenAppended ( nsIBox *  aBox,
nsBoxLayoutState aState,
nsIBox *  aChildList 
) [virtual]

Reimplemented from nsBoxLayout.

Definition at line 297 of file nsGridLayout2.cpp.

{
  mGrid.NeedsRebuild(aState);
  return NS_OK;
}

Here is the call graph for this function:

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

Reimplemented from nsBoxLayout.

Definition at line 289 of file nsGridLayout2.cpp.

{
  mGrid.NeedsRebuild(aState);
  return NS_OK;
}

Here is the call graph for this function:

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

Reimplemented from nsBoxLayout.

Definition at line 306 of file nsGridLayout2.cpp.

{
  mGrid.NeedsRebuild(aState);
  return NS_OK;
}

Here is the call graph for this function:

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

Reimplemented from nsBoxLayout.

Definition at line 315 of file nsGridLayout2.cpp.

{
  mGrid.NeedsRebuild(aState);
  return NS_OK;
}

Here is the call graph for this function:

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

Implements nsIGridPart.

Definition at line 236 of file nsGridLayout2.cpp.

{
  NS_ERROR("Should not be called");
  return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsGridLayout2::DirtyRows ( nsIBox *  aBox,
nsBoxLayoutState aState 
) [virtual]

Implements nsIGridPart.

Definition at line 243 of file nsGridLayout2.cpp.

{
  NS_ERROR("Should not be called");
  return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsStackLayout::GetAscent ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nscoord aAscent 
) [virtual, inherited]

Reimplemented from nsBoxLayout.

Definition at line 171 of file nsStackLayout.cpp.

{
  aAscent = 0;
  nsIBox* child = nsnull;
  aBox->GetChildBox(&child);
   
  while (child) {  
    nscoord ascent = 0;
    child->GetAscent(aState, ascent);
    nsMargin margin;
    child->GetMargin(margin);
    ascent += margin.top + margin.bottom;
    if (ascent > aAscent)
      aAscent = ascent;
    child->GetNextBox(&child);
  }

  return NS_OK;
}
NS_IMETHODIMP nsBoxLayout::GetFlex ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nscoord aFlex 
) [virtual, inherited]

Implements nsIBoxLayout.

Reimplemented in nsSprocketLayout.

Definition at line 100 of file nsBoxLayout.cpp.

{
  return aBox->GetFlex(aState, aFlex);
}
NS_IMETHODIMP nsGridLayout2::GetGrid ( nsIBox *  aBox,
nsGrid **  aList,
PRInt32 aIndex,
nsGridRowLayout aRequestor = nsnull 
) [virtual]

Implements nsIGridPart.

Definition at line 77 of file nsGridLayout2.cpp.

{
  mGrid.SetBox(aBox);
  *aGrid = &mGrid;
  return NS_OK;
}

Here is the call graph for this function:

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

Reimplemented from nsStackLayout.

Definition at line 191 of file nsGridLayout2.cpp.

{
  nsresult rv = nsStackLayout::GetMaxSize(aBox, aState, aSize); 
   if (NS_FAILED(rv))
    return rv;

  // if there are no <rows> tags that will sum up our columns,
  // sum up our columns here.
  nsSize total(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
  nsIBox* rowBox = mGrid.GetRowBox();
  nsIBox* columnBox = mGrid.GetColumnBox();
  if (!rowBox || !columnBox) {
    if (!rowBox) {
      total.height = 0;
      // max height is the sum of our rows
      PRInt32 rows = mGrid.GetRowCount();
      for (PRInt32 i=0; i < rows; i++)
      {
        nscoord size = 0;
        mGrid.GetMaxRowHeight(aState, i, size, PR_TRUE); 
        AddWidth(total, size, PR_FALSE); // AddHeight
      }
    }

    if (!columnBox) {
      total.width = 0;
      // max height is the sum of our rows
      PRInt32 columns = mGrid.GetColumnCount();
      for (PRInt32 i=0; i < columns; i++)
      {
        nscoord size = 0;
        mGrid.GetMaxRowHeight(aState, i, size, PR_FALSE); // GetPrefRowWidth
        AddWidth(total, size, PR_TRUE); // AddWidth
      }
    }

    AddMargin(aBox, total);
    AddOffset(aState, aBox, total);
    AddSmallestSize(aSize, total);
  }

  return rv;
}

Here is the call graph for this function:

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

Reimplemented from nsStackLayout.

Definition at line 105 of file nsGridLayout2.cpp.

{
  nsresult rv = nsStackLayout::GetMinSize(aBox, aState, aSize); 
  if (NS_FAILED(rv))
    return rv;

  // if there are no <rows> tags that will sum up our columns,
  // sum up our columns here.
  nsSize total(0,0);
  nsIBox* rowBox = mGrid.GetRowBox();
  nsIBox* columnBox = mGrid.GetColumnBox();
  if (!rowBox || !columnBox) {
    if (!rowBox) {
      // max height is the sum of our rows
      PRInt32 rows = mGrid.GetRowCount();
      for (PRInt32 i=0; i < rows; i++)
      {
        nscoord size = 0;
        mGrid.GetMinRowHeight(aState, i, size, PR_TRUE); 
        AddWidth(total, size, PR_FALSE); // AddHeight
      }
    }

    if (!columnBox) {
      // max height is the sum of our rows
      PRInt32 columns = mGrid.GetColumnCount();
      for (PRInt32 i=0; i < columns; i++)
      {
        nscoord size = 0;
        mGrid.GetMinRowHeight(aState, i, size, PR_FALSE); // GetPrefRowWidth
        AddWidth(total, size, PR_TRUE); // AddWidth
      }
    }

    AddMargin(aBox, total);
    AddOffset(aState, aBox, total);
    AddLargestSize(aSize, total);
  }
  
  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridLayout2::GetParentGridPart ( nsIBox *  aBox,
nsIBox **  aParentBox,
nsIGridPart **  aParentGridPart 
) [virtual]

Implements nsIGridPart.

Definition at line 85 of file nsGridLayout2.cpp.

{
  NS_ERROR("Should not be called");
  return NS_ERROR_FAILURE;
}
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 nsGridLayout2::GetPrefSize ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
nsSize aSize 
) [virtual]

Reimplemented from nsStackLayout.

Definition at line 148 of file nsGridLayout2.cpp.

{
  nsresult rv = nsStackLayout::GetPrefSize(aBox, aState, aSize); 
  if (NS_FAILED(rv))
    return rv;

  // if there are no <rows> tags that will sum up our columns,
  // sum up our columns here.
  nsSize total(0,0);
  nsIBox* rowBox = mGrid.GetRowBox();
  nsIBox* columnBox = mGrid.GetColumnBox();
  if (!rowBox || !columnBox) {
    if (!rowBox) {
      // max height is the sum of our rows
      PRInt32 rows = mGrid.GetRowCount();
      for (PRInt32 i=0; i < rows; i++)
      {
        nscoord size = 0;
        mGrid.GetPrefRowHeight(aState, i, size, PR_TRUE); 
        AddWidth(total, size, PR_FALSE); // AddHeight
      }
    }

    if (!columnBox) {
      // max height is the sum of our rows
      PRInt32 columns = mGrid.GetColumnCount();
      for (PRInt32 i=0; i < columns; i++)
      {
        nscoord size = 0;
        mGrid.GetPrefRowHeight(aState, i, size, PR_FALSE); // GetPrefRowWidth
        AddWidth(total, size, PR_TRUE); // AddWidth
      }
    }

    AddMargin(aBox, total);
    AddOffset(aState, aBox, total);
    AddLargestSize(aSize, total);
  }

  return rv;
}

Here is the call graph for this function:

NS_IMETHODIMP nsGridLayout2::GetRowCount ( PRInt32 aRowCount) [virtual]

Implements nsIGridPart.

Definition at line 282 of file nsGridLayout2.cpp.

{
  NS_ERROR("Should not be called");
  return NS_OK;
}
NS_IMETHODIMP nsGridLayout2::GetTotalMargin ( nsIBox *  aBox,
nsMargin aMargin,
PRBool  aIsHorizontal 
) [virtual]

Implements nsIGridPart.

Definition at line 271 of file nsGridLayout2.cpp.

{
  aMargin.left = 0;
  aMargin.right = 0;
  aMargin.top = 0;
  aMargin.bottom = 0;

  return NS_OK;
}
NS_IMETHODIMP nsBoxLayout::IsCollapsed ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState,
PRBool aCollapsed 
) [virtual, inherited]

Implements nsIBoxLayout.

Reimplemented in nsSprocketLayout.

Definition at line 107 of file nsBoxLayout.cpp.

{
  return aBox->IsCollapsed(aState, aCollapsed);
}
NS_IMETHODIMP nsGridLayout2::Layout ( nsIBox *  aBox,
nsBoxLayoutState aBoxLayoutState 
) [virtual]

Reimplemented from nsStackLayout.

Definition at line 66 of file nsGridLayout2.cpp.

{
  mGrid.SetBox(aBox);
  nsresult rv = nsStackLayout::Layout(aBox, aBoxLayoutState);
#ifdef DEBUG_grid
  mGrid.PrintCellMap();
#endif
  return rv;
}

Here is the call graph for this function:

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

Definition at line 71 of file nsStackLayout.cpp.


Friends And Related Function Documentation

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

Definition at line 52 of file nsGridLayout2.cpp.

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

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

Eric D Vaughan A frame that can have multiple children.

Only one child may be displayed at one time. So the can be flipped though like a deck of cards.

Definition at line 59 of file nsStackLayout.cpp.

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

Member Data Documentation

Definition at line 89 of file nsGridLayout2.h.


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