PDT+ bug 28341 - Destroy caption frame when outer table frame is destroyed. Add caption to outer frame rather than inner frame. r=troy, a=rickg

This commit is contained in:
karnaze@netscape.com
2000-03-02 06:09:37 +00:00
parent e5f6b3e10d
commit 9c252d135d
9 changed files with 107 additions and 26 deletions

View File

@@ -1402,12 +1402,6 @@ nsCSSFrameConstructor::ConstructTableCaptionFrame(nsIPresShell* aPres
nsLayoutAtoms::floaterList, nsLayoutAtoms::floaterList,
aState.mFloatedItems.childList); aState.mFloatedItems.childList);
} }
if (outerFrame) {
outerFrame->SetInitialChildList(aPresContext, nsLayoutAtoms::captionList,
aNewCaptionFrame);
}
return rv; return rv;
} }
@@ -5096,7 +5090,19 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell,
// the next 5 cases are only relevant if the parent is not a table, ConstructTableFrame handles children // the next 5 cases are only relevant if the parent is not a table, ConstructTableFrame handles children
case NS_STYLE_DISPLAY_TABLE_CAPTION: case NS_STYLE_DISPLAY_TABLE_CAPTION:
{ {
rv = ConstructTableCaptionFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, // aParentFrame may be an inner table frame rather than an outer frame
// In this case we need to get the outer frame.
nsIFrame* parentFrame = aParentFrame;
nsIFrame* outerFrame = nsnull;
aParentFrame->GetParent(&outerFrame);
nsCOMPtr<nsIAtom> frameType;
if (outerFrame) {
outerFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::tableOuterFrame == frameType.get()) {
parentFrame = outerFrame;
}
}
rv = ConstructTableCaptionFrame(aPresShell, aPresContext, aState, aContent, parentFrame,
aStyleContext, newFrame, ignore, tableCreator); aStyleContext, newFrame, ignore, tableCreator);
aFrameItems.AddChild(newFrame); aFrameItems.AddChild(newFrame);
return rv; return rv;

View File

