bug 157915 - Use the parent of the continued frame when calling DeleteChildsNextInFlow. sr=kin, r=alexsavulov

This commit is contained in:
karnaze%netscape.com 2002-09-24 22:13:20 +00:00
Родитель 0757f184a7
Коммит d71ccf1e46
12 изменённых файлов: 100 добавлений и 38 удалений

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

@ -975,7 +975,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
state.mOverflowFloaters.GetLength(), PR_FALSE);
if (!newLine)
return NS_ERROR_OUT_OF_MEMORY;
state.mOverflowFloaters.SetFrames(nsnull);
mLines.push_back(newLine);
nsLineList::iterator nextToLastLine = ----end_lines();
PushLines(state, nextToLastLine);
@ -5281,11 +5280,17 @@ nsBlockFrame::DeleteChildsNextInFlow(nsIPresContext* aPresContext,
nsIFrame* aChild)
{
#ifdef DEBUG
// out-of-flow and placeholders frames don't satisfy the IsChild condition because
// DeleteChildsNextInFlow needs to be called on the parent of the next-in-flow
nsFrameState childState;
aChild->GetFrameState(&childState);
NS_PRECONDITION((childState & NS_FRAME_OUT_OF_FLOW) || IsChild(aPresContext, aChild),
"bad geometric parent");
nsCOMPtr<nsIAtom> frameType;
aChild->GetFrameType(getter_AddRefs(frameType));
if ((nsLayoutAtoms::placeholderFrame != frameType) && !(childState & NS_FRAME_OUT_OF_FLOW)) {
NS_PRECONDITION(IsChild(aPresContext, aChild), "bad geometric parent");
}
#endif
nsIFrame* nextInFlow;
aChild->GetNextInFlow(&nextInFlow);
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
@ -5321,9 +5326,10 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
nsIFrame* nextInFlow;
aPlaceholder->GetNextInFlow(&nextInFlow);
if (nextInFlow) {
// Use nextInFlow's parent since it always will be able to find nextInFlow.
// If aPlaceholder's parent is an inline, nextInFlow's will be a block.
nsHTMLContainerFrame* parent;
aPlaceholder->GetParent((nsIFrame**)&parent);
NS_ASSERTION(parent, "no parent");
nextInFlow->GetParent((nsIFrame**)&parent);
parent->DeleteChildsNextInFlow(aState.mPresContext, aPlaceholder);
}
// Reflow the floater.

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

@ -199,6 +199,11 @@ public:
inline nscoord GetAscent() { return mAscent; }
// Create a contination for aPlaceholder and its out of flow frame and
// add it to the list of overflow floaters
nsresult SplitPlaceholder(nsBlockReflowState& aState,
nsIFrame& aPlaceholder);
protected:
nsBlockFrame();
virtual ~nsBlockFrame();
@ -428,11 +433,6 @@ protected:
nsIFrame* aLastPlaceholder,
PRBool& aKeepReflowGoing);
// Create a contination for aPlaceholder and its out of flow frame and
// add it to the list of overflow floaters
nsresult SplitPlaceholder(nsBlockReflowState& aState,
nsIFrame& aPlaceholder);
nsresult SplitLine(nsBlockReflowState& aState,
nsLineLayout& aLineLayout,
line_iterator aLine,

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

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsInlineFrame.h"
#include "nsBlockFrame.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLParts.h"
#include "nsIStyleContext.h"
@ -784,16 +785,24 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext,
}
}
else if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
nsIFrame* newFrame;
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
if (NS_FAILED(rv)) {
return rv;
nsCOMPtr<nsIAtom> frameType;
aFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::placeholderFrame == frameType) {
nsBlockReflowState* blockRS = lineLayout->mBlockRS;
blockRS->mBlock->SplitPlaceholder(*blockRS, *aFrame);
}
if (!reflowingFirstLetter) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
if (nsnull != nextFrame) {
PushFrames(aPresContext, nextFrame, aFrame);
else {
nsIFrame* newFrame;
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
if (NS_FAILED(rv)) {
return rv;
}
if (!reflowingFirstLetter) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
if (nsnull != nextFrame) {
PushFrames(aPresContext, nextFrame, aFrame);
}
}
}
}

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

@ -272,6 +272,10 @@ protected:
nsSpaceManager* mSpaceManager;
const nsStyleText* mStyleText; // for the block
const nsHTMLReflowState* mBlockReflowState;
// XXX remove this when landing bug 154892 (splitting absolute positioned frames)
friend class nsInlineFrame;
nsBlockReflowState* mBlockRS;/* XXX hack! */
nsCompatibility mCompatMode;
nscoord mMinLineHeight;

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

@ -57,6 +57,15 @@ NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
return NS_OK;
}
// These are useful for debugging
nsPlaceholderFrame::nsPlaceholderFrame()
{
}
nsPlaceholderFrame::~nsPlaceholderFrame()
{
}
NS_IMETHODIMP
nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -160,4 +169,5 @@ nsPlaceholderFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
*aResult = sizeof(*this);
return NS_OK;
}
#endif

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

@ -51,6 +51,8 @@ public:
* Create a new placeholder frame
*/
friend nsresult NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsIFrame** aInstancePtrResult);
nsPlaceholderFrame();
virtual ~nsPlaceholderFrame();
// Get/Set the associated out of flow frame
nsIFrame* GetOutOfFlowFrame() const {return mOutOfFlowFrame;}

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

