bug fixes #107707, 108771, 108773

-r jag -sr hyatt -a asa
This commit is contained in:
evaughan%netscape.com 2001-11-08 20:46:02 +00:00
parent 3bc7b7e2dc
commit 92fedde2ff
5 changed files with 166 additions and 24 deletions

View File

@ -883,19 +883,6 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, n
aBottom = row->mBottom;
}
PRBool
nsGrid::CheckCollapsed(nsBoxLayoutState& aState, nsGridRow* aRow, nscoord& aSize, nscoord& aNewSize)
{
if (aRow->IsCollapsed(aState))
{
aSize = 0;
aNewSize = 0;
return PR_TRUE;
}
return PR_FALSE;
}
/**
* These methods return the preferred, min, max coord for a given row index if
* aIsHorizontal is PR_TRUE. If you pass PR_FALSE you will get the inverse.
@ -908,8 +895,11 @@ nsGrid::GetPrefRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aSiz
nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
if (CheckCollapsed(aState, row, row->mPref, aSize))
return NS_OK;
if (row->IsCollapsed(aState))
{
aSize = 0;
return NS_OK;
}
if (row->IsPrefSet())
{
@ -1005,8 +995,11 @@ nsGrid::GetMinRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aSize
nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
if (CheckCollapsed(aState, row, row->mMin, aSize))
return NS_OK;
if (row->IsCollapsed(aState))
{
aSize = 0;
return NS_OK;
}
if (row->IsMinSet())
{
@ -1098,8 +1091,11 @@ nsGrid::GetMaxRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aSize
nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
if (CheckCollapsed(aState, row, row->mMax, aSize))
return NS_OK;
if (row->IsCollapsed(aState))
{
aSize = 0;
return NS_OK;
}
if (row->IsMaxSet())
{

View File

@ -93,6 +93,8 @@ public:
// accessors
void SetBox(nsIBox* aBox) { mBox = aBox; }
nsIBox* GetBox() { return mBox; }
nsIBox* GetRowBox() { return mRowBox; }
nsIBox* GetColumnBox() { return mColumnBox; }
nsGridRow* GetColumns();
nsGridRow* GetRows();
PRInt32 GetRowCount(PRInt32 aIsHorizontal = PR_TRUE);
@ -106,10 +108,10 @@ public:
nsGridRow*& aFirstRow,
nsGridRow*& aLastRow,
PRBool aIsHorizontal);
private:
void GetPartFromBox(nsIBox* aBox, nsIGridPart** aPart);
void GetBoxTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal = PR_TRUE);
PRBool CheckCollapsed(nsBoxLayoutState& aState, nsGridRow* aRow, nscoord& aSize, nscoord& aNewSize);
void FreeMap();
void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);

View File

@ -88,22 +88,154 @@ nsGridLayout2::GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart*
return NS_ERROR_FAILURE;
}
void
nsGridLayout2::AddWidth(nsSize& aSize, nscoord aSize2, PRBool aIsHorizontal)
{
nscoord& size = GET_WIDTH(aSize, aIsHorizontal);
if (size != NS_INTRINSICSIZE) {
if (aSize2 == NS_INTRINSICSIZE)
size = NS_INTRINSICSIZE;
else
size += aSize2;
}
}
NS_IMETHODIMP
nsGridLayout2::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
return nsStackLayout::GetMinSize(aBox, aState, aSize);
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++)
{
nsGridRow* row = mGrid.GetRowAt(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++)
{
nsGridRow* row = mGrid.GetColumnAt(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;
}
NS_IMETHODIMP
nsGridLayout2::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
return nsStackLayout::GetPrefSize(aBox, aState, aSize);
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++)
{
nsGridRow* row = mGrid.GetRowAt(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++)
{
nsGridRow* row = mGrid.GetColumnAt(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;
}
NS_IMETHODIMP
nsGridLayout2::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
return nsStackLayout::GetMaxSize(aBox, aState, aSize);
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++)
{
nsGridRow* row = mGrid.GetRowAt(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++)
{
nsGridRow* row = mGrid.GetColumnAt(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;
}
NS_IMETHODIMP

View File

@ -81,10 +81,14 @@ public:
NS_IMETHOD GetRowCount(PRInt32& aRowCount);
protected:
nsGridLayout2(nsIPresShell* aShell);
nsGridLayout2(nsIPresShell* aShell);
nsGrid mGrid;
private:
void AddWidth(nsSize& aSize, nscoord aSize2, PRBool aIsHorizontal);
}; // class nsGridLayout2

View File

@ -244,6 +244,14 @@ nsGridRowLeafLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, ns
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)
{