From bbe0f2a86ea43eda7280a5a1aab2762edd43ab46 Mon Sep 17 00:00:00 2001 From: "peterl%netscape.com" Date: Thu, 25 Mar 1999 19:27:11 +0000 Subject: [PATCH] protect recreate frames for content against content with no parent --- layout/base/nsCSSFrameConstructor.cpp | 30 ++++++++----------- .../html/style/src/nsCSSFrameConstructor.cpp | 30 ++++++++----------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 3c20000b4c83..1f616fde0371 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4548,28 +4548,22 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, { nsresult rv = NS_OK; - // First, remove the frames associated with the content object on which the - // attribute change occurred. - - // XXX Right now, ContentRemoved() does not do anything with its aContainer - // and aIndexInContainer in parameters, so I am passing in null and 0, respectively - rv = ContentRemoved(aPresContext, nsnull, aContent, 0); - - if (NS_OK == rv) { - // Now, recreate the frames associated with this content object. - nsIContent *container; - rv = aContent->GetParent(container); - + nsIContent *container; + rv = aContent->GetParent(container); + if (container) { + PRInt32 indexInContainer; + rv = container->IndexOf(aContent, indexInContainer); if (NS_OK == rv) { - PRInt32 indexInContainer; - rv = container->IndexOf(aContent, indexInContainer); - + // First, remove the frames associated with the content object on which the + // attribute change occurred. + rv = ContentRemoved(aPresContext, container, aContent, indexInContainer); + if (NS_OK == rv) { + // Now, recreate the frames associated with this content object. rv = ContentInserted(aPresContext, container, aContent, indexInContainer); } - - NS_RELEASE(container); - } + } + NS_RELEASE(container); } return rv; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 3c20000b4c83..1f616fde0371 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -4548,28 +4548,22 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIPresContext* aPresContext, { nsresult rv = NS_OK; - // First, remove the frames associated with the content object on which the - // attribute change occurred. - - // XXX Right now, ContentRemoved() does not do anything with its aContainer - // and aIndexInContainer in parameters, so I am passing in null and 0, respectively - rv = ContentRemoved(aPresContext, nsnull, aContent, 0); - - if (NS_OK == rv) { - // Now, recreate the frames associated with this content object. - nsIContent *container; - rv = aContent->GetParent(container); - + nsIContent *container; + rv = aContent->GetParent(container); + if (container) { + PRInt32 indexInContainer; + rv = container->IndexOf(aContent, indexInContainer); if (NS_OK == rv) { - PRInt32 indexInContainer; - rv = container->IndexOf(aContent, indexInContainer); - + // First, remove the frames associated with the content object on which the + // attribute change occurred. + rv = ContentRemoved(aPresContext, container, aContent, indexInContainer); + if (NS_OK == rv) { + // Now, recreate the frames associated with this content object. rv = ContentInserted(aPresContext, container, aContent, indexInContainer); } - - NS_RELEASE(container); - } + } + NS_RELEASE(container); } return rv;