nsSize
nsGridRowGroupLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
{
 nsSize maxSize = nsGridRowLayout::GetMaxSize(aBox, aState); 

  PRInt32 index = 0;
  nsGrid* grid = GetGrid(aBox, &index);

  if (grid) 
  {
    // make sure we add in extra columns sizes as well
    bool isHorizontal = IsHorizontal(aBox);
    PRInt32 extraColumns = grid->GetExtraColumnCount(isHorizontal);
    PRInt32 start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
    for (PRInt32 i=0; i < extraColumns; i++)
    {
      nscoord max =
        grid->GetMaxRowHeight(aState, i+start, !isHorizontal); // GetMaxColumnWidth

      AddWidth(maxSize, max, isHorizontal);
    }
  }

  return maxSize;
}
nsSize
nsGridRowGroupLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
{ 
  nsSize vpref = nsGridRowLayout::GetPrefSize(aBox, aState); 


 /* It is possible that we could have some extra columns. This is when less columns in XUL were 
  * defined that needed. And example might be a grid with 3 defined columns but a row with 4 cells in 
  * it. We would need an extra column to make the grid work. But because that extra column does not 
  * have a box associated with it we must add its size in manually. Remember we could have extra rows
  * as well.
  */

  PRInt32 index = 0;
  nsGrid* grid = GetGrid(aBox, &index);

  if (grid) 
  {
    // make sure we add in extra columns sizes as well
    bool isHorizontal = IsHorizontal(aBox);
    PRInt32 extraColumns = grid->GetExtraColumnCount(isHorizontal);
    PRInt32 start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
    for (PRInt32 i=0; i < extraColumns; i++)
    {
      nscoord pref =
        grid->GetPrefRowHeight(aState, i+start, !isHorizontal); // GetPrefColumnWidth

      AddWidth(vpref, pref, isHorizontal);
    }
  }

  return vpref;
}
nsSize
nsGridLayout2::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
{
  nsSize maxSize = nsStackLayout::GetMaxSize(aBox, aState); 

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

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

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

  return maxSize;
}
nsSize
nsGridLayout2::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
{
  nsSize pref = nsStackLayout::GetPrefSize(aBox, aState); 

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

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

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

  return pref;
}
示例#5
0
nsSize
nsGridLayout2::GetXULMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
{
  nsSize minSize = nsStackLayout::GetXULMinSize(aBox, aState); 

  // if there are no <rows> tags that will sum up our columns,
  // sum up our columns here.
  nsSize total(0,0);
  nsIFrame* rowsBox = mGrid.GetRowsBox();
  nsIFrame* columnsBox = mGrid.GetColumnsBox();
  if (!rowsBox || !columnsBox) {
    if (!rowsBox) {
      // max height is the sum of our rows
      int32_t rows = mGrid.GetRowCount();
      for (int32_t i=0; i < rows; i++)
      {
        nscoord height = mGrid.GetMinRowHeight(aState, i, true); 
        AddWidth(total, height, false); // AddHeight
      }
    }

    if (!columnsBox) {
      // max height is the sum of our rows
      int32_t columns = mGrid.GetColumnCount();
      for (int32_t i=0; i < columns; i++)
      {
        nscoord width = mGrid.GetMinRowHeight(aState, i, false); 
        AddWidth(total, width, true); // AddWidth
      }
    }

    AddMargin(aBox, total);
    AddOffset(aBox, total);
    AddLargestSize(minSize, total);
  }
  
  return minSize;
}
nsSize
nsGridRowGroupLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
{
  nsSize minSize = nsGridRowLayout::GetMinSize(aBox, aState); 

  int32_t index = 0;
  nsGrid* grid = GetGrid(aBox, &index);

  if (grid) 
  {
    // make sure we add in extra columns sizes as well
    bool isHorizontal = IsHorizontal(aBox);
    int32_t extraColumns = grid->GetExtraColumnCount(isHorizontal);
    int32_t start = grid->GetColumnCount(isHorizontal) - grid->GetExtraColumnCount(isHorizontal);
    for (int32_t i=0; i < extraColumns; i++)
    {
      nscoord min = 
        grid->GetMinRowHeight(aState, i+start, !isHorizontal); // GetMinColumnWidth
      AddWidth(minSize, min, isHorizontal);
    }
  }

  return minSize;
}