2) Exposes code to allow new grid landing

bug# 77357
-r hyatt -sr waterson
This commit is contained in:
evaughan%netscape.com 2001-10-09 21:02:29 +00:00
Родитель 664e370179
Коммит 12b15fa911
28 изменённых файлов: 465 добавлений и 162 удалений

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

@ -296,14 +296,29 @@ nsresult
NS_NewOutlinerBodyFrame (nsIPresShell* aPresShell, nsIFrame** aNewFrame);
// grid
#ifdef MOZ_GRID2
nsresult
NS_NewGridLayout2 ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewGridLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
#ifdef MOZ_GRID2
nsresult
NS_NewGridRowLeafLayout ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewObeliskLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
#ifdef MOZ_GRID2
nsresult
NS_NewGridRowGroupLayout ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewTempleLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
nsresult
NS_NewTreeLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
@ -5339,8 +5354,11 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
nsCOMPtr<nsIBoxLayout> layout;
#ifdef MOZ_GRID2
NS_NewGridLayout2(aPresShell, getter_AddRefs(layout));
#else
NS_NewGridLayout(aPresShell, layout);
#endif
if (aTag == nsXULAtoms::tree) {
rv = NS_NewXULTreeFrame(aPresShell, &newFrame, PR_FALSE, layout);
if (aXBLBaseTag) {
@ -5402,7 +5420,11 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
}
else
{
#ifdef MOZ_GRID2
NS_NewGridRowGroupLayout(aPresShell, getter_AddRefs(layout));
#else
NS_NewTempleLayout(aPresShell, layout);
#endif
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout);
}
@ -5433,7 +5455,12 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
isReplaced = PR_TRUE;
nsCOMPtr<nsIBoxLayout> layout;
#ifdef MOZ_GRID2
NS_NewGridRowLeafLayout(aPresShell, getter_AddRefs(layout));
#else
NS_NewObeliskLayout(aPresShell, layout);
#endif
if (aTag == nsXULAtoms::treerow)
rv = NS_NewXULTreeSliceFrame(aPresShell, &newFrame, PR_FALSE, layout);

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

@ -74,6 +74,9 @@ SUB_LIBRARIES= \
$(DIST)\lib\layoutxulbase_s.lib \
$(DIST)\lib\contentshared_s.lib \
$(DIST)\lib\raptorxuloutliner_s.lib \
!ifdef MOZ_GRID2
$(DIST)\lib\raptorxulgrid_s.lib \
!endif
!ifdef MOZ_MATHML
$(DIST)\lib\layoutmathmlbase_s.lib \
$(DIST)\lib\layoutmathmlcontent_s.lib \

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