@@ -1402,12 +1402,6 @@ nsCSSFrameConstructor::ConstructTableCaptionFrame(nsIPresShell* aPres
nsLayoutAtoms::floaterList, nsLayoutAtoms::floaterList,
aState.mFloatedItems.childList); aState.mFloatedItems.childList);
} }
if (outerFrame) {
outerFrame->SetInitialChildList(aPresContext, nsLayoutAtoms::captionList,
aNewCaptionFrame);
}
return rv; return rv;
} }
@@ -5096,7 +5090,19 @@ nsCSSFrameConstructor::ConstructFrameByDisplayType(nsIPresShell* aPresShell,
// the next 5 cases are only relevant if the parent is not a table, ConstructTableFrame handles children // the next 5 cases are only relevant if the parent is not a table, ConstructTableFrame handles children
case NS_STYLE_DISPLAY_TABLE_CAPTION: case NS_STYLE_DISPLAY_TABLE_CAPTION:
{ {
rv = ConstructTableCaptionFrame(aPresShell, aPresContext, aState, aContent, aParentFrame, // aParentFrame may be an inner table frame rather than an outer frame
// In this case we need to get the outer frame.
nsIFrame* parentFrame = aParentFrame;
nsIFrame* outerFrame = nsnull;
aParentFrame->GetParent(&outerFrame);
nsCOMPtr<nsIAtom> frameType;
if (outerFrame) {
outerFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::tableOuterFrame == frameType.get()) {
parentFrame = outerFrame;
}
}
rv = ConstructTableCaptionFrame(aPresShell, aPresContext, aState, aContent, parentFrame,
aStyleContext, newFrame, ignore, tableCreator); aStyleContext, newFrame, ignore, tableCreator);
aFrameItems.AddChild(newFrame); aFrameItems.AddChild(newFrame);
return rv; return rv;

View File

@@ -37,6 +37,8 @@
#include "nsHTMLParts.h" #include "nsHTMLParts.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
/* ----------- nsTableCaptionFrame ---------- */
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0 #define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0
// caption frame // caption frame
@@ -46,6 +48,20 @@ nsTableCaptionFrame::nsTableCaptionFrame()
SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE); SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE);
} }
nsTableCaptionFrame::~nsTableCaptionFrame()
{
}
NS_IMETHODIMP
nsTableOuterFrame::Destroy(nsIPresContext* aPresContext)
{
if (mCaptionFrame) {
mCaptionFrame->Destroy(aPresContext);
}
return nsHTMLContainerFrame::Destroy(aPresContext);
}
NS_IMETHODIMP NS_IMETHODIMP
nsTableCaptionFrame::GetFrameType(nsIAtom** aType) const nsTableCaptionFrame::GetFrameType(nsIAtom** aType) const
{ {
@@ -117,13 +133,19 @@ struct OuterTableReflowState {
} }
}; };
/* ----------- nsTableOuterFrame ---------- */ /* ----------- nsTableOuterFrame ---------- */
NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
nsTableOuterFrame::nsTableOuterFrame()
{
}
nsTableOuterFrame::~nsTableOuterFrame()
{
}
nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{ {
if (NULL == aInstancePtr) { if (NULL == aInstancePtr) {

View File

@@ -32,10 +32,14 @@ struct nsStyleTable;
class nsTableCaptionFrame : public nsBlockFrame class nsTableCaptionFrame : public nsBlockFrame
{ {
public: public:
// nsISupports // nsISupports
nsTableCaptionFrame();
NS_IMETHOD GetFrameType(nsIAtom** aType) const; NS_IMETHOD GetFrameType(nsIAtom** aType) const;
friend nsresult NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
protected:
nsTableCaptionFrame();
virtual ~nsTableCaptionFrame();
}; };
@@ -60,8 +64,7 @@ public:
* *
* @return NS_OK if the frame was properly allocated, otherwise an error code * @return NS_OK if the frame was properly allocated, otherwise an error code
*/ */
friend nsresult friend nsresult NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
NS_IMETHOD Init(nsIPresContext* aPresContext, NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent, nsIContent* aContent,
@@ -69,6 +72,8 @@ public:
nsIStyleContext* aContext, nsIStyleContext* aContext,
nsIFrame* aPrevInFlow); nsIFrame* aPrevInFlow);
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD AdjustZeroWidth(); NS_IMETHOD AdjustZeroWidth();
/** @see nsIFrame::SetInitialChildList */ /** @see nsIFrame::SetInitialChildList */
@@ -151,6 +156,9 @@ public:
protected: protected:
nsTableOuterFrame();
virtual ~nsTableOuterFrame();
/** Always returns 0, since the outer table frame has no border of its own /** Always returns 0, since the outer table frame has no border of its own
* The inner table frame can answer this question in a meaningful way. * The inner table frame can answer this question in a meaningful way.
* @see nsHTMLContainerFrame::GetSkipSides */ * @see nsHTMLContainerFrame::GetSkipSides */

View File

@@ -0,0 +1,8 @@
The bug causes a crash when the page is destroyed
<BR>
<TABLE>
<CAPTION>
<IMG SRC="../images/animated.gif">
</CAPTION>
<TR><TD>foo</TD></TR>
</TABLE>

View File

@@ -127,6 +127,7 @@ file:///s|/mozilla/layout/html/tests/table/bugs/bug2684.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug2757.html file:///s|/mozilla/layout/html/tests/table/bugs/bug2757.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug2763.html file:///s|/mozilla/layout/html/tests/table/bugs/bug2763.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug2773.html file:///s|/mozilla/layout/html/tests/table/bugs/bug2773.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug28341.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug2886.html file:///s|/mozilla/layout/html/tests/table/bugs/bug2886.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug2886-2.html file:///s|/mozilla/layout/html/tests/table/bugs/bug2886-2.html
file:///s|/mozilla/layout/html/tests/table/bugs/bug28928.html file:///s|/mozilla/layout/html/tests/table/bugs/bug28928.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -37,6 +37,8 @@
#include "nsHTMLParts.h" #include "nsHTMLParts.h"
#include "nsIPresShell.h" #include "nsIPresShell.h"
/* ----------- nsTableCaptionFrame ---------- */
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0 #define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0
// caption frame // caption frame
@@ -46,6 +48,20 @@ nsTableCaptionFrame::nsTableCaptionFrame()
SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE); SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE);
} }
nsTableCaptionFrame::~nsTableCaptionFrame()
{
}
NS_IMETHODIMP
nsTableOuterFrame::Destroy(nsIPresContext* aPresContext)
{
if (mCaptionFrame) {
mCaptionFrame->Destroy(aPresContext);
}
return nsHTMLContainerFrame::Destroy(aPresContext);
}
NS_IMETHODIMP NS_IMETHODIMP
nsTableCaptionFrame::GetFrameType(nsIAtom** aType) const nsTableCaptionFrame::GetFrameType(nsIAtom** aType) const
{ {
@@ -117,13 +133,19 @@ struct OuterTableReflowState {
} }
}; };
/* ----------- nsTableOuterFrame ---------- */ /* ----------- nsTableOuterFrame ---------- */
NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
nsTableOuterFrame::nsTableOuterFrame()
{
}
nsTableOuterFrame::~nsTableOuterFrame()
{
}
nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{ {
if (NULL == aInstancePtr) { if (NULL == aInstancePtr) {

View File

@@ -32,10 +32,14 @@ struct nsStyleTable;
class nsTableCaptionFrame : public nsBlockFrame class nsTableCaptionFrame : public nsBlockFrame
{ {
public: public:
// nsISupports // nsISupports
nsTableCaptionFrame();
NS_IMETHOD GetFrameType(nsIAtom** aType) const; NS_IMETHOD GetFrameType(nsIAtom** aType) const;
friend nsresult NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
protected:
nsTableCaptionFrame();
virtual ~nsTableCaptionFrame();
}; };
@@ -60,8 +64,7 @@ public:
* *
* @return NS_OK if the frame was properly allocated, otherwise an error code * @return NS_OK if the frame was properly allocated, otherwise an error code
*/ */
friend nsresult friend nsresult NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
NS_IMETHOD Init(nsIPresContext* aPresContext, NS_IMETHOD Init(nsIPresContext* aPresContext,
nsIContent* aContent, nsIContent* aContent,
@@ -69,6 +72,8 @@ public:
nsIStyleContext* aContext, nsIStyleContext* aContext,
nsIFrame* aPrevInFlow); nsIFrame* aPrevInFlow);
NS_IMETHOD Destroy(nsIPresContext* aPresContext);
NS_IMETHOD AdjustZeroWidth(); NS_IMETHOD AdjustZeroWidth();
/** @see nsIFrame::SetInitialChildList */ /** @see nsIFrame::SetInitialChildList */
@@ -151,6 +156,9 @@ public:
protected: protected:
nsTableOuterFrame();
virtual ~nsTableOuterFrame();
/** Always returns 0, since the outer table frame has no border of its own /** Always returns 0, since the outer table frame has no border of its own
* The inner table frame can answer this question in a meaningful way. * The inner table frame can answer this question in a meaningful way.
* @see nsHTMLContainerFrame::GetSkipSides */ * @see nsHTMLContainerFrame::GetSkipSides */