fixed a nasty bug where some incremental reflow cases of a table with collapsing borders would crash.

One example of the crash is changing the style of a cell via DOM.
Also fixed an error in the API of nsTableColFrame
This commit is contained in:
buster%netscape.com 1999-01-29 18:49:32 +00:00
parent a2de6c3901
commit 3f9d48c279
6 changed files with 76 additions and 54 deletions

View File

@ -54,10 +54,10 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
/** return the index of the column the col represents. always >= 0 */
virtual int GetColumnIndex ();
virtual PRInt32 GetColumnIndex ();
/** return the number of the columns the col represents. always >= 0 */
virtual int GetSpan ();
virtual PRInt32 GetSpan ();
/** set the index of the column this content object represents. must be >= 0 */
virtual void SetColumnIndex (int aColIndex);
@ -115,7 +115,7 @@ inline void nsTableColFrame::InitColFrame(PRInt32 aColIndex)
mColIndex = aColIndex;
}
inline nsTableColFrame::GetColumnIndex()
inline PRInt32 nsTableColFrame::GetColumnIndex()
{ return mColIndex; }
inline void nsTableColFrame::SetColumnIndex (int aColIndex)

View File

@ -1270,6 +1270,8 @@ void nsTableFrame::ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext
if (nsnull==cellMap)
return; // no info yet, so nothing useful to do
CacheColFramesInCellMap();
// compute all the collapsing border values for the entire table
// XXX: we have to make this more incremental!
const nsStyleTable *tableStyle=nsnull;
@ -3976,33 +3978,12 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext,
}
mColCache = new ColumnInfoCache(GetColCount());
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame)
{ // in this loop, we cache column info and set column style info from cells
nsTableColFrame *colFrame=nsnull;
childFrame->FirstChild(nsnull, (nsIFrame *&)colFrame);
while (nsnull!=colFrame)
{
PRInt32 repeat = colFrame->GetSpan();
for (PRInt32 i=0; i<repeat; i++)
{
nsTableColFrame *cachedColFrame = mCellMap->GetColumnFrame(colIndex+i);
if (nsnull==cachedColFrame)
{
if (gsDebug) printf("TIF BCB: adding column frame %p\n", colFrame);
mCellMap->AppendColumnFrame(colFrame);
}
colIndex++;
}
colFrame->GetNextSibling((nsIFrame *&)colFrame);
}
childFrame->GetNextSibling(childFrame);
}
CacheColFramesInCellMap();
// handle rowgroups
childFrame = mFrames.FirstChild();
nsIFrame * childFrame = mFrames.FirstChild();
while (nsnull!=childFrame)
{
{ // in this loop, set column style info from cells
const nsStyleDisplay *childDisplay;
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
@ -4070,6 +4051,34 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext,
mColumnCacheValid=PR_TRUE;
}
void nsTableFrame::CacheColFramesInCellMap()
{
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame)
{ // in this loop, we cache column info
nsTableColFrame *colFrame=nsnull;
childFrame->FirstChild(nsnull, (nsIFrame *&)colFrame);
while (nsnull!=colFrame)
{
PRInt32 colIndex = colFrame->GetColumnIndex();
PRInt32 repeat = colFrame->GetSpan();
for (PRInt32 i=0; i<repeat; i++)
{
nsTableColFrame *cachedColFrame = mCellMap->GetColumnFrame(colIndex+i);
if (nsnull==cachedColFrame)
{
if (gsDebug)
printf("TIF BCB: adding column frame %p\n", colFrame);
mCellMap->AppendColumnFrame(colFrame);
}
colIndex++;
}
colFrame->GetNextSibling((nsIFrame *&)colFrame);
}
childFrame->GetNextSibling(childFrame);
}
}
void nsTableFrame::InvalidateColumnWidths()
{
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();

View File

@ -697,6 +697,8 @@ protected:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual void CacheColFramesInCellMap();
/** called every time we discover we have a new cell to add to the table.
* This could be because we got actual cell content, because of rowspan/colspan attributes, etc.
* This method changes mCellMap as necessary to account for the new cell.

View File

@ -54,10 +54,10 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
/** return the index of the column the col represents. always >= 0 */
virtual int GetColumnIndex ();
virtual PRInt32 GetColumnIndex ();
/** return the number of the columns the col represents. always >= 0 */
virtual int GetSpan ();
virtual PRInt32 GetSpan ();
/** set the index of the column this content object represents. must be >= 0 */
virtual void SetColumnIndex (int aColIndex);
@ -115,7 +115,7 @@ inline void nsTableColFrame::InitColFrame(PRInt32 aColIndex)
mColIndex = aColIndex;
}
inline nsTableColFrame::GetColumnIndex()
inline PRInt32 nsTableColFrame::GetColumnIndex()
{ return mColIndex; }
inline void nsTableColFrame::SetColumnIndex (int aColIndex)