@ -296,14 +296,29 @@ nsresult
NS_NewOutlinerBodyFrame (nsIPresShell* aPresShell, nsIFrame** aNewFrame);
// grid
#ifdef MOZ_GRID2
nsresult
NS_NewGridLayout2 ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewGridLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
#ifdef MOZ_GRID2
nsresult
NS_NewGridRowLeafLayout ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewObeliskLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
#ifdef MOZ_GRID2
nsresult
NS_NewGridRowGroupLayout ( nsIPresShell* aPresShell, nsIBoxLayout** aNewLayout );
#else
nsresult
NS_NewTempleLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
#endif
nsresult
NS_NewTreeLayout ( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout );
@ -5339,8 +5354,11 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
processChildren = PR_TRUE;
isReplaced = PR_TRUE;
nsCOMPtr<nsIBoxLayout> layout;
#ifdef MOZ_GRID2
NS_NewGridLayout2(aPresShell, getter_AddRefs(layout));
#else
NS_NewGridLayout(aPresShell, layout);
#endif
if (aTag == nsXULAtoms::tree) {
rv = NS_NewXULTreeFrame(aPresShell, &newFrame, PR_FALSE, layout);
if (aXBLBaseTag) {
@ -5402,7 +5420,11 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
}
else
{
#ifdef MOZ_GRID2
NS_NewGridRowGroupLayout(aPresShell, getter_AddRefs(layout));
#else
NS_NewTempleLayout(aPresShell, layout);
#endif
rv = NS_NewBoxFrame(aPresShell, &newFrame, PR_FALSE, layout);
}
@ -5433,7 +5455,12 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell,
isReplaced = PR_TRUE;
nsCOMPtr<nsIBoxLayout> layout;
#ifdef MOZ_GRID2
NS_NewGridRowLeafLayout(aPresShell, getter_AddRefs(layout));
#else
NS_NewObeliskLayout(aPresShell, layout);
#endif
if (aTag == nsXULAtoms::treerow)
rv = NS_NewXULTreeSliceFrame(aPresShell, &newFrame, PR_FALSE, layout);

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

@ -50,7 +50,77 @@
#include "nsGridRow.h"
#include "nsGridCell.h"
//------ nsGrid ----
/*
The grid control expands the idea of boxes from 1 dimension to 2 dimensions.
It works by allowing the XUL to define a collection of rows and columns and then
stacking them on top of each other. Here is and example.
Example 1:
<grid>
<columns>
<column/>
<column/>
</columns>
<rows>
<row/>
<row/>
</rows>
</grid>
example 2:
<grid>
<columns>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows>
<row>
<text value="hello"/>
<text value="there"/>
</row>
</rows>
</grid>
example 3:
<grid>
<rows>
<row>
<text value="hello"/>
<text value="there"/>
</row>
</rows>
<columns>
<column>
<text value="Hey I'm in the column and I'm on top!"/>
</column>
<column/>
</columns>
</grid>
The columns are first and the rows are second, so the rows will be drawn on top of the columns.
You can reverse this by defining the rows first.
Other tags are then placed in the <row> or <column> tags causing the grid to accommodate everyone.
It does this by creating 3 things: A cellmap, a row list, and a column list. The cellmap is a 2
dimensional array of nsGridCells. Each cell contains 2 boxes. One cell from the column list
and one from the row list. When a cell is asked for its size it returns that smallest size it can
be to accommodate the 2 cells. Row lists and Column lists use the same data structure: nsGridRow.
Essentially a row and column are the same except a row goes alone the x axis and a column the y.
To make things easier and save code everything is written in terms of the x dimension. A flag is
passed in called "isRow" that can flip the calculations to the y axis.
Usually the number of cells in a row match the number of columns, but not always.
It is possible to define 5 columns for a grid but have 10 cells in one of the rows.
In this case 5 extra columns will be added to the column list to handle the situation.
These are called extraColumns/Rows.
*/
nsGrid::nsGrid():mBox(nsnull),
mColumns(nsnull),
@ -74,6 +144,11 @@ nsGrid::~nsGrid()
MOZ_COUNT_DTOR(nsGrid);
}
/*
* This is called whenever something major happens in the grid. And example
* might be when many cells or row are added. It sets a flag signaling that
* all the grids caches information should be recalculated.
*/
void
nsGrid::NeedsRebuild(nsBoxLayoutState& aState)
{
@ -86,26 +161,34 @@ nsGrid::NeedsRebuild(nsBoxLayoutState& aState)
// free the map
FreeMap();
// tell all the rows and columns they are dirty
// find the new row and column box. They could have
// been changed.
FindRowsAndColumns(&mRowBox, &mColumnBox);
// tell all the rows and columns they are dirty
DirtyRows(mRowBox, aState);
DirtyRows(mColumnBox, aState);
}
/**
* Run through the rows in the given box and mark them dirty so they
* will get recalculated and get a layout.
*/
void
nsGrid::DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState)
{
// make sure we prevent others from dirtying things.
mMarkingDirty = PR_TRUE;
// if the box is a grid part have it recursively hand it.
if (aRowBox) {
nsCOMPtr<nsIBoxLayout> layout;
aRowBox->GetLayoutManager(getter_AddRefs(layout));
if (layout) {
nsCOMPtr<nsIGridPart> monument( do_QueryInterface(layout) );
if (monument)
monument->DirtyRows(aRowBox, aState);
nsCOMPtr<nsIGridPart> part( do_QueryInterface(layout) );
if (part)
part->DirtyRows(aRowBox, aState);
}
}
@ -129,13 +212,7 @@ nsGridRow* nsGrid::GetRows()
nsGridRow*
nsGrid::GetColumnAt(PRInt32 aIndex, PRBool aIsRow)
{
RebuildIfNeeded();
if (aIsRow) {
NS_ASSERTION(aIndex < mColumnCount || aIndex >= 0, "Index out of range");
return &mColumns[aIndex];
} else
return GetRowAt(aIndex);
return GetRowAt(aIndex, !aIsRow);
}
nsGridRow*
@ -147,7 +224,8 @@ nsGrid::GetRowAt(PRInt32 aIndex, PRBool aIsRow)
NS_ASSERTION(aIndex < mRowCount || aIndex >= 0, "Index out of range");
return &mRows[aIndex];
} else {
return GetColumnAt(aIndex);
NS_ASSERTION(aIndex < mColumnCount || aIndex >= 0, "Index out of range");
return &mColumns[aIndex];
}
}
@ -178,6 +256,9 @@ nsGrid::GetExtraRowCount(PRBool aIsRow)
return mExtraColumnCount;
}
/**
* If we are marked for rebuild. Then build everything
*/
void
nsGrid::RebuildIfNeeded()
{
@ -266,6 +347,9 @@ nsGrid::FreeMap()
mColumnBox = nsnull;
}
/**
* finds the first <rows> and <columns> tags in the <grid> tag
*/
void
nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns)
{
@ -317,6 +401,11 @@ nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns)
}
}
/**
* Count the number of rows and columns in the given box. aRowCount well become the actual number
* rows defined in the xul. aComputedColumnCount will become the number of columns by counting the number
* of cells in each row.
*/
void
nsGrid::CountRowsColumns(nsIBox* aRowBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
{
@ -333,6 +422,9 @@ 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 aIsRow)
{
@ -364,6 +456,9 @@ nsGrid::BuildRows(nsIBox* aBox, PRBool aRowCount, nsGridRow** aRows, PRBool aIsR
}
/**
* Given the number of rows and columns. Build a cellmap
*/
void
nsGrid::BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells)
{
@ -374,6 +469,10 @@ nsGrid::BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells)
(*aCells) = new nsGridCell[size];
}
/**
* Run through all the cells in the rows and columns and populate then with 2 cells. One from the row and one
* from the column
*/
void
nsGrid::PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, PRBool aIsRow)
{
@ -423,7 +522,7 @@ nsGrid::PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount
/**
* These methods return the preferred, min, max sizes for a given row index.
* aIsRow is defaulted to PR_TRUE. If you pass PR_FALSE you will get the inverse.
* aIsRow if aIsRow is PR_TRUE. If you pass PR_FALSE you will get the inverse.
* As if you called GetPrefColumnSize(aState, index, aPref)
*/
nsresult
@ -467,9 +566,9 @@ nsGrid::GetMaxRowSize(nsBoxLayoutState& aState, PRInt32 aRowIndex, nsSize& aSize
}
/**
* These methods return the preferred, min, max coord for a given row index.
* aIsRow is defaulted to PR_TRUE. If you pass PR_FALSE you will get the inverse.
* As if you called GetPrefColumnHeight(aState, index, aPref)
* These methods return the preferred, min, max coord for a given row index if
* aIsRow is PR_TRUE. If you pass PR_FALSE you will get the inverse.
* As if you called GetPrefColumnHeight(aState, index, aPref).
*/
nsresult
nsGrid::GetPrefRowHeight(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aSize, PRBool aIsRow)
@ -745,6 +844,10 @@ nsGrid::GetColumnCount(PRInt32 aIsRow)
return GetRowCount(!aIsRow);
}
/**
* This is called if a child in a row became dirty. This happens if the child gets bigger or smaller
* in some way.
*/
void
nsGrid::RowChildIsDirty(nsBoxLayoutState& aState, PRInt32 aRowIndex, PRInt32 aColumnIndex, PRBool aIsRow)
{
@ -784,6 +887,10 @@ nsGrid::RowChildIsDirty(nsBoxLayoutState& aState, PRInt32 aRowIndex, PRInt32 aCo
mMarkingDirty = PR_FALSE;
}
/**
* The row became dirty. This happens if the row's borders change or children inside it
* force it to change size
*/
void
nsGrid::RowIsDirty(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsRow)
{
@ -793,6 +900,9 @@ nsGrid::RowIsDirty(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsRow)
NeedsRebuild(aState);
}
/*
* a Cell in the given row or columns at the given index has had a child added or removed
*/
void
nsGrid::CellAddedOrRemoved(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsRow)
{
@ -804,6 +914,9 @@ nsGrid::CellAddedOrRemoved(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsR
NeedsRebuild(aState);
}
/**
* A row or columns at the given index had been added or removed
*/
void
nsGrid::RowAddedOrRemoved(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsRow)
{
@ -814,24 +927,7 @@ nsGrid::RowAddedOrRemoved(nsBoxLayoutState& aState, PRInt32 aIndex, PRBool aIsRo
NeedsRebuild(aState);
}
/*
void
nsGrid::PrintCellMap()
{
printf("-----CellMap------\n");
for (int y=0; y < mRowCount; y++)
{
for (int x=0; x < mColumnCount; x++)
{
nsGridCell* cell = GetCellAt(x,y);
//printf("(%d)@%p[@%p,@%p] ", y*mColumnCount+x, cell, cell->GetBoxInRow(), cell->GetBoxInColumn());
printf("p=%d, ", y*mColumnCount+x, cell, cell->GetBoxInRow(), cell->GetBoxInColumn());
}
printf("\n");
}
}
*/
#ifdef DEBUG_grid
void
nsGrid::PrintCellMap()
{
@ -839,6 +935,7 @@ nsGrid::PrintCellMap()
printf("-----Columns------\n");
for (int x=0; x < mColumnCount; x++)
{
nsGridRow* column = GetColumnAt(x);
printf("%d(pf=%d, mn=%d, mx=%d) ", x, column->mPref, column->mMin, column->mMax);
}
@ -852,18 +949,18 @@ nsGrid::PrintCellMap()
printf("\n");
/*
printf("-----CellMap------\n");
for (int y=0; y < mRowCount; y++)
{
for (int x=0; x < mColumnCount; x++)
{
nsGridCell* cell = GetCellAt(x,y);
//printf("(%d)@%p[@%p,@%p] ", y*mColumnCount+x, cell, cell->GetBoxInRow(), cell->GetBoxInColumn());
printf("p=%d, ", y*mColumnCount+x, cell, cell->GetBoxInRow(), cell->GetBoxInColumn());
}
printf("\n");
}
*/
}
#endif

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

@ -57,64 +57,88 @@ class nsGridCell;
class nsGrid
{
public:
nsGrid();
~nsGrid();
nsGrid();
~nsGrid();
virtual void FreeMap();
virtual PRInt32 GetRowCount(PRInt32 aIsRow = PR_TRUE);
virtual PRInt32 GetColumnCount(PRInt32 aIsRow = PR_TRUE);
virtual void NeedsRebuild(nsBoxLayoutState& aBoxLayoutState);
virtual nsGridRow* GetColumnAt(PRInt32 aIndex, PRBool aIsRow = PR_TRUE);
virtual nsGridRow* GetRowAt(PRInt32 aIndex, PRBool aIsRow = PR_TRUE);
virtual nsGridCell* GetCellAt(PRInt32 aX, PRInt32 aY);
virtual void RebuildIfNeeded();
virtual void NeedsRebuild(nsBoxLayoutState& aBoxLayoutState);
virtual nsGridRow* GetColumnAt(PRInt32 aIndex, PRBool aIsRow);
virtual nsGridRow* GetRowAt(PRInt32 aIndex, PRBool aIsRow);
virtual nsGridCell* GetCellAt(PRInt32 aX, PRInt32 aY);
virtual void RebuildIfNeeded();
virtual nsresult GetPrefRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetMinRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetMaxRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetRowFlex(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aSize, PRBool aIsRow);
virtual nsresult GetPrefRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetMinRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetMaxRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsRow);
virtual nsresult GetRowFlex(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aSize, PRBool aIsRow);
virtual nsresult GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow = PR_TRUE);
virtual nsresult GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow = PR_TRUE);
virtual nsresult GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow = PR_TRUE);
virtual nsresult GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow);
virtual nsresult GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow);
virtual nsresult GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsRow);
virtual void RowChildIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, PRInt32 aColumnIndex, PRBool aIsRow = PR_TRUE);
virtual void RowIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow = PR_TRUE);
virtual void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow = PR_TRUE);
virtual void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow = PR_TRUE);
virtual void DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState);
virtual void PrintCellMap();
virtual PRInt32 GetExtraColumnCount(PRBool aIsRow = PR_TRUE);
virtual PRInt32 GetExtraRowCount(PRBool aIsRow = PR_TRUE);
virtual void RowChildIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, PRInt32 aColumnIndex, PRBool aIsRow);
virtual void RowIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow);
virtual void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow);
virtual void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsRow);
virtual void DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState);
#ifdef DEBUG_grid
virtual void PrintCellMap();
#endif
virtual PRInt32 GetExtraColumnCount(PRBool aIsRow);
virtual PRInt32 GetExtraRowCount(PRBool aIsRow);
// accessors
virtual void SetBox(nsIBox* aBox) { mBox = aBox; }
virtual nsGridRow* GetColumns();
virtual nsGridRow* GetRows();
virtual void SetBox(nsIBox* aBox) { mBox = aBox; }
virtual nsIBox* GetBox() { return mBox; }
virtual nsGridRow* GetColumns();
virtual nsGridRow* GetRows();
virtual PRInt32 GetRowCount(PRInt32 aIsRow);
virtual PRInt32 GetColumnCount(PRInt32 aIsRow);
protected:
virtual void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);
virtual void BuildRows(nsIBox* aBox, PRBool aSize, nsGridRow** aColumnsRows, PRBool aIsRow = PR_TRUE);
virtual void BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells);
virtual void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, PRBool aIsRow = PR_TRUE);
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
virtual void SetLargestSize(nsSize& aSize, nscoord aHeight, PRBool aIsRow);
virtual void SetSmallestSize(nsSize& aSize, nscoord aHeight, PRBool aIsRow);
virtual void FreeMap();
virtual void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);
virtual void BuildRows(nsIBox* aBox, PRBool aSize, nsGridRow** aColumnsRows, PRBool aIsRow);
virtual void BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells);
virtual void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, PRBool aIsRow);
virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
virtual void SetLargestSize(nsSize& aSize, nscoord aHeight, PRBool aIsRow);
virtual void SetSmallestSize(nsSize& aSize, nscoord aHeight, PRBool aIsRow);
public:
private:
nsIBox* mBox;
nsGridRow* mRows;
nsGridRow* mColumns;
nsIBox* mRowBox;
nsIBox* mColumnBox;
PRBool mNeedsRebuild;
PRInt32 mRowCount;
PRInt32 mColumnCount;
PRInt32 mExtraRowCount;
PRInt32 mExtraColumnCount;
nsGridCell* mCellMap;
PRBool mMarkingDirty;
// the box that implement the <grid> tag
nsIBox* mBox;
// an array of row object
nsGridRow* mRows;
// an array of columns objects.
nsGridRow* mColumns;
// the first in the <grid> that implements the <rows> tag.
nsIBox* mRowBox;
// the first in the <grid> that implements the <columns> tag.
nsIBox* mColumnBox;
// a flag that is false tells us to rebuild the who grid
PRBool mNeedsRebuild;
// number of rows and columns as defined by the XUL
PRInt32 mRowCount;
PRInt32 mColumnCount;
// number of rows and columns that are implied but not
// explicitly defined int he XUL
PRInt32 mExtraRowCount;
PRInt32 mExtraColumnCount;
// x,y array of cells in the rows and columns
nsGridCell* mCellMap;
// a flag that when true suppresses all other MarkDirties. This
// prevents lots of extra work being done.
PRBool mMarkingDirty;
};
#endif

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

