Bug 535721. Deal with MoveChildrenTo on non-siblings. r=roc

This commit is contained in:
Boris Zbarsky 2009-12-23 16:17:23 -05:00
parent 32cfd3d5a7
commit 976c983e86
3 changed files with 27 additions and 4 deletions

View File

@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function boom()
{
document.getElementById("i").appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "div"));
}
</script>
</head>
<body onload="boom();">
<div><span><span id="i"><div></div></span></span></div>
</body>
</html>

View File

@ -266,4 +266,5 @@ load 500467-1.html
load 501878-1.html load 501878-1.html
load 503936-1.html load 503936-1.html
load 526378-1.xul load 526378-1.xul
load 535721-1.xhtml
load 535911-1.xhtml load 535911-1.xhtml

View File

@ -1396,10 +1396,9 @@ MoveChildrenTo(nsPresContext* aPresContext,
nsIFrame* aNewParent, nsIFrame* aNewParent,
nsFrameList& aFrameList) nsFrameList& aFrameList)
{ {
NS_PRECONDITION(aOldParent->GetParent() == aNewParent->GetParent(), PRBool sameGrandParent = aOldParent->GetParent() == aNewParent->GetParent();
"Unexpected old and new parents");
if (aNewParent->HasView() || aOldParent->HasView()) { if (aNewParent->HasView() || aOldParent->HasView() || !sameGrandParent) {
// Move the frames into the new view // Move the frames into the new view
nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, aFrameList, nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, aFrameList,
aOldParent, aNewParent); aOldParent, aNewParent);
@ -1419,6 +1418,12 @@ MoveChildrenTo(nsPresContext* aPresContext,
if (setHasChildWithView) { if (setHasChildWithView) {
aNewParent->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW); aNewParent->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
if (!sameGrandParent) {
for (nsIFrame* ancestor = aNewParent->GetParent();
ancestor; ancestor = ancestor->GetParent()) {
ancestor->AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
}
}
} }
if (aNewParent->GetChildList(nsnull).IsEmpty() && if (aNewParent->GetChildList(nsnull).IsEmpty() &&
@ -5812,7 +5817,7 @@ nsCSSFrameConstructor::AppendFrames(nsFrameConstructorState& aState,
// initial parent, because that could screw up float parenting; it's easier // initial parent, because that could screw up float parenting; it's easier
// to do this little fixup here instead. // to do this little fixup here instead.
if (aFrameList.NotEmpty() && !IsInlineOutside(aFrameList.FirstChild())) { if (aFrameList.NotEmpty() && !IsInlineOutside(aFrameList.FirstChild())) {
// See whether out trailing inline is empty // See whether our trailing inline is empty
nsIFrame* firstContinuation = aParentFrame->GetFirstContinuation(); nsIFrame* firstContinuation = aParentFrame->GetFirstContinuation();
if (firstContinuation->GetChildList(nsnull).IsEmpty()) { if (firstContinuation->GetChildList(nsnull).IsEmpty()) {
// Our trailing inline is empty. Collect our starting blocks from // Our trailing inline is empty. Collect our starting blocks from