From 15e12f10a8100bc4cc022366ffd3bbcbb96d9316 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Thu, 5 Aug 1999 03:30:09 +0000 Subject: [PATCH] Added NULL pointer check for frame manager in DeletingFrameSubtree() git-svn-id: svn://10.0.0.236/trunk@42259 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 113 +++++++++--------- .../html/style/src/nsCSSFrameConstructor.cpp | 113 +++++++++--------- 2 files changed, 116 insertions(+), 110 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 19a45f24d73..ffa75c02123 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -4511,63 +4511,67 @@ DeletingFrameSubtree(nsIPresContext* aPresContext, nsIFrame* aRemovedFrame, nsIFrame* aFrame) { - // Remove the mapping from the content object to its frame - nsCOMPtr 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 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); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 19a45f24d73..ffa75c02123 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -4511,63 +4511,67 @@ DeletingFrameSubtree(nsIPresContext* aPresContext, nsIFrame* aRemovedFrame, nsIFrame* aFrame) { - // Remove the mapping from the content object to its frame - nsCOMPtr 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 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);