@ -45,7 +45,7 @@
#include "nsGridCell.h"
#include "nsFrame.h"
#include "nsIBox.h"
#include "nsBoxLayout.h"
#include "nsBox.h"
#include "nsStackLayout.h"
@ -73,7 +73,7 @@ nsGridCell::GetPrefSize(nsBoxLayoutState& aState, nsSize& aPref)
if (mBoxInColumn) {
mBoxInColumn->GetPrefSize(aState, pref);
nsBoxLayout::AddMargin(mBoxInColumn, pref);
nsBox::AddMargin(mBoxInColumn, pref);
nsStackLayout::AddOffset(aState, mBoxInColumn, pref);
nsBoxLayout::AddLargestSize(aPref, pref);
@ -82,7 +82,7 @@ nsGridCell::GetPrefSize(nsBoxLayoutState& aState, nsSize& aPref)
if (mBoxInRow) {
mBoxInRow->GetPrefSize(aState, pref);
nsBoxLayout::AddMargin(mBoxInRow, pref);
nsBox::AddMargin(mBoxInRow, pref);
nsStackLayout::AddOffset(aState, mBoxInRow, pref);
nsBoxLayout::AddLargestSize(aPref, pref);
@ -106,7 +106,7 @@ nsGridCell::GetMinSize(nsBoxLayoutState& aState, nsSize& aMin)
if (mBoxInColumn) {
mBoxInColumn->GetMinSize(aState, min);
nsBoxLayout::AddMargin(mBoxInColumn, min);
nsBox::AddMargin(mBoxInColumn, min);
nsStackLayout::AddOffset(aState, mBoxInColumn, min);
nsBoxLayout::AddLargestSize(aMin, min);
@ -115,7 +115,7 @@ nsGridCell::GetMinSize(nsBoxLayoutState& aState, nsSize& aMin)
if (mBoxInRow) {
mBoxInRow->GetMinSize(aState, min);
nsBoxLayout::AddMargin(mBoxInRow, min);
nsBox::AddMargin(mBoxInRow, min);
nsStackLayout::AddOffset(aState, mBoxInRow, min);
nsBoxLayout::AddLargestSize(aMin, min);
@ -140,7 +140,7 @@ nsGridCell::GetMaxSize(nsBoxLayoutState& aState, nsSize& aMax)
mBoxInColumn->GetMaxSize(aState, max);
nsBoxLayout::AddMargin(mBoxInColumn, max);
nsBox::AddMargin(mBoxInColumn, max);
nsStackLayout::AddOffset(aState, mBoxInColumn, max);
nsBoxLayout::AddSmallestSize(aMax, max);
@ -149,7 +149,7 @@ nsGridCell::GetMaxSize(nsBoxLayoutState& aState, nsSize& aMax)
if (mBoxInRow) {
mBoxInRow->GetMaxSize(aState, max);
nsBoxLayout::AddMargin(mBoxInRow, max);
nsBox::AddMargin(mBoxInRow, max);
nsStackLayout::AddOffset(aState, mBoxInRow, max);
nsBoxLayout::AddSmallestSize(aMax, max);

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

@ -67,14 +67,16 @@ nsGridLayout2::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
{
mGrid.SetBox(aBox);
nsresult rv = nsStackLayout::Layout(aBox, aBoxLayoutState);
#ifdef DEBUG_grid
mGrid.PrintCellMap();
#endif
return rv;
}
NS_IMETHODIMP
nsGridLayout2::GetGrid(nsIBox* aBox, nsGrid** aGrid, PRInt32* aIndex, nsGridRowLayout* aRequestor)
{
mGrid.mBox = aBox;
mGrid.SetBox(aBox);
*aGrid = &mGrid;
return NS_OK;
}

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

@ -42,6 +42,11 @@
// See documentation in associated header file
//
/*
* The nsGridRowGroupLayout implements the <rows> or <columns> tag in a grid.
*/
#include "nsGridRowGroupLayout.h"
#include "nsIBox.h"
#include "nsCOMPtr.h"
@ -98,6 +103,14 @@ nsGridRowGroupLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize
{
nsresult rv = nsGridRowLayout::GetPrefSize(aBox, aState, aSize);
/* 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.
*/
nsGrid* grid = nsnull;
PRInt32 index = 0;
GetGrid(aBox, &grid, &index);
@ -183,6 +196,9 @@ nsGridRowGroupLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
return nsGridRowLayout::Layout(aBox, aBoxLayoutState);
}
/*
* Scrollframes are tranparent. We should always walk down into them.
*/
nsIBox*
nsGridRowGroupLayout::CheckForScrollFrame(nsIBox* aChild)
{
@ -199,6 +215,10 @@ nsGridRowGroupLayout::CheckForScrollFrame(nsIBox* aChild)
return aChild;
}
/*
* Run down through our children dirtying them recursively.
*/
NS_IMETHODIMP
nsGridRowGroupLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
{
@ -271,6 +291,9 @@ nsGridRowGroupLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32
}
/**
* Fill out the given row structure recursively
*/
NS_IMETHODIMP
nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows, PRInt32* aCount)
{

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

@ -84,6 +84,8 @@ nsGridRowLeafLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize&
GetGrid(aBox, &grid, &index);
PRInt32 isRow = 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 {

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

@ -23,7 +23,11 @@ DEPTH=..\..\..\..
LIBRARY_NAME=layoutxulbase_s
MODULE=layout_xul
DIRS=outliner
DIRS=outliner \
!ifdef MOZ_GRID2
grid
!endif
REQUIRES = xpcom \
string \
dom \

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

@ -1493,36 +1493,24 @@ nsBox::AddInset(nsIBox* aBox, nsSize& aSize)
AddMargin(aSize, margin);
}
void
nsBox::BoundsCheck(nscoord& aMin, nscoord& aPref, nscoord& aMax)
{
if (aMin > aMax)
aMin = aMax;
if (aPref > aMax)
aPref = aMax;
if (aPref < aMin)
aPref = aMin;
}
void
nsBox::BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize)
{
if (aMinSize.width > aMaxSize.width)
aMinSize.width = aMaxSize.width;
if (aMinSize.height > aMaxSize.height)
aMinSize.height = aMaxSize.height;
/*
if (aMinSize.width > aMaxSize.width)
aMaxSize.width = aMinSize.width;
if (aMinSize.height > aMaxSize.height)
aMaxSize.height = aMinSize.height;
*/
if (aPrefSize.width > aMaxSize.width)
aPrefSize.width = aMaxSize.width;
if (aPrefSize.height > aMaxSize.height)
aPrefSize.height = aMaxSize.height;
if (aPrefSize.width < aMinSize.width)
aPrefSize.width = aMinSize.width;
if (aPrefSize.height < aMinSize.height)
aPrefSize.height = aMinSize.height;
BoundsCheck(aMinSize.width, aPrefSize.width, aMaxSize.width);
BoundsCheck(aMinSize.height, aPrefSize.height, aMaxSize.height);
}
NS_IMETHODIMP
@ -1628,6 +1616,14 @@ nsBox::Release(void)
return NS_OK;
}
NS_IMETHODIMP
nsBox::GetIndexOf(nsIBox* aChild, PRInt32* aIndex)
{
// return -1. We have no children
*aIndex = -1;
return NS_OK;
}
//
// QueryInterface
//

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

@ -99,6 +99,7 @@ public:
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState);
NS_IMETHOD DumpBox(FILE* out);
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust);
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex);
nsBox(nsIPresShell* aShell);
@ -122,6 +123,7 @@ public:
static nsresult CollapseChild(nsBoxLayoutState& aState, nsIFrame* aFrame, PRBool aHide);
static void BoundsCheck(nsSize& aMinSize, nsSize& aPrefSize, nsSize& aMaxSize);
static void BoundsCheck(nscoord& aMinSize, nscoord& aPrefSize, nscoord& aMaxSize);
protected:

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

