From 6064b6abc28cf601eb759d32f8e0d9659a8cc275 Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Tue, 2 Jul 2002 14:56:18 +0000 Subject: [PATCH] bug 150652 - find correct containing block in nsBlockFrame::DoRemoveOutOfFlowFrame. sr=kin, r=alexsavulov. --- layout/generic/nsBlockFrame.cpp | 17 ++++++++++++----- layout/html/base/src/nsBlockFrame.cpp | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 4cd852efa004..5fc9a3657703 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -4986,15 +4986,22 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIPresContext* aPresContext, const nsStyleDisplay* display = nsnull; aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); NS_ASSERTION(display, "program error"); + // find the containing block, this is either the parent or the grandparent + // if the parent is an inline frame nsIFrame* parent; aFrame->GetParent(&parent); -#ifdef DEBUG - NS_ASSERTION(parent, "program error"); nsCOMPtr parentType; parent->GetFrameType(getter_AddRefs(parentType)); - NS_ASSERTION((nsLayoutAtoms::blockFrame == parentType) || - (nsLayoutAtoms::areaFrame == parentType), "program error"); -#endif + while (parent && (nsLayoutAtoms::blockFrame != parentType) && + (nsLayoutAtoms::areaFrame != parentType)) { + parent->GetParent(&parent); + parent->GetFrameType(getter_AddRefs(parentType)); + } + if (!parent) { + NS_ASSERTION(PR_FALSE, "null parent"); + return; + } + nsBlockFrame* block = (nsBlockFrame*)parent; // Remove aFrame from the appropriate list. if (display->IsAbsolutelyPositioned()) { diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 4cd852efa004..5fc9a3657703 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -4986,15 +4986,22 @@ nsBlockFrame::DoRemoveOutOfFlowFrame(nsIPresContext* aPresContext, const nsStyleDisplay* display = nsnull; aFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); NS_ASSERTION(display, "program error"); + // find the containing block, this is either the parent or the grandparent + // if the parent is an inline frame nsIFrame* parent; aFrame->GetParent(&parent); -#ifdef DEBUG - NS_ASSERTION(parent, "program error"); nsCOMPtr parentType; parent->GetFrameType(getter_AddRefs(parentType)); - NS_ASSERTION((nsLayoutAtoms::blockFrame == parentType) || - (nsLayoutAtoms::areaFrame == parentType), "program error"); -#endif + while (parent && (nsLayoutAtoms::blockFrame != parentType) && + (nsLayoutAtoms::areaFrame != parentType)) { + parent->GetParent(&parent); + parent->GetFrameType(getter_AddRefs(parentType)); + } + if (!parent) { + NS_ASSERTION(PR_FALSE, "null parent"); + return; + } + nsBlockFrame* block = (nsBlockFrame*)parent; // Remove aFrame from the appropriate list. if (display->IsAbsolutelyPositioned()) {