Bug 363879, deCOMtaminate nsGrid dir, part 2, p=Andreas Lange, r+sr=roc

This commit is contained in:
Olli.Pettay%helsinki.fi 2006-12-18 18:25:48 +00:00
Родитель 673a2835ad
Коммит 458ea9c2e0
12 изменённых файлов: 142 добавлений и 286 удалений

Просмотреть файл

@ -239,7 +239,7 @@ nsGrid::RebuildIfNeeded()
BuildRows(mColumnsBox, columnCount, &mColumns, PR_FALSE);
// build and populate the cell map
BuildCellMap(rowCount, columnCount, &mCellMap);
mCellMap = BuildCellMap(rowCount, columnCount);
mRowCount = rowCount;
mColumnCount = columnCount;
@ -305,8 +305,7 @@ nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns)
nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
if (monument)
{
nsGridRowGroupLayout* rowGroup = nsnull;
monument->CastToRowGroupLayout(&rowGroup);
nsGridRowGroupLayout* rowGroup = monument->CastToRowGroupLayout();
if (rowGroup) {
PRBool isHorizontal = !nsSprocketLayout::IsHorizontal(child);
if (isHorizontal)
@ -352,7 +351,7 @@ nsGrid::CountRowsColumns(nsIBox* aRowBox, PRInt32& aRowCount, PRInt32& aComputed
* Given the number of rows create nsGridRow objects for them and full them out.
*/
void
nsGrid::BuildRows(nsIBox* aBox, PRBool aRowCount, nsGridRow** aRows, PRBool aIsHorizontal)
nsGrid::BuildRows(nsIBox* aBox, PRInt32 aRowCount, nsGridRow** aRows, PRBool aIsHorizontal)
{
// if no rows then return null
if (aRowCount == 0) {
@ -400,8 +399,7 @@ nsGrid::BuildRows(nsIBox* aBox, PRBool aRowCount, nsGridRow** aRows, PRBool aIsH
if (layout) {
nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
if (monument) {
PRInt32 count;
monument->BuildRows(aBox, row, &count);
monument->BuildRows(aBox, row);
}
}
}
@ -413,19 +411,18 @@ nsGrid::BuildRows(nsIBox* aBox, PRBool aRowCount, nsGridRow** aRows, PRBool aIsH
/**
* Given the number of rows and columns. Build a cellmap
*/
void
nsGrid::BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells)
nsGridCell*
nsGrid::BuildCellMap(PRInt32 aRows, PRInt32 aColumns)
{
PRInt32 size = aRows*aColumns;
PRInt32 oldsize = mRowCount*mColumnCount;
if (size == 0) {
delete[] mCellMap;
(*aCells) = nsnull;
}
else {
if (size > oldsize) {
delete[] mCellMap;
(*aCells) = new nsGridCell[size];
return new nsGridCell[size];
} else {
// clear out cellmap
for (PRInt32 i=0; i < oldsize; i++)
@ -433,10 +430,10 @@ nsGrid::BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells)
mCellMap[i].SetBoxInRow(nsnull);
mCellMap[i].SetBoxInColumn(nsnull);
}
(*aCells) = mCellMap;
return mCellMap;
}
}
return nsnull;
}
/**
@ -450,7 +447,7 @@ nsGrid::PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount
return;
// look through the columns
nscoord j = 0;
PRInt32 j = 0;
for(PRInt32 i=0; i < aRowCount; i++)
{
@ -644,17 +641,19 @@ nsGrid::GetPartFromBox(nsIBox* aBox, nsIGridPart** aPart)
}
}
void
nsGrid::GetBoxTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal)
nsMargin
nsGrid::GetBoxTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)
{
nsMargin margin(0,0,0,0);
// walk the boxes parent chain getting the border/padding/margin of our parent rows
// first get the layour manager
nsCOMPtr<nsIGridPart> part;
nsCOMPtr<nsIGridPart> parent;
GetPartFromBox(aBox, getter_AddRefs(part));
if (part)
part->GetTotalMargin(aBox, aMargin, aIsHorizontal);
margin = part->GetTotalMargin(aBox, aIsHorizontal);
return margin;
}
/**
@ -767,8 +766,6 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, n
totalBorderPadding += inset;
totalBorderPadding += border;
totalBorderPadding += padding;
box->GetMargin(margin);
}
// if we are the first or last row
@ -777,9 +774,7 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, n
// fortunately they only affect the first
// and last row inside the <rows> tag
GetBoxTotalMargin(box, margin, aIsHorizontal);
totalMargin = margin;
totalMargin = GetBoxTotalMargin(box, aIsHorizontal);
}
if (aIsHorizontal) {
@ -835,7 +830,7 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, n
// include the margin of the columns. To the row
// at this point border/padding and margins all added
// up to more needed space.
GetBoxTotalMargin(box, margin, !aIsHorizontal);
margin = GetBoxTotalMargin(box, !aIsHorizontal);
box->GetInset(inset);
// get real border and padding. GetBorderAndPadding
// is redefined on nsGridRowLeafFrame. If we called it here
@ -1139,8 +1134,7 @@ nsGrid::IsGrid(nsIBox* aBox)
if (!part)
return PR_FALSE;
nsGridLayout2* grid = nsnull;
part->CastToGridLayout(&grid);
nsGridLayout2* grid = part->CastToGridLayout();
if (grid)
return PR_TRUE;

Просмотреть файл

@ -108,12 +108,12 @@ public:
private:
void GetPartFromBox(nsIBox* aBox, nsIGridPart** aPart);
void GetBoxTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal = PR_TRUE);
nsMargin GetBoxTotalMargin(nsIBox* aBox, PRBool aIsHorizontal = PR_TRUE);
void FreeMap();
void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);
void BuildRows(nsIBox* aBox, PRBool aSize, nsGridRow** aColumnsRows, PRBool aIsHorizontal = PR_TRUE);
void BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells);
void BuildRows(nsIBox* aBox, PRInt32 aSize, nsGridRow** aColumnsRows, PRBool aIsHorizontal = PR_TRUE);
nsGridCell* BuildCellMap(PRInt32 aRows, PRInt32 aColumns);
void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, PRBool aIsHorizontal = PR_TRUE);
void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
void SetLargestSize(nsSize& aSize, nscoord aHeight, PRBool aIsHorizontal = PR_TRUE);

Просмотреть файл

@ -93,8 +93,8 @@ nsGridLayout2::IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutSt
return rv;
}
NS_IMETHODIMP
nsGridLayout2::GetGrid(nsIBox* aBox, nsGrid** aGrid, PRInt32* aIndex, nsGridRowLayout* aRequestor)
nsGrid*
nsGridLayout2::GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
{
// XXX This should be set a better way!
mGrid.SetBox(aBox);
@ -106,15 +106,7 @@ nsGridLayout2::GetGrid(nsIBox* aBox, nsGrid** aGrid, PRInt32* aIndex, nsGridRowL
}
#endif
*aGrid = &mGrid;
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridRow)
{
NS_ERROR("Should not be called");
return NS_ERROR_FAILURE;
return &mGrid;
}
void
@ -255,63 +247,11 @@ nsGridLayout2::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
return rv;
}
NS_IMETHODIMP
nsGridLayout2::CountRowsColumns(nsIBox* aRowBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
nsMargin
nsGridLayout2::GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)
{
NS_ERROR("Should not be called");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGridLayout2::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
{
NS_ERROR("Should not be called");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGridLayout2::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
{
NS_ERROR("Should not be called");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsGridLayout2::CastToRowGroupLayout(nsGridRowGroupLayout** aRowGroup)
{
(*aRowGroup) = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::CastToGridLayout(nsGridLayout2** aGridLayout)
{
(*aGridLayout) = this;
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal)
{
aMargin.left = 0;
aMargin.right = 0;
aMargin.top = 0;
aMargin.bottom = 0;
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::GetRowCount(PRInt32& aRowCount)
{
NS_ERROR("Should not be called");
return NS_OK;
}
NS_IMETHODIMP_(nsIGridPart::Type)
nsGridLayout2::GetType()
{
return eGrid;
nsMargin margin(0,0,0,0);
return margin;
}
NS_IMETHODIMP
@ -330,7 +270,6 @@ nsGridLayout2::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aChildList)
@ -339,7 +278,6 @@ nsGridLayout2::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
return NS_OK;
}
NS_IMETHODIMP
nsGridLayout2::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aChildList)

Просмотреть файл

@ -67,19 +67,19 @@ public:
NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD IntrinsicWidthsDirty(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);
virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return nsnull; }
virtual nsGridLayout2* CastToGridLayout() { return this; }
virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull);
virtual void GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridPart) { NS_NOTREACHED("Should not be called"); }
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_(Type) GetType();
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount) { NS_NOTREACHED("Should not be called"); }
virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState) { NS_NOTREACHED("Should not be called"); }
virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows) { NS_NOTREACHED("Should not be called"); return 0; }
virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal);
virtual PRInt32 GetRowCount() { NS_NOTREACHED("Should not be called"); return 0; }
virtual Type GetType() { return eGrid; }
NS_IMETHOD ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox, nsIBox* aChildList);
NS_IMETHOD ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,

Просмотреть файл

@ -72,18 +72,15 @@ nsGridRowGroupLayout::~nsGridRowGroupLayout()
{
}
NS_IMETHODIMP
void
nsGridRowGroupLayout::ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
if (grid)
grid->RowAddedOrRemoved(aState, index, isHorizontal);
return NS_OK;
}
void
@ -110,9 +107,8 @@ nsGridRowGroupLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize
* as well.
*/
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
if (grid)
{
@ -137,9 +133,8 @@ nsGridRowGroupLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
{
nsresult rv = nsGridRowLayout::GetMaxSize(aBox, aState, aSize);
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
if (grid)
{
@ -164,9 +159,8 @@ nsGridRowGroupLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
{
nsresult rv = nsGridRowLayout::GetMinSize(aBox, aState, aSize);
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
if (grid)
{
@ -188,7 +182,7 @@ nsGridRowGroupLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
/*
* Run down through our children dirtying them recursively.
*/
NS_IMETHODIMP
void
nsGridRowGroupLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
{
if (aBox) {
@ -217,12 +211,10 @@ nsGridRowGroupLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
child->GetNextBox(&child);
}
}
return NS_OK;
}
NS_IMETHODIMP
void
nsGridRowGroupLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
{
if (aBox) {
@ -256,28 +248,14 @@ nsGridRowGroupLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32
mRowCount = aRowCount - startCount;
}
return NS_OK;
}
NS_IMETHODIMP
nsGridRowGroupLayout::GetRowCount(PRInt32& aRowCount)
{
aRowCount = mRowCount;
return NS_OK;
}
NS_IMETHODIMP_(nsIGridPart::Type)
nsGridRowGroupLayout::GetType()
{
return eRowGroup;
}
/**
* Fill out the given row structure recursively
*/
NS_IMETHODIMP
nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
PRInt32
nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows)
{
PRInt32 rowCount = 0;
@ -295,9 +273,7 @@ nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
if (layout) {
nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
if (monument) {
PRInt32 count = 0;
monument->BuildRows(deepChild, &aRows[rowCount], &count);
rowCount += count;
rowCount += monument->BuildRows(deepChild, &aRows[rowCount]);
child->GetNextBox(&child);
deepChild = child;
continue;
@ -313,24 +289,15 @@ nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
}
}
*aCount = rowCount;
return NS_OK;
return rowCount;
}
NS_IMETHODIMP
nsGridRowGroupLayout::CastToRowGroupLayout(nsGridRowGroupLayout** aRowGroup)
{
(*aRowGroup) = this;
return NS_OK;
}
NS_IMETHODIMP
nsGridRowGroupLayout::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal)
nsMargin
nsGridRowGroupLayout::GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)
{
// group have border and padding added to the total margin
nsresult rv = nsGridRowLayout::GetTotalMargin(aBox, aMargin, aIsHorizontal);
nsMargin margin = nsGridRowLayout::GetTotalMargin(aBox, aIsHorizontal);
// make sure we have the scrollframe on the outside if it has one.
// that's where the border is.
@ -339,13 +306,12 @@ nsGridRowGroupLayout::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIs
// add our border/padding to it
nsMargin borderPadding(0,0,0,0);
aBox->GetBorderAndPadding(borderPadding);
margin += borderPadding;
aMargin += borderPadding;
aBox->GetInset(borderPadding);
margin += borderPadding;
aMargin += borderPadding;
return rv;
return margin;
}

Просмотреть файл

@ -56,22 +56,22 @@ public:
friend nsresult NS_NewGridRowGroupLayout(nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout);
NS_IMETHOD CastToRowGroupLayout(nsGridRowGroupLayout** aRowGroup);
virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return this; }
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_(Type) GetType();
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState);
virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal);
virtual PRInt32 GetRowCount() { return mRowCount; }
virtual Type GetType() { return eRowGroup; }
protected:
nsGridRowGroupLayout(nsIPresShell* aShell);
virtual ~nsGridRowGroupLayout();
NS_IMETHOD ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
static void AddWidth(nsSize& aSize, nscoord aSize2, PRBool aIsHorizontal);
private:

Просмотреть файл

@ -56,28 +56,32 @@ nsGridRowLayout::nsGridRowLayout(nsIPresShell* aPresShell):nsSprocketLayout()
NS_IMETHODIMP
nsGridRowLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)
{
return ChildAddedOrRemoved(aBox, aState);
ChildAddedOrRemoved(aBox, aState);
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
{
return ChildAddedOrRemoved(aBox, aState);
ChildAddedOrRemoved(aBox, aState);
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
{
return ChildAddedOrRemoved(aBox, aState);
ChildAddedOrRemoved(aBox, aState);
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
{
return ChildAddedOrRemoved(aBox, aState);
ChildAddedOrRemoved(aBox, aState);
return NS_OK;
}
NS_IMETHODIMP
void
nsGridRowLayout::GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridPart)
{
// go up and find our parent gridRow. Skip and non gridRow
@ -90,26 +94,23 @@ nsGridRowLayout::GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPar
// get the parent
if (aBox)
aBox->GetParentBox(&aBox);
aBox->GetParentBox(&aBox);
if (aBox)
{
nsCOMPtr<nsIBoxLayout> layout;
aBox->GetLayoutManager(getter_AddRefs(layout));
nsCOMPtr<nsIGridPart> parentGridRow = do_QueryInterface(layout);
if (parentGridRow && parentGridRow->CanContain(this)) {
parentGridRow.swap(*aParentGridPart);
*aParentBox = aBox;
return NS_OK;
}
nsCOMPtr<nsIBoxLayout> layout;
aBox->GetLayoutManager(getter_AddRefs(layout));
nsCOMPtr<nsIGridPart> parentGridRow = do_QueryInterface(layout);
if (parentGridRow && parentGridRow->CanContain(this)) {
parentGridRow.swap(*aParentGridPart);
*aParentBox = aBox;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRowLayout* aRequestor)
nsGrid*
nsGridRowLayout::GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
{
if (aRequestor == nsnull)
@ -118,9 +119,8 @@ nsGridRowLayout::GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRo
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;
return parent->GetGrid(parentBox, aIndex, this);
return nsnull;
}
nsresult rv = NS_OK;
@ -145,10 +145,7 @@ nsGridRowLayout::GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRo
index = count;
break;
}
PRInt32 c = 0;
gridRow->GetRowCount(c);
count += c;
count += gridRow->GetRowCount();
} else
count++;
@ -159,9 +156,8 @@ nsGridRowLayout::GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRo
// this could happen during initial construction so lets just
// fail.
if (index == -1) {
*aList = nsnull;
*aIndex = -1;
return NS_OK;
return nsnull;
}
(*aIndex) += index;
@ -171,27 +167,13 @@ nsGridRowLayout::GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRo
GetParentGridPart(aBox, &parentBox, getter_AddRefs(parent));
if (parent)
parent->GetGrid(parentBox, aList, aIndex, this);
return parent->GetGrid(parentBox, aIndex, this);
return NS_OK;
return nsnull;
}
NS_IMETHODIMP
nsGridRowLayout::CastToRowGroupLayout(nsGridRowGroupLayout** aRowGroup)
{
(*aRowGroup) = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::CastToGridLayout(nsGridLayout2** aGridLayout)
{
(*aGridLayout) = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLayout::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal)
nsMargin
nsGridRowLayout::GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)
{
// get our parents margin
nsMargin margin(0,0,0,0);
@ -214,7 +196,7 @@ nsGridRowLayout::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHoriz
// get the parent first child to see if we are first
parent->GetChildBox(&child);
part->GetTotalMargin(parent,margin,aIsHorizontal);
margin = part->GetTotalMargin(parent, aIsHorizontal);
// if first or last
if (child == aBox || next == nsnull) {
@ -242,13 +224,12 @@ nsGridRowLayout::GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHoriz
}
}
aMargin = margin;
// add ours to it.
aBox->GetMargin(margin);
aMargin += margin;
nsMargin ourMargin;
aBox->GetMargin(ourMargin);
margin += ourMargin;
return NS_OK;
return margin;
}
NS_IMPL_ADDREF_INHERITED(nsGridRowLayout, nsBoxLayout)

