From a48e4337a04c2a218516d1de49bc053499462058 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Fri, 23 Mar 2001 14:43:09 +0000 Subject: [PATCH] Removed code which prevented reparenting of views + added code to check floating child list when reparenting views bug 71032; sr = waterson@netscape.com; r=dcone@netscape.com --- layout/generic/nsHTMLContainerFrame.cpp | 23 +++++++++++-------- layout/html/base/src/nsHTMLContainerFrame.cpp | 23 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index d2ffcad073a0..0ef4b2179930 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -168,21 +168,16 @@ ReparentFrameViewTo(nsIPresContext* aPresContext, // Verify that the current parent view is what we think it is nsIView* parentView; - // you have to check all the time to see if this - // view has been reparented.. if you try to insert for - // a view that has been reparented.. bad things can happen. - // I took out the debug check and check all the time now.. - // this case happens when you print. - view->GetParent(parentView); - if(parentView != aOldParentView) - return NS_OK; - //NS_ASSERTION(parentView == aOldParentView, "unexpected parent view"); // Change the parent view. PRInt32 zIndex; view->GetZIndex(zIndex); - aViewManager->RemoveChild(aOldParentView, view); + // Remove the view using it's parent instead + // of aOldParentView which is wrong. + nsIView* vp = nsnull; + view->GetParent(vp); + aViewManager->RemoveChild(vp, view); // XXX We need to insert this view in the correct place within its z-order... // XXX What should we do about the Z-placeholder-child if this frame is position:fixed? @@ -204,6 +199,14 @@ ReparentFrameViewTo(nsIPresContext* aPresContext, ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView); childFrame->GetNextSibling(&childFrame); } + + // Also check the floater-list + aFrame->FirstChild(aPresContext, nsLayoutAtoms::floaterList, &childFrame); + while (childFrame) { + ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView); + childFrame->GetNextSibling(&childFrame); + } + } return NS_OK; diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index d2ffcad073a0..0ef4b2179930 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -168,21 +168,16 @@ ReparentFrameViewTo(nsIPresContext* aPresContext, // Verify that the current parent view is what we think it is nsIView* parentView; - // you have to check all the time to see if this - // view has been reparented.. if you try to insert for - // a view that has been reparented.. bad things can happen. - // I took out the debug check and check all the time now.. - // this case happens when you print. - view->GetParent(parentView); - if(parentView != aOldParentView) - return NS_OK; - //NS_ASSERTION(parentView == aOldParentView, "unexpected parent view"); // Change the parent view. PRInt32 zIndex; view->GetZIndex(zIndex); - aViewManager->RemoveChild(aOldParentView, view); + // Remove the view using it's parent instead + // of aOldParentView which is wrong. + nsIView* vp = nsnull; + view->GetParent(vp); + aViewManager->RemoveChild(vp, view); // XXX We need to insert this view in the correct place within its z-order... // XXX What should we do about the Z-placeholder-child if this frame is position:fixed? @@ -204,6 +199,14 @@ ReparentFrameViewTo(nsIPresContext* aPresContext, ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView); childFrame->GetNextSibling(&childFrame); } + + // Also check the floater-list + aFrame->FirstChild(aPresContext, nsLayoutAtoms::floaterList, &childFrame); + while (childFrame) { + ReparentFrameViewTo(aPresContext, childFrame, aViewManager, aNewParentView, aOldParentView); + childFrame->GetNextSibling(&childFrame); + } + } return NS_OK;