From cdce771b29b168af65f6f4b28a0e08ec1e021211 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Mon, 19 Mar 2001 22:16:47 +0000 Subject: [PATCH] Bug 71594. Reparent views from 'trailing' frame, but only make trailing frame if it'd have children. r=karnaze, sr=attinasi --- layout/base/nsCSSFrameConstructor.cpp | 46 +++++++++++-------- .../html/style/src/nsCSSFrameConstructor.cpp | 46 +++++++++++-------- layout/html/tests/block/bugs/71594.html | 1 + 3 files changed, 55 insertions(+), 38 deletions(-) create mode 100644 layout/html/tests/block/bugs/71594.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index f2fe8e17175..a87acbb1973 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -12544,36 +12544,44 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, // list3's frames belong to another inline frame nsIFrame* inlineFrame = nsnull; - if (aIsPositioned) { - NS_NewPositionedInlineFrame(aPresShell, &inlineFrame); - } - else { - NS_NewInlineFrame(aPresShell, &inlineFrame); - } - - InitAndRestoreFrame(aPresContext, aState, aContent, - aParentFrame, aStyleContext, nsnull, inlineFrame); - - if (aIsPositioned) { - // Relatively positioned frames need a view - nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame, - aStyleContext, nsnull, PR_FALSE); - } - if (list3) { + if (aIsPositioned) { + NS_NewPositionedInlineFrame(aPresShell, &inlineFrame); + } + else { + NS_NewInlineFrame(aPresShell, &inlineFrame); + } + + InitAndRestoreFrame(aPresContext, aState, aContent, + aParentFrame, aStyleContext, nsnull, inlineFrame); + + if (aIsPositioned) { + // Relatively positioned frames need a view + nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame, + aStyleContext, nsnull, PR_FALSE); + + // Move list3's frames into the new view + nsIFrame* oldParent; + list3->GetParent(&oldParent); + nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, list3, oldParent, inlineFrame); + } + // Reparent (cheaply) the frames in list3 - we don't have to futz // with their style context because they already have the right one. nsFrameList list; list.AppendFrames(inlineFrame, list3); + + inlineFrame->SetInitialChildList(aPresContext, nsnull, list3); } - inlineFrame->SetInitialChildList(aPresContext, nsnull, list3); // Mark the 3 frames as special. That way if any of the // append/insert/remove methods try to fiddle with the children, the // containing block will be reframed instead. SetFrameIsSpecial(aState.mFrameManager, aNewFrame, blockFrame); SetFrameIsSpecial(aState.mFrameManager, blockFrame, inlineFrame); - SetFrameIsSpecial(aState.mFrameManager, inlineFrame, nsnull); + + if (inlineFrame) + SetFrameIsSpecial(aState.mFrameManager, inlineFrame, nsnull); #ifdef DEBUG if (gNoisyInlineConstruction) { @@ -12588,7 +12596,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, printf(" ==> block frame:\n"); frameDebug->List(aPresContext, stdout, 2); } - if (NS_SUCCEEDED(inlineFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + if (inlineFrame && NS_SUCCEEDED(inlineFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { printf(" ==> trailing inline frame:\n"); frameDebug->List(aPresContext, stdout, 2); } diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index f2fe8e17175..a87acbb1973 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -12544,36 +12544,44 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, // list3's frames belong to another inline frame nsIFrame* inlineFrame = nsnull; - if (aIsPositioned) { - NS_NewPositionedInlineFrame(aPresShell, &inlineFrame); - } - else { - NS_NewInlineFrame(aPresShell, &inlineFrame); - } - - InitAndRestoreFrame(aPresContext, aState, aContent, - aParentFrame, aStyleContext, nsnull, inlineFrame); - - if (aIsPositioned) { - // Relatively positioned frames need a view - nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame, - aStyleContext, nsnull, PR_FALSE); - } - if (list3) { + if (aIsPositioned) { + NS_NewPositionedInlineFrame(aPresShell, &inlineFrame); + } + else { + NS_NewInlineFrame(aPresShell, &inlineFrame); + } + + InitAndRestoreFrame(aPresContext, aState, aContent, + aParentFrame, aStyleContext, nsnull, inlineFrame); + + if (aIsPositioned) { + // Relatively positioned frames need a view + nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame, + aStyleContext, nsnull, PR_FALSE); + + // Move list3's frames into the new view + nsIFrame* oldParent; + list3->GetParent(&oldParent); + nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, list3, oldParent, inlineFrame); + } + // Reparent (cheaply) the frames in list3 - we don't have to futz // with their style context because they already have the right one. nsFrameList list; list.AppendFrames(inlineFrame, list3); + + inlineFrame->SetInitialChildList(aPresContext, nsnull, list3); } - inlineFrame->SetInitialChildList(aPresContext, nsnull, list3); // Mark the 3 frames as special. That way if any of the // append/insert/remove methods try to fiddle with the children, the // containing block will be reframed instead. SetFrameIsSpecial(aState.mFrameManager, aNewFrame, blockFrame); SetFrameIsSpecial(aState.mFrameManager, blockFrame, inlineFrame); - SetFrameIsSpecial(aState.mFrameManager, inlineFrame, nsnull); + + if (inlineFrame) + SetFrameIsSpecial(aState.mFrameManager, inlineFrame, nsnull); #ifdef DEBUG if (gNoisyInlineConstruction) { @@ -12588,7 +12596,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell, printf(" ==> block frame:\n"); frameDebug->List(aPresContext, stdout, 2); } - if (NS_SUCCEEDED(inlineFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + if (inlineFrame && NS_SUCCEEDED(inlineFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { printf(" ==> trailing inline frame:\n"); frameDebug->List(aPresContext, stdout, 2); } diff --git a/layout/html/tests/block/bugs/71594.html b/layout/html/tests/block/bugs/71594.html new file mode 100644 index 00000000000..bfc03bb57ca --- /dev/null +++ b/layout/html/tests/block/bugs/71594.html @@ -0,0 +1 @@ +
test
\ No newline at end of file