@ -262,6 +262,24 @@ nsBoxFrame::~nsBoxFrame()
NS_ASSERTION(mInner == nsnull,"Error Destroy was never called on this Frame!!!");
}
NS_IMETHODIMP nsBoxFrame::SetParent(const nsIFrame* aParent)
{
// our box parent can only be a box. Make sure its a box and set it
// if its not a box then its nsnull
// cast away const so we can call QueryInterface.
nsIFrame* parent = (nsIFrame*)aParent;
// don't use com ptr. Frames don't support ADDREF or RELEASE;
nsIBox* boxParent = nsnull;
if (parent)
parent->QueryInterface(NS_GET_IID(nsIBox), (void**)&boxParent);
return nsBox::SetParentBox(boxParent);
}
NS_IMETHODIMP
nsBoxFrame::GetVAlign(Valignment& aAlign)
{
@ -323,6 +341,8 @@ nsBoxFrame::Init(nsIPresContext* aPresContext,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
SetParent(aParent);
mInner->mPresContext = aPresContext;
nsresult rv = nsContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
@ -1463,6 +1483,8 @@ nsBoxFrameInner::GetDebugPref(nsIPresContext* aPresContext)
}
}
#include "nsIMonument.h"
NS_IMETHODIMP
nsBoxFrame::Paint(nsIPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -1470,7 +1492,6 @@ nsBoxFrame::Paint(nsIPresContext* aPresContext,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
const nsStyleVisibility* vis =
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
@ -2693,3 +2714,5 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
return NS_OK;
}

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

@ -108,6 +108,7 @@ public:
NS_IMETHOD BeginLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD GetDebug(PRBool& aDebug);
NS_IMETHOD SetParent(const nsIFrame* aParent);
//NS_IMETHOD GetMouseThrough(PRBool& aMouseThrough);

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

@ -195,6 +195,12 @@ nsBoxLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aCh
return NS_OK;
}
NS_IMETHODIMP
nsBoxLayout::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
{
return NS_OK;
}
NS_IMETHODIMP
nsBoxLayout::ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild)
{

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

@ -60,6 +60,7 @@ public:
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 ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState);
@ -69,8 +70,8 @@ public:
virtual void AddMargin(nsIBox* aChild, nsSize& aSize);
virtual void AddMargin(nsSize& aSize, const nsMargin& aMargin);
virtual void AddLargestSize(nsSize& aSize, const nsSize& aToAdd);
virtual void AddSmallestSize(nsSize& aSize, const nsSize& aToAdd);
static void AddLargestSize(nsSize& aSize, const nsSize& aToAdd);
static void AddSmallestSize(nsSize& aSize, const nsSize& aToAdd);
};
#endif

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

