Added NULL pointer check for frame manager in DeletingFrameSubtree()
git-svn-id: svn://10.0.0.236/trunk@42259 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -4511,63 +4511,67 @@ DeletingFrameSubtree(nsIPresContext* aPresContext,
|
||||
nsIFrame* aRemovedFrame,
|
||||
nsIFrame* aFrame)
|
||||
{
|
||||
// Remove the mapping from the content object to its frame
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
aFrameManager->SetPrimaryFrameFor(content, nsnull);
|
||||
// If there's no frame manager it's probably because the pres shell is
|
||||
// being destroyed
|
||||
if (aFrameManager) {
|
||||
// Remove the mapping from the content object to its frame
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
aFrameManager->SetPrimaryFrameFor(content, nsnull);
|
||||
|
||||
// Recursively walk aFrame's child frames looking for placeholder frames
|
||||
nsIFrame* childFrame;
|
||||
aFrame->FirstChild(nsnull, &childFrame);
|
||||
while (childFrame) {
|
||||
nsIAtom* frameType;
|
||||
PRBool isPlaceholder;
|
||||
|
||||
// Recursively walk aFrame's child frames looking for placeholder frames
|
||||
nsIFrame* childFrame;
|
||||
aFrame->FirstChild(nsnull, &childFrame);
|
||||
while (childFrame) {
|
||||
nsIAtom* frameType;
|
||||
PRBool isPlaceholder;
|
||||
|
||||
// See if it's a placeholder frame
|
||||
childFrame->GetFrameType(&frameType);
|
||||
isPlaceholder = (nsLayoutAtoms::placeholderFrame == frameType);
|
||||
NS_IF_RELEASE(frameType);
|
||||
|
||||
if (isPlaceholder) {
|
||||
// Get the out-of-flow frame
|
||||
nsIFrame* outOfFlowFrame = ((nsPlaceholderFrame*)childFrame)->GetOutOfFlowFrame();
|
||||
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
||||
|
||||
// Remove the mapping from the out-of-flow frame to its placeholder
|
||||
aFrameManager->SetPlaceholderFrameFor(outOfFlowFrame, nsnull);
|
||||
|
||||
// Recursively find and delete any of its out-of-flow frames, and remove
|
||||
// the mapping from content objects to frames
|
||||
DeletingFrameSubtree(aPresContext, aPresShell, aFrameManager, aRemovedFrame,
|
||||
outOfFlowFrame);
|
||||
|
||||
// Don't delete the out-of-flow frame if aRemovedFrame is one of its
|
||||
// ancestor frames, because when aRemovedFrame is deleted it will delete
|
||||
// its child frames including this out-of-flow frame
|
||||
if (!IsAncestorFrame(outOfFlowFrame, aRemovedFrame)) {
|
||||
// Get the out-of-flow frame's parent
|
||||
nsIFrame* parentFrame;
|
||||
outOfFlowFrame->GetParent(&parentFrame);
|
||||
|
||||
// Get the child list name for the out-of-flow frame
|
||||
nsIAtom* listName;
|
||||
GetChildListNameFor(parentFrame, outOfFlowFrame, &listName);
|
||||
|
||||
// Ask the parent to delete the out-of-flow frame
|
||||
aFrameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame,
|
||||
listName, outOfFlowFrame);
|
||||
NS_IF_RELEASE(listName);
|
||||
// See if it's a placeholder frame
|
||||
childFrame->GetFrameType(&frameType);
|
||||
isPlaceholder = (nsLayoutAtoms::placeholderFrame == frameType);
|
||||
NS_IF_RELEASE(frameType);
|
||||
|
||||
if (isPlaceholder) {
|
||||
// Get the out-of-flow frame
|
||||
nsIFrame* outOfFlowFrame = ((nsPlaceholderFrame*)childFrame)->GetOutOfFlowFrame();
|
||||
NS_ASSERTION(outOfFlowFrame, "no out-of-flow frame");
|
||||
|
||||
// Remove the mapping from the out-of-flow frame to its placeholder
|
||||
aFrameManager->SetPlaceholderFrameFor(outOfFlowFrame, nsnull);
|
||||
|
||||
// Recursively find and delete any of its out-of-flow frames, and remove
|
||||
// the mapping from content objects to frames
|
||||
DeletingFrameSubtree(aPresContext, aPresShell, aFrameManager, aRemovedFrame,
|
||||
outOfFlowFrame);
|
||||
|
||||
// Don't delete the out-of-flow frame if aRemovedFrame is one of its
|
||||
// ancestor frames, because when aRemovedFrame is deleted it will delete
|
||||
// its child frames including this out-of-flow frame
|
||||
if (!IsAncestorFrame(outOfFlowFrame, aRemovedFrame)) {
|
||||
// Get the out-of-flow frame's parent
|
||||
nsIFrame* parentFrame;
|
||||
outOfFlowFrame->GetParent(&parentFrame);
|
||||
|
||||
// Get the child list name for the out-of-flow frame
|
||||
nsIAtom* listName;
|
||||
GetChildListNameFor(parentFrame, outOfFlowFrame, &listName);
|
||||
|
||||
// Ask the parent to delete the out-of-flow frame
|
||||
aFrameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame,
|
||||
listName, outOfFlowFrame);
|
||||
NS_IF_RELEASE(listName);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Recursively find and delete any of its out-of-flow frames, and remove
|
||||
// the mapping from content objects to frames
|
||||
DeletingFrameSubtree(aPresContext, aPresShell, aFrameManager, aRemovedFrame,
|
||||
childFrame);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Recursively find and delete any of its out-of-flow frames, and remove
|
||||
// the mapping from content objects to frames
|
||||
DeletingFrameSubtree(aPresContext, aPresShell, aFrameManager, aRemovedFrame,
|
||||
childFrame);
|
||||
|
||||
// Get the next sibling child frame
|
||||
childFrame->GetNextSibling(&childFrame);
|
||||
}
|
||||
|
||||
// Get the next sibling child frame
|
||||
childFrame->GetNextSibling(&childFrame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@@ -4652,7 +4656,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
|
||||
#endif // INCLUDE_XUL
|
||||
|
||||
if (childFrame) {
|
||||
|
||||
// Walk the frame subtree deleting any out-of-flow frames, and
|
||||
// remove the mapping from content objects to frames
|
||||
DeletingFrameSubtree(aPresContext, shell, frameManager, childFrame, childFrame);
|
||||
|
||||
Reference in New Issue
Block a user