Просмотреть файл

@ -66,18 +66,18 @@ class nsGridRowLayout : public nsSprocketLayout,
public:
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);
virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return nsnull; }
virtual nsGridLayout2* CastToGridLayout() { return nsnull; }
virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull);
virtual void 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);
virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal);
protected:
NS_IMETHOD ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)=0;
virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)=0;
nsGridRowLayout(nsIPresShell* aShell);
};

Просмотреть файл

@ -76,9 +76,8 @@ nsGridRowLeafFrame::GetBorderAndPadding(nsMargin& aBorderAndPadding)
if (!part)
return rv;
nsGrid* grid = nsnull;
PRInt32 index = 0;
part->GetGrid(this, &grid, &index);
nsGrid* grid = part->GetGrid(this, &index);
if (!grid)
return rv;

Просмотреть файл

@ -72,9 +72,8 @@ nsGridRowLeafLayout::~nsGridRowLeafLayout()
NS_IMETHODIMP
nsGridRowLeafLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
// If we are not in a grid. Then we just work like a box. But if we are in a grid
@ -92,9 +91,8 @@ nsGridRowLeafLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
NS_IMETHODIMP
nsGridRowLeafLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
if (!grid)
@ -110,9 +108,8 @@ nsGridRowLeafLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
NS_IMETHODIMP
nsGridRowLeafLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSize)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
if (!grid)
@ -127,26 +124,22 @@ nsGridRowLeafLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
/** If a child is added or removed or changes size
*/
NS_IMETHODIMP
void
nsGridRowLeafLayout::ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
if (grid)
grid->CellAddedOrRemoved(aState, index, isHorizontal);
return NS_OK;
}
void
nsGridRowLeafLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nsComputedBoxSize*& aComputedBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes)
{
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
nsGrid* grid = GetGrid(aBox, &index);
PRBool isHorizontal = IsHorizontal(aBox);
// Our base class SprocketLayout is giving us a chance to change the box sizes before layout
@ -201,8 +194,7 @@ nsGridRowLeafLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, ns
grid->GetFirstAndLastRow(aState, firstIndex, lastIndex, firstRow, lastRow, !isHorizontal);
if (i == firstIndex || i == lastIndex) {
nsMargin offset(0,0,0,0);
GetTotalMargin(aBox, offset, isHorizontal);
nsMargin offset = GetTotalMargin(aBox, isHorizontal);
nsMargin border(0,0,0,0);
// can't call GetBorderPadding we will get into recursion
@ -328,7 +320,7 @@ nsGridRowLeafLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
return nsGridRowLayout::Layout(aBox, aBoxLayoutState);
}
NS_IMETHODIMP
void
nsGridRowLeafLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
{
if (aBox) {
@ -338,11 +330,9 @@ nsGridRowLeafLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
// calling MarkIntrinsicWidthsDirty for every row.
aState.PresShell()->FrameNeedsReflow(aBox, nsIPresShell::eTreeChange);
}
return NS_OK;
}
NS_IMETHODIMP
void
nsGridRowLeafLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
{
if (aBox) {
@ -362,33 +352,16 @@ nsGridRowLeafLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32&
aRowCount++;
}
return NS_OK;
}
NS_IMETHODIMP
nsGridRowLeafLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
PRInt32
nsGridRowLeafLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows)
{
if (aBox) {
aRows[0].Init(aBox, PR_FALSE);
*aCount = 1;
return NS_OK;
return 1;
}
*aCount = 0;
return NS_OK;
return 0;
}
NS_IMETHODIMP
nsGridRowLeafLayout::GetRowCount(PRInt32& aRowCount)
{
aRowCount = 1;
return NS_OK;
}
NS_IMETHODIMP_(nsIGridPart::Type)
nsGridRowLeafLayout::GetType()
{
return eRowLeaf;
}