@ -975,7 +975,6 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
state.mOverflowFloaters.GetLength(), PR_FALSE);
if (!newLine)
return NS_ERROR_OUT_OF_MEMORY;
state.mOverflowFloaters.SetFrames(nsnull);
mLines.push_back(newLine);
nsLineList::iterator nextToLastLine = ----end_lines();
PushLines(state, nextToLastLine);
@ -5281,11 +5280,17 @@ nsBlockFrame::DeleteChildsNextInFlow(nsIPresContext* aPresContext,
nsIFrame* aChild)
{
#ifdef DEBUG
// out-of-flow and placeholders frames don't satisfy the IsChild condition because
// DeleteChildsNextInFlow needs to be called on the parent of the next-in-flow
nsFrameState childState;
aChild->GetFrameState(&childState);
NS_PRECONDITION((childState & NS_FRAME_OUT_OF_FLOW) || IsChild(aPresContext, aChild),
"bad geometric parent");
nsCOMPtr<nsIAtom> frameType;
aChild->GetFrameType(getter_AddRefs(frameType));
if ((nsLayoutAtoms::placeholderFrame != frameType) && !(childState & NS_FRAME_OUT_OF_FLOW)) {
NS_PRECONDITION(IsChild(aPresContext, aChild), "bad geometric parent");
}
#endif
nsIFrame* nextInFlow;
aChild->GetNextInFlow(&nextInFlow);
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
@ -5321,9 +5326,10 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
nsIFrame* nextInFlow;
aPlaceholder->GetNextInFlow(&nextInFlow);
if (nextInFlow) {
// Use nextInFlow's parent since it always will be able to find nextInFlow.
// If aPlaceholder's parent is an inline, nextInFlow's will be a block.
nsHTMLContainerFrame* parent;
aPlaceholder->GetParent((nsIFrame**)&parent);
NS_ASSERTION(parent, "no parent");
nextInFlow->GetParent((nsIFrame**)&parent);
parent->DeleteChildsNextInFlow(aState.mPresContext, aPlaceholder);
}
// Reflow the floater.

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

@ -199,6 +199,11 @@ public:
inline nscoord GetAscent() { return mAscent; }
// Create a contination for aPlaceholder and its out of flow frame and
// add it to the list of overflow floaters
nsresult SplitPlaceholder(nsBlockReflowState& aState,
nsIFrame& aPlaceholder);
protected:
nsBlockFrame();
virtual ~nsBlockFrame();
@ -428,11 +433,6 @@ protected:
nsIFrame* aLastPlaceholder,
PRBool& aKeepReflowGoing);
// Create a contination for aPlaceholder and its out of flow frame and
// add it to the list of overflow floaters
nsresult SplitPlaceholder(nsBlockReflowState& aState,
nsIFrame& aPlaceholder);
nsresult SplitLine(nsBlockReflowState& aState,
nsLineLayout& aLineLayout,
line_iterator aLine,

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

@ -36,6 +36,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsInlineFrame.h"
#include "nsBlockFrame.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLParts.h"
#include "nsIStyleContext.h"
@ -784,16 +785,24 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext,
}
}
else if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
nsIFrame* newFrame;
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
if (NS_FAILED(rv)) {
return rv;
nsCOMPtr<nsIAtom> frameType;
aFrame->GetFrameType(getter_AddRefs(frameType));
if (nsLayoutAtoms::placeholderFrame == frameType) {
nsBlockReflowState* blockRS = lineLayout->mBlockRS;
blockRS->mBlock->SplitPlaceholder(*blockRS, *aFrame);
}
if (!reflowingFirstLetter) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
if (nsnull != nextFrame) {
PushFrames(aPresContext, nextFrame, aFrame);
else {
nsIFrame* newFrame;
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
if (NS_FAILED(rv)) {
return rv;
}
if (!reflowingFirstLetter) {
nsIFrame* nextFrame;
aFrame->GetNextSibling(&nextFrame);
if (nsnull != nextFrame) {
PushFrames(aPresContext, nextFrame, aFrame);
}
}
}
}

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

@ -272,6 +272,10 @@ protected:
nsSpaceManager* mSpaceManager;
const nsStyleText* mStyleText; // for the block
const nsHTMLReflowState* mBlockReflowState;
// XXX remove this when landing bug 154892 (splitting absolute positioned frames)
friend class nsInlineFrame;
nsBlockReflowState* mBlockRS;/* XXX hack! */
nsCompatibility mCompatMode;
nscoord mMinLineHeight;

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

@ -57,6 +57,15 @@ NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
return NS_OK;
}
// These are useful for debugging
nsPlaceholderFrame::nsPlaceholderFrame()
{
}
nsPlaceholderFrame::~nsPlaceholderFrame()
{
}
NS_IMETHODIMP
nsPlaceholderFrame::Reflow(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
@ -160,4 +169,5 @@ nsPlaceholderFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
*aResult = sizeof(*this);
return NS_OK;
}
#endif

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

@ -51,6 +51,8 @@ public:
* Create a new placeholder frame
*/
friend nsresult NS_NewPlaceholderFrame(nsIPresShell* aPresShell, nsIFrame** aInstancePtrResult);
nsPlaceholderFrame();
virtual ~nsPlaceholderFrame();
// Get/Set the associated out of flow frame
nsIFrame* GetOutOfFlowFrame() const {return mOutOfFlowFrame;}