Moved ContentDeleted() document notification code to the style system which

generates the reflow command
This commit is contained in:
troy@netscape.com
1998-09-25 05:13:06 +00:00
parent a6caa3c0e7
commit e78f443a85
32 changed files with 836 additions and 1399 deletions

View File

@@ -140,99 +140,6 @@ NS_METHOD nsHTMLContainerFrame::GetCursorAndContentAt(nsIPresContext& aPresConte
return NS_OK;
}
NS_IMETHODIMP
nsHTMLContainerFrame::ContentDeleted(nsIPresShell* aShell,
nsIPresContext* aPresContext,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInParent)
{
// Find the frame that precedes the deletion point
nsHTMLContainerFrame* flow;
nsIFrame* deadFrame;
nsIFrame* prevSibling;
if (aIndexInParent > 0) {
nsIContent* precedingContent;
aContainer->ChildAt(aIndexInParent - 1, precedingContent);
prevSibling = aShell->FindFrameWithContent(precedingContent);
NS_RELEASE(precedingContent);
// The frame may have a next-in-flow. Get the last-in-flow
nsIFrame* nextInFlow;
do {
prevSibling->GetNextInFlow(nextInFlow);
if (nsnull != nextInFlow) {
prevSibling = nextInFlow;
}
} while (nsnull != nextInFlow);
// Get the dead frame (maybe)
prevSibling->GetGeometricParent((nsIFrame*&)flow);
prevSibling->GetNextSibling(deadFrame);
if (nsnull == deadFrame) {
// The deadFrame must be prevSibling's parent's next-in-flows
// first frame. Therefore it doesn't have a prevSibling.
flow = (nsHTMLContainerFrame*) flow->mNextInFlow;
if (nsnull != flow) {
deadFrame = flow->mFirstChild;
}
prevSibling = nsnull;
}
}
else {
prevSibling = nsnull;
flow = this;
deadFrame = flow->mFirstChild;
}
NS_ASSERTION(nsnull != deadFrame, "yikes! couldn't find frame");
if (nsnull == deadFrame) {
return NS_OK;
}
// Generate a reflow command
nsIReflowCommand* cmd;
nsresult rv = NS_NewHTMLReflowCommand(&cmd, flow,
nsIReflowCommand::FrameDeleted);
if (NS_OK != rv) {
return rv;
}
aShell->AppendReflowCommand(cmd);
NS_RELEASE(cmd);
// Take the frame away; Note that we also have to take away any
// continuations so we loop here until deadFrame is nsnull.
while (nsnull != deadFrame) {
// Remove frame from sibling list
nsIFrame* nextSib;
deadFrame->GetNextSibling(nextSib);
if (nsnull != prevSibling) {
prevSibling->SetNextSibling(nextSib);
}
else {
flow->mFirstChild = nextSib;
}
// Break frame out of its flow and then destroy it
nsIFrame* nextInFlow;
deadFrame->GetNextInFlow(nextInFlow);
deadFrame->BreakFromNextFlow();
deadFrame->DeleteFrame(*aPresContext);
deadFrame = nextInFlow;
if (nsnull != deadFrame) {
// Get the parent of deadFrame's continuation
deadFrame->GetGeometricParent((nsIFrame*&) flow);
// When we move to a next-in-flow then the deadFrame will be the
// first child of the new parent. Therefore we know that
// prevSibling will be null.
prevSibling = nsnull;
}
}
return rv;
}
nsPlaceholderFrame*
nsHTMLContainerFrame::CreatePlaceholderFrame(nsIPresContext& aPresContext,
nsIFrame* aFloatedFrame)