mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
fixed a memory leak, and a null pointer dereference, having to do with collapsing borders
This commit is contained in:
parent
c1f02ff5b3
commit
334db030c0
@ -339,6 +339,21 @@ nsTableFrame::Init(nsIPresContext& aPresContext,
|
||||
|
||||
nsTableFrame::~nsTableFrame()
|
||||
{
|
||||
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
||||
{
|
||||
PRInt32 i=0;
|
||||
for ( ; i<4; i++)
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[i].ElementAt(0));
|
||||
while (border)
|
||||
{
|
||||
delete border;
|
||||
mBorderEdges.mEdges[i].RemoveElementAt(0);
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[i].ElementAt(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull!=mCellMap) {
|
||||
delete mCellMap;
|
||||
mCellMap = nsnull;
|
||||
@ -358,6 +373,7 @@ nsTableFrame::~nsTableFrame()
|
||||
delete mColCache;
|
||||
mColCache = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -903,7 +919,10 @@ void nsTableFrame::AppendLayoutData(nsVoidArray* aList, nsTableCellFrame* aTable
|
||||
void nsTableFrame::SetBorderEdgeLength(PRUint8 aSide, PRInt32 aIndex, nscoord aLength)
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(aIndex));
|
||||
border->mLength = aLength;
|
||||
if (border)
|
||||
{
|
||||
border->mLength = aLength;
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableFrame::DidComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
||||
@ -983,7 +1002,6 @@ void nsTableFrame::ComputeHorizontalCollapsingBorders(nsIPresContext& aPresConte
|
||||
PRInt32 rowCount = mCellMap->GetRowCount();
|
||||
if (aStartRowIndex>=rowCount)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeHorizontalCollapsingBorders");
|
||||
return; // we don't have the requested row yet
|
||||
}
|
||||
|
||||
@ -1027,7 +1045,6 @@ void nsTableFrame::ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext
|
||||
endRowIndex=rowCount-1;
|
||||
if (aStartRowIndex>=rowCount)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeVerticalCollapsingBorders");
|
||||
return; // we don't have the requested row yet
|
||||
}
|
||||
|
||||
@ -4748,15 +4765,15 @@ void nsTableFrame::GetTableBorderAt(nsMargin &aBorder, PRInt32 aRowIndex, PRInt3
|
||||
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(aRowIndex));
|
||||
if (border) {
|
||||
aBorder.left = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
||||
aBorder.right = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.top = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.bottom = border->mWidth;
|
||||
}
|
||||
if (border) {
|
||||
aBorder.left = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
||||
aBorder.right = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.top = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.bottom = border->mWidth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -805,6 +805,7 @@ public: /* ----- Cell Map public methods ----- */
|
||||
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
||||
PRBool RequiresPass1Layout();
|
||||
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
|
||||
/** Get the cell and associated data for a table cell from the frame's cellmap */
|
||||
@ -822,6 +823,7 @@ public: /* ----- Cell Map public methods ----- */
|
||||
|
||||
/*------------end of nsITableLayout methods -----------------------*/
|
||||
|
||||
|
||||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
void Dump(PRBool aDumpCols, PRBool aDumpCellMap);
|
||||
|
@ -339,6 +339,21 @@ nsTableFrame::Init(nsIPresContext& aPresContext,
|
||||
|
||||
nsTableFrame::~nsTableFrame()
|
||||
{
|
||||
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
||||
{
|
||||
PRInt32 i=0;
|
||||
for ( ; i<4; i++)
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[i].ElementAt(0));
|
||||
while (border)
|
||||
{
|
||||
delete border;
|
||||
mBorderEdges.mEdges[i].RemoveElementAt(0);
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[i].ElementAt(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull!=mCellMap) {
|
||||
delete mCellMap;
|
||||
mCellMap = nsnull;
|
||||
@ -358,6 +373,7 @@ nsTableFrame::~nsTableFrame()
|
||||
delete mColCache;
|
||||
mColCache = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -903,7 +919,10 @@ void nsTableFrame::AppendLayoutData(nsVoidArray* aList, nsTableCellFrame* aTable
|
||||
void nsTableFrame::SetBorderEdgeLength(PRUint8 aSide, PRInt32 aIndex, nscoord aLength)
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[aSide].ElementAt(aIndex));
|
||||
border->mLength = aLength;
|
||||
if (border)
|
||||
{
|
||||
border->mLength = aLength;
|
||||
}
|
||||
}
|
||||
|
||||
void nsTableFrame::DidComputeHorizontalCollapsingBorders(nsIPresContext& aPresContext,
|
||||
@ -983,7 +1002,6 @@ void nsTableFrame::ComputeHorizontalCollapsingBorders(nsIPresContext& aPresConte
|
||||
PRInt32 rowCount = mCellMap->GetRowCount();
|
||||
if (aStartRowIndex>=rowCount)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeHorizontalCollapsingBorders");
|
||||
return; // we don't have the requested row yet
|
||||
}
|
||||
|
||||
@ -1027,7 +1045,6 @@ void nsTableFrame::ComputeVerticalCollapsingBorders(nsIPresContext& aPresContext
|
||||
endRowIndex=rowCount-1;
|
||||
if (aStartRowIndex>=rowCount)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "aStartRowIndex>=rowCount in ComputeVerticalCollapsingBorders");
|
||||
return; // we don't have the requested row yet
|
||||
}
|
||||
|
||||
@ -4748,15 +4765,15 @@ void nsTableFrame::GetTableBorderAt(nsMargin &aBorder, PRInt32 aRowIndex, PRInt3
|
||||
if (NS_STYLE_BORDER_COLLAPSE==GetBorderCollapseStyle())
|
||||
{
|
||||
nsBorderEdge *border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_LEFT].ElementAt(aRowIndex));
|
||||
if (border) {
|
||||
aBorder.left = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
||||
aBorder.right = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.top = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.bottom = border->mWidth;
|
||||
}
|
||||
if (border) {
|
||||
aBorder.left = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_RIGHT].ElementAt(aRowIndex));
|
||||
aBorder.right = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.top = border->mWidth;
|
||||
border = (nsBorderEdge *)(mBorderEdges.mEdges[NS_SIDE_TOP].ElementAt(aColIndex));
|
||||
aBorder.bottom = border->mWidth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -805,6 +805,7 @@ public: /* ----- Cell Map public methods ----- */
|
||||
/** returns PR_TRUE if table layout requires a preliminary pass over the content */
|
||||
PRBool RequiresPass1Layout();
|
||||
|
||||
|
||||
/*---------------- nsITableLayout methods ------------------------*/
|
||||
|
||||
/** Get the cell and associated data for a table cell from the frame's cellmap */
|
||||
@ -822,6 +823,7 @@ public: /* ----- Cell Map public methods ----- */
|
||||
|
||||
/*------------end of nsITableLayout methods -----------------------*/
|
||||
|
||||
|
||||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
void Dump(PRBool aDumpCols, PRBool aDumpCellMap);
|
||||
|
Loading…
Reference in New Issue
Block a user