Don't use a static nsTArray. Bug 369099, r=bernd, sr=roc

git-svn-id: svn://10.0.0.236/trunk@220057 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2007-02-13 16:23:19 +00:00
parent acd9d288db
commit cda6f2b142
3 changed files with 37 additions and 6 deletions

View File

@ -76,6 +76,7 @@
#include "nsXBLWindowKeyHandler.h"
#include "txMozillaXSLTProcessor.h"
#include "nsDOMStorage.h"
#include "nsCellMap.h"
#ifdef MOZ_XUL
#include "nsXULContentUtils.h"
@ -138,6 +139,12 @@ nsLayoutStatics::Initialize()
return rv;
}
rv = nsCellMap::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsCellMap");
return rv;
}
// Register all of our atoms once
nsCSSAnonBoxes::AddRefAtoms();
nsCSSPseudoClasses::AddRefAtoms();
@ -216,6 +223,7 @@ nsLayoutStatics::Shutdown()
#ifdef DEBUG
nsFrame::DisplayReflowShutdown();
#endif
nsCellMap::Shutdown();
// Release all of our atoms
nsColorNames::ReleaseTable();

View File

@ -42,7 +42,7 @@
#include "nsTableRowGroupFrame.h"
// Empty static array used for SafeElementAt() calls on mRows.
static nsCellMap::CellDataArray sEmptyRow;
static nsCellMap::CellDataArray * sEmptyRow;
// CellData
@ -1216,6 +1216,25 @@ nsCellMap::~nsCellMap()
}
}
/* static */
nsresult
nsCellMap::Init()
{
NS_ASSERTION(!sEmptyRow, "How did that happen?");
sEmptyRow = new nsCellMap::CellDataArray();
NS_ENSURE_TRUE(sEmptyRow, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}
/* static */
void
nsCellMap::Shutdown()
{
delete sEmptyRow;
sEmptyRow = nsnull;
}
nsTableCellFrame*
nsCellMap::GetCellFrame(PRInt32 aRowIndexIn,
PRInt32 aColIndexIn,
@ -1234,7 +1253,7 @@ nsCellMap::GetCellFrame(PRInt32 aRowIndexIn,
}
CellData* data =
mRows.SafeElementAt(rowIndex, sEmptyRow).SafeElementAt(colIndex);
mRows.SafeElementAt(rowIndex, *sEmptyRow).SafeElementAt(colIndex);
if (data) {
return data->GetCellFrame();
}
@ -1993,7 +2012,7 @@ nsCellMap::GetRowSpanForNewCell(nsTableCellFrame* aCellFrameToAdd,
PRBool nsCellMap::HasMoreThanOneCell(PRInt32 aRowIndex) const
{
const CellDataArray& row = mRows.SafeElementAt(aRowIndex, sEmptyRow);
const CellDataArray& row = mRows.SafeElementAt(aRowIndex, *sEmptyRow);
PRUint32 maxColIndex = row.Length();
PRUint32 count = 0;
PRUint32 colIndex;
@ -2010,7 +2029,7 @@ PRBool nsCellMap::HasMoreThanOneCell(PRInt32 aRowIndex) const
PRInt32
nsCellMap::GetNumCellsOriginatingInRow(PRInt32 aRowIndex) const
{
const CellDataArray& row = mRows.SafeElementAt(aRowIndex, sEmptyRow);
const CellDataArray& row = mRows.SafeElementAt(aRowIndex, *sEmptyRow);
PRUint32 count = 0;
PRUint32 maxColIndex = row.Length();
PRUint32 colIndex;
@ -2533,7 +2552,7 @@ nsCellMap::IsZeroColSpan(PRInt32 aRowIndex,
PRInt32 aColIndex) const
{
CellData* data =
mRows.SafeElementAt(aRowIndex, sEmptyRow).SafeElementAt(aColIndex);
mRows.SafeElementAt(aRowIndex, *sEmptyRow).SafeElementAt(aColIndex);
return data && data->IsZeroColSpan();
}
@ -2541,7 +2560,8 @@ CellData*
nsCellMap::GetDataAt(PRInt32 aMapRowIndex,
PRInt32 aColIndex) const
{
return mRows.SafeElementAt(aMapRowIndex, sEmptyRow).SafeElementAt(aColIndex);
return
mRows.SafeElementAt(aMapRowIndex, *sEmptyRow).SafeElementAt(aColIndex);
}
// only called if the cell at aMapRowIndex, aColIndex is null or dead

View File

@ -288,6 +288,9 @@ public:
*/
~nsCellMap();
static nsresult Init();
static void Shutdown();
nsCellMap* GetNextSibling() const;
void SetNextSibling(nsCellMap* aSibling);