Просмотреть файл

@ -62,13 +62,13 @@ public:
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 ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
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_IMETHOD_(Type) GetType();
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState);
virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
virtual PRInt32 GetRowCount() { return 1; }
virtual Type GetType() { return eRowLeaf; }
protected:

Просмотреть файл

@ -47,10 +47,10 @@ class nsGridRowLayout;
class nsGridRow;
class nsGridLayout2;
// adaee669-f8db-42d7-8817-a2299a341404
// 07373ed7-e947-4a5e-b36c-69f7c195677b
#define NS_IGRIDPART_IID \
{ 0xadaee669, 0xf8db, 0x42d7, \
{ 0x88, 0x17, 0xa2, 0x29, 0x9a, 0x34, 0x14, 0x04 } }
{ 0x07373ed7, 0xe947, 0x4a5e, \
{ 0xb3, 0x6c, 0x69, 0xf7, 0xc1, 0x95, 0x67, 0x7b } }
/**
* An additional interface implemented by nsIBoxLayout implementations
@ -62,14 +62,12 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGRIDPART_IID)
NS_IMETHOD CastToRowGroupLayout(nsGridRowGroupLayout** aRowGroup)=0;
NS_IMETHOD CastToGridLayout(nsGridLayout2** aGrid)=0;
virtual nsGridRowGroupLayout* CastToRowGroupLayout()=0;
virtual nsGridLayout2* CastToGridLayout()=0;
/**
* @param aBox [IN] The other half of the |this| parameter, i.e., the box
* whose layout manager is |this|.
* @param aList [OUT] The grid of which aBox (a row, row group, or grid)
* is a part.
* @param aIndex [INOUT] For callers not setting aRequestor, the value
* pointed to by aIndex is incremented by the index
* of the row (aBox) within its row group; if aBox
@ -82,8 +80,9 @@ public:
* in which case it is a pointer to that grid part.
* (This may only be non-null for row groups and
* grids.)
* @return The grid of which aBox (a row, row group, or grid) is a part.
*/
NS_IMETHOD GetGrid(nsIBox* aBox, nsGrid** aList, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull)=0;
virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull)=0;
/**
* @param aBox [IN] The other half of the |this| parameter, i.e., the box
@ -93,19 +92,25 @@ public:
* row group).
* @param aParentGridRow [OUT] The layout manager for aParentBox.
*/
NS_IMETHOD GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridRow)=0;
virtual void GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridRow)=0;
NS_IMETHOD CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)=0;
NS_IMETHOD DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)=0;
NS_IMETHOD BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)=0;
NS_IMETHOD GetTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal)=0;
NS_IMETHOD GetRowCount(PRInt32& aRowCount)=0;
/**
* @param aBox [IN] The other half of the |this| parameter, i.e., the box
* whose layout manager is |this|.
* @param aRowCount [INOUT] Row count
* @param aComputedColumnCount [INOUT] Column count
*/
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)=0;
virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)=0;
virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows)=0;
virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)=0;
virtual PRInt32 GetRowCount()=0;
/**
* Return the level of the grid hierarchy this grid part represents.
*/
enum Type { eGrid, eRowGroup, eRowLeaf };
NS_IMETHOD_(Type) GetType()=0;
virtual Type GetType()=0;
/**
* Return whether this grid part is an appropriate parent for the argument.