From 441e02909f142bd4e34aa4d43eb0867fe9fc645a Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Wed, 20 Oct 1999 23:35:38 +0000 Subject: [PATCH] added check for null frame. The child frame can be null when a comment node exists as one of the children of the select. r=kmcclusk, Bug #16355 --- layout/base/nsCSSFrameConstructor.cpp | 44 ++++++++++--------- .../html/style/src/nsCSSFrameConstructor.cpp | 44 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 561a32ceb00d..ba014884b20b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -6337,30 +6337,32 @@ nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext, // Get the childFrame for the added child (option) // then get the child's parent frame which should be an area frame aPresShell->GetPrimaryFrameFor(aChild, &childFrame); - childFrame->GetParent(&parentFrame); + if (nsnull != childFrame) { + childFrame->GetParent(&parentFrame); - // Now loop through all the child looking fr the frame whose content - // is equal to the select element's content - // this is because when gernated content is created it stuff the parent content - // pointer into the generated frame, so in this case it has the select content - parentFrame->FirstChild(nsnull, &childFrame); - nsCOMPtr selectContent = do_QueryInterface(aSelectElement); - while (nsnull != childFrame) { - nsIContent * content; - childFrame->GetContent(&content); + // Now loop through all the child looking fr the frame whose content + // is equal to the select element's content + // this is because when gernated content is created it stuff the parent content + // pointer into the generated frame, so in this case it has the select content + parentFrame->FirstChild(nsnull, &childFrame); + nsCOMPtr selectContent = do_QueryInterface(aSelectElement); + while (nsnull != childFrame) { + nsIContent * content; + childFrame->GetContent(&content); - // Found the dummy frame so get the FrameManager and - // delete/remove the dummy frame - if (selectContent.get() == content) { - nsCOMPtr frameManager; - aPresShell->GetFrameManager(getter_AddRefs(frameManager)); - frameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame, nsnull, childFrame); - NS_IF_RELEASE(content); - return NS_OK; - } + // Found the dummy frame so get the FrameManager and + // delete/remove the dummy frame + if (selectContent.get() == content) { + nsCOMPtr frameManager; + aPresShell->GetFrameManager(getter_AddRefs(frameManager)); + frameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame, nsnull, childFrame); + NS_IF_RELEASE(content); + return NS_OK; + } - NS_IF_RELEASE(content); - childFrame->GetNextSibling(&childFrame); + NS_IF_RELEASE(content); + childFrame->GetNextSibling(&childFrame); + } } } } diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 561a32ceb00d..ba014884b20b 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -6337,30 +6337,32 @@ nsCSSFrameConstructor::RemoveDummyFrameFromSelect(nsIPresContext* aPresContext, // Get the childFrame for the added child (option) // then get the child's parent frame which should be an area frame aPresShell->GetPrimaryFrameFor(aChild, &childFrame); - childFrame->GetParent(&parentFrame); + if (nsnull != childFrame) { + childFrame->GetParent(&parentFrame); - // Now loop through all the child looking fr the frame whose content - // is equal to the select element's content - // this is because when gernated content is created it stuff the parent content - // pointer into the generated frame, so in this case it has the select content - parentFrame->FirstChild(nsnull, &childFrame); - nsCOMPtr selectContent = do_QueryInterface(aSelectElement); - while (nsnull != childFrame) { - nsIContent * content; - childFrame->GetContent(&content); + // Now loop through all the child looking fr the frame whose content + // is equal to the select element's content + // this is because when gernated content is created it stuff the parent content + // pointer into the generated frame, so in this case it has the select content + parentFrame->FirstChild(nsnull, &childFrame); + nsCOMPtr selectContent = do_QueryInterface(aSelectElement); + while (nsnull != childFrame) { + nsIContent * content; + childFrame->GetContent(&content); - // Found the dummy frame so get the FrameManager and - // delete/remove the dummy frame - if (selectContent.get() == content) { - nsCOMPtr frameManager; - aPresShell->GetFrameManager(getter_AddRefs(frameManager)); - frameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame, nsnull, childFrame); - NS_IF_RELEASE(content); - return NS_OK; - } + // Found the dummy frame so get the FrameManager and + // delete/remove the dummy frame + if (selectContent.get() == content) { + nsCOMPtr frameManager; + aPresShell->GetFrameManager(getter_AddRefs(frameManager)); + frameManager->RemoveFrame(*aPresContext, *aPresShell, parentFrame, nsnull, childFrame); + NS_IF_RELEASE(content); + return NS_OK; + } - NS_IF_RELEASE(content); - childFrame->GetNextSibling(&childFrame); + NS_IF_RELEASE(content); + childFrame->GetNextSibling(&childFrame); + } } } }