View File

@ -1270,6 +1270,8 @@ void nsTableFrame::ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext
if (nsnull==cellMap)
return; // no info yet, so nothing useful to do
CacheColFramesInCellMap();
// compute all the collapsing border values for the entire table
// XXX: we have to make this more incremental!
const nsStyleTable *tableStyle=nsnull;
@ -3976,33 +3978,12 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext,
}
mColCache = new ColumnInfoCache(GetColCount());
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame)
{ // in this loop, we cache column info and set column style info from cells
nsTableColFrame *colFrame=nsnull;
childFrame->FirstChild(nsnull, (nsIFrame *&)colFrame);
while (nsnull!=colFrame)
{
PRInt32 repeat = colFrame->GetSpan();
for (PRInt32 i=0; i<repeat; i++)
{
nsTableColFrame *cachedColFrame = mCellMap->GetColumnFrame(colIndex+i);
if (nsnull==cachedColFrame)
{
if (gsDebug) printf("TIF BCB: adding column frame %p\n", colFrame);
mCellMap->AppendColumnFrame(colFrame);
}
colIndex++;
}
colFrame->GetNextSibling((nsIFrame *&)colFrame);
}
childFrame->GetNextSibling(childFrame);
}
CacheColFramesInCellMap();
// handle rowgroups
childFrame = mFrames.FirstChild();
nsIFrame * childFrame = mFrames.FirstChild();
while (nsnull!=childFrame)
{
{ // in this loop, set column style info from cells
const nsStyleDisplay *childDisplay;
childFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)childDisplay));
if (PR_TRUE==IsRowGroup(childDisplay->mDisplay))
@ -4070,6 +4051,34 @@ void nsTableFrame::BuildColumnCache( nsIPresContext& aPresContext,
mColumnCacheValid=PR_TRUE;
}
void nsTableFrame::CacheColFramesInCellMap()
{
nsIFrame * childFrame = mColGroups.FirstChild();
while (nsnull!=childFrame)
{ // in this loop, we cache column info
nsTableColFrame *colFrame=nsnull;
childFrame->FirstChild(nsnull, (nsIFrame *&)colFrame);
while (nsnull!=colFrame)
{
PRInt32 colIndex = colFrame->GetColumnIndex();
PRInt32 repeat = colFrame->GetSpan();
for (PRInt32 i=0; i<repeat; i++)
{
nsTableColFrame *cachedColFrame = mCellMap->GetColumnFrame(colIndex+i);
if (nsnull==cachedColFrame)
{
if (gsDebug)
printf("TIF BCB: adding column frame %p\n", colFrame);
mCellMap->AppendColumnFrame(colFrame);
}
colIndex++;
}
colFrame->GetNextSibling((nsIFrame *&)colFrame);
}
childFrame->GetNextSibling(childFrame);
}
}
void nsTableFrame::InvalidateColumnWidths()
{
nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow();

View File

@ -697,6 +697,8 @@ protected:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
virtual void CacheColFramesInCellMap();
/** called every time we discover we have a new cell to add to the table.
* This could be because we got actual cell content, because of rowspan/colspan attributes, etc.
* This method changes mCellMap as necessary to account for the new cell.