@ -435,7 +435,12 @@ nsBoxLayoutState::RecycleFreedMemory(nsIPresShell* aShell, void* aMem)
nsresult
nsBoxLayoutState::GetPresShell(nsIPresShell** aShell)
{
return mPresContext->GetShell(aShell);
if (mPresContext)
return mPresContext->GetShell(aShell);
else {
*aShell = nsnull;
return NS_OK;
}
}
nsresult

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

@ -232,25 +232,6 @@ nsContainerBox::GetBoxAt(PRInt32 aIndex)
return nsnull;
}
PRInt32
nsContainerBox::GetIndexOf(nsIBox* aBox)
{
// find the frame to remove
nsIBox* child = mFirstChild;
PRInt32 count = 0;
while (child)
{
if (aBox == child) {
return count;
}
child->GetNextBox(&child);
count++;
}
return -1;
}
void
nsContainerBox::Remove(nsBoxLayoutState& aState, nsIFrame* aFrame)
{
@ -411,7 +392,7 @@ nsContainerBox::InitChildren(nsBoxLayoutState& aState, nsIFrame* aList)
CheckBoxOrder(aState);
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, aState, mFirstChild);
mLayoutManager->ChildrenSet(this, aState, mFirstChild);
}
@ -745,3 +726,24 @@ nsContainerBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)
return NS_OK;
}
NS_IMETHODIMP
nsContainerBox::GetIndexOf(nsIBox* aBox, PRInt32* aIndex)
{
nsIBox* child = mFirstChild;
PRInt32 count = 0;
while (child)
{
if (aBox == child) {
*aIndex = count;
return NS_OK;
}
child->GetNextBox(&child);
count++;
}
*aIndex = -1;
return NS_OK;
}

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

@ -61,10 +61,10 @@ public:
NS_IMETHOD GetAscent(nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex);
virtual nsIBox* GetBoxAt(PRInt32 aIndex);
virtual nsIBox* GetBox(nsIFrame* aFrame);
virtual PRInt32 GetIndexOf(nsIBox* aBox);
virtual PRInt32 GetChildCount();
virtual void ClearChildren(nsBoxLayoutState& aState);
virtual PRInt32 CreateBoxList(nsBoxLayoutState& aState, nsIFrame* aList, nsIBox*& first, nsIBox*& last);

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

@ -126,6 +126,7 @@ public:
NS_IMETHOD MarkStyleChange(nsBoxLayoutState& aState)=0;
NS_IMETHOD DumpBox(FILE* out)=0;
NS_IMETHOD ChildrenMustHaveWidgets(PRBool& aMust)=0;
NS_IMETHOD GetIndexOf(nsIBox* aChild, PRInt32* aIndex)=0;
static PRBool AddCSSPrefSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);
static PRBool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize);

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

@ -69,6 +69,7 @@ public:
NS_IMETHOD ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)=0;
NS_IMETHOD ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
NS_IMETHOD ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
NS_IMETHOD ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
NS_IMETHOD ChildBecameDirty(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChild)=0;
NS_IMETHOD BecameDirty(nsIBox* aBox, nsBoxLayoutState& aState)=0;
};

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

@ -92,7 +92,7 @@ nsSprocketLayout::nsSprocketLayout()
}
PRBool
nsSprocketLayout::IsHorizontal(nsIBox* aBox) const
nsSprocketLayout::IsHorizontal(nsIBox* aBox)
{
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);

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

@ -120,14 +120,17 @@ public:
nsSprocketLayout();
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 AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, PRBool aIsHorizontal);
static void AddCoord(nscoord& aCoord, nscoord aCoordToAdd);
protected:
virtual PRBool IsHorizontal(nsIBox* aBox) const;
virtual void SetLargestSize(nsSize& aSize1, const nsSize& aSize2, PRBool aIsHorizontal);
virtual void SetSmallestSize(nsSize& aSize1, const nsSize& aSize2, PRBool aIsHorizontal);
virtual void AddLargestSize(nsSize& aSize, const nsSize& aSizeToAdd, PRBool aIsHorizontal);
virtual void AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, PRBool aIsHorizontal);
virtual void AddCoord(nscoord& aCoord, nscoord aCoordToAdd);
virtual void ComputeChildsNextPosition(nsIBox* aBox,
nsIBox* aChild,

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

@ -65,9 +65,7 @@ public:
NS_IMETHOD GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
NS_IMETHOD GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nscoord& aAscent);
protected:
PRBool AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize);
static PRBool AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize);
private:
static nsIBoxLayout* gInstance;

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

@ -63,7 +63,12 @@ NS_NewTreeLayout( nsIPresShell* aPresShell, nsCOMPtr<nsIBoxLayout>& aNewLayout)
return NS_OK;
}
nsTreeLayout::nsTreeLayout(nsIPresShell* aPresShell):nsTempleLayout(aPresShell)
nsTreeLayout::nsTreeLayout(nsIPresShell* aPresShell):
#ifdef MOZ_GRID2
nsGridRowGroupLayout(aPresShell)
#else
nsTempleLayout(aPresShell)
#endif
{
}
@ -106,7 +111,12 @@ nsXULTreeSliceFrame* nsTreeLayout::GetRowFrame(nsIBox* aBox)
NS_IMETHODIMP
nsTreeLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
{
#ifdef MOZ_GRID2
nsresult rv = nsGridRowGroupLayout::GetPrefSize(aBox, aBoxLayoutState, aSize);
#else
nsresult rv = nsTempleLayout::GetPrefSize(aBox, aBoxLayoutState, aSize);
#endif
nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox);
if (frame) {
nscoord rowheight = frame->GetRowHeightTwips();
@ -134,7 +144,12 @@ nsTreeLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSiz
NS_IMETHODIMP
nsTreeLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
{
#ifdef MOZ_GRID2
nsresult rv = nsGridRowGroupLayout::GetMinSize(aBox, aBoxLayoutState, aSize);
#else
nsresult rv = nsTempleLayout::GetMinSize(aBox, aBoxLayoutState, aSize);
#endif
nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox);
if (frame) {
nscoord rowheight = frame->GetRowHeightTwips();
@ -162,7 +177,12 @@ nsTreeLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize
NS_IMETHODIMP
nsTreeLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
{
#ifdef MOZ_GRID2
nsresult rv = nsGridRowGroupLayout::GetMaxSize(aBox, aBoxLayoutState, aSize);
#else
nsresult rv = nsTempleLayout::GetMaxSize(aBox, aBoxLayoutState, aSize);
#endif
nsXULTreeOuterGroupFrame* frame = GetOuterFrame(aBox);
if (frame) {
nscoord rowheight = frame->GetRowHeightTwips();

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

@ -45,14 +45,23 @@
#ifndef nsTreeLayout_h___
#define nsTreeLayout_h___
#ifdef MOZ_GRID2
#include "nsGridRowGroupLayout.h"
#else
#include "nsTempleLayout.h"
#endif
#include "nsXULTreeOuterGroupFrame.h"
#include "nsXULTreeSliceFrame.h"
class nsIBox;
class nsBoxLayoutState;
#ifdef MOZ_GRID2
class nsTreeLayout : public nsGridRowGroupLayout
#else
class nsTreeLayout : public nsTempleLayout
#endif
{
public:
nsTreeLayout(nsIPresShell* aShell);

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

@ -46,7 +46,15 @@
#include "nsIMonument.h"
#include "nsIBoxLayout.h"
#include "nsMonumentLayout.h"
#ifdef MOZ_GRID2
#include "nsGrid.h"
#include "nsGridRow.h"
#else
#include "nsGridLayout.h"
#include "nsTempleLayout.h"
#endif
//
@ -126,8 +134,19 @@ nsXULTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
// Now find the nth column in the other temple.
nsCOMPtr<nsIBox> box(do_QueryInterface(mParent));
nsCOMPtr<nsIBoxLayout> lm;
#ifdef MOZ_GRID2
box->GetLayoutManager(getter_AddRefs(lm));
nsCOMPtr<nsIGridPart> part(do_QueryInterface(lm));
nsGrid* grid;
PRInt32 index;
part->GetGrid(box, &grid, &index);
nsIBox* splitBox = grid->GetColumnAt(i)->GetBox();
#else
box->GetLayoutManager(getter_AddRefs(lm));
nsCOMPtr<nsIMonument> mon(do_QueryInterface(lm));
nsTempleLayout* temple = nsnull;
nsIBox* templeBox = nsnull;
mon->GetOtherTemple(box, &temple, &templeBox);
@ -139,7 +158,7 @@ nsXULTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
PRInt32 currIndex = 0;
if (left)
i--;
do {
if (i < 0) break;
@ -156,6 +175,8 @@ nsXULTreeCellFrame::GetFrameForPoint(nsIPresContext* aPresContext,
nsIBox* splitBox = nsnull;
if (child)
child->GetNextBox(&splitBox);
#endif
nsIFrame* splitter = nsnull;
if (splitBox)
splitBox->QueryInterface(NS_GET_IID(nsIFrame), (void**)&splitter);

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

@ -55,7 +55,6 @@
#include "nsIServiceManager.h"
#include "nsIScrollableView.h"
#include "nsIMonument.h"
#include "nsTempleLayout.h"
#include "nsTreeLayout.h"
#include "nsITimer.h"
#include "nsIBindingManager.h"
@ -66,6 +65,12 @@
#include "nsIStyleContext.h"
#include "nsIDOMText.h"
#ifdef MOZ_GRID2
#include "nsGridRowGroupLayout.h"
#else
#include "nsTempleLayout.h"
#endif
#define TICK_FACTOR 50
// the longest amount of time that can go by before the use