Reget our parent after blowing away letter frames. Bug 318592, r+sr=dbaron

This commit is contained in:
bzbarsky%mit.edu 2006-11-04 01:59:14 +00:00
Родитель 19ecad0c61
Коммит e374435e06
1 изменённых файлов: 45 добавлений и 27 удалений

Просмотреть файл

@ -4515,6 +4515,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
// --------- IF SCROLLABLE WRAP IN SCROLLFRAME --------
#ifdef DEBUG
PRBool propagatedScrollToViewport =
PropagateScrollToViewport() == aDocElement;
@ -4522,6 +4523,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState,
aState.mPresContext->IsPaginated() ||
propagatedScrollToViewport,
"Scrollbars should have been propagated to the viewport");
#endif
nsIFrame* contentFrame = nsnull;
PRBool isBlockFrame = PR_FALSE;
@ -8944,8 +8946,8 @@ nsCSSFrameConstructor::NeedSpecialFrameReframe(nsIContent* aParent1,
nsIFrame*& aPrevSibling,
nsIFrame* aNextSibling)
{
NS_ENSURE_TRUE(aPrevSibling || aNextSibling, PR_TRUE);
// XXXbz aNextSibling is utterly unused. Why?
if (!IsInlineFrame2(aParentFrame))
return PR_FALSE;
@ -8974,6 +8976,9 @@ nsCSSFrameConstructor::NeedSpecialFrameReframe(nsIContent* aParent1,
aParentFrame = prevParent; // prevParent is a block, put aChild there
}
else {
// XXXbz see comments in ContentInserted about this being wrong in many
// cases! Why doesn't this just use aNextSibling anyway? Why are we
// looking sometimes in aParent1 and sometimes in aParent2?
nsIFrame* nextSibling = (aIndexInContainer >= 0)
? FindNextSibling(aParent2, aParentFrame,
aIndexInContainer)
@ -9002,6 +9007,9 @@ nsCSSFrameConstructor::NeedSpecialFrameReframe(nsIContent* aParent1,
NS_ASSERTION(aParentFrame, "program error - null parent frame");
}
else { // prevParent is a block
// XXXbz see comments in ContentInserted about this being wrong in many
// cases! Why doesn't this just use aNextSibling anyway? Why are we
// looking sometimes in aParent1 and sometimes in aParent2?
nsIFrame* nextSibling = (aIndexInContainer >= 0)
? FindNextSibling(aParent2, aParentFrame,
aIndexInContainer)
@ -9341,6 +9349,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
// letter-frame is present, use its parent.
if (parentFrame->GetType() == nsLayoutAtoms::letterFrame) {
parentFrame = parentFrame->GetParent();
container = parentFrame->GetContent();
}
// Remove the old letter frames before doing the insertion
@ -9348,31 +9357,6 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
state.mFrameManager,
state.mFloatedItems.containingBlock);
// Check again to see if the frame we are manipulating is part
// of a block-in-inline hierarchy.
if (IsFrameSpecial(parentFrame)) {
nsCOMPtr<nsIContent> parentContainer = blockContent->GetParent();
#ifdef DEBUG
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentInserted: parentFrame=");
nsFrame::ListTag(stdout, parentFrame);
printf(" is special inline\n");
printf(" ==> blockContent=%p, parentContainer=%p\n",
NS_STATIC_CAST(void*, blockContent),
NS_STATIC_CAST(void*, parentContainer));
}
#endif
if (parentContainer) {
ReinsertContent(parentContainer, blockContent);
}
else {
// XXX uh oh. the block that needs reworking has no parent...
NS_NOTREACHED("block that needs recreation has no parent");
}
return NS_OK;
}
// Removing the letterframes messes around with the frame tree, removing
// and creating frames. We need to reget our prevsibling.
// See XXX comment the first time we do this in this method....
@ -9381,6 +9365,40 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
aChild)
: FindPreviousAnonymousSibling(mPresShell, mDocument, aContainer,
aChild);
// If there is no previous sibling, then find the frame that follows
if (! prevSibling) {
nextSibling = (aIndexInContainer >= 0)
? FindNextSibling(container, parentFrame, aIndexInContainer, aChild)
: FindNextAnonymousSibling(mPresShell, mDocument, aContainer, aChild);
}
handleSpecialFrame = IsFrameSpecial(parentFrame) && !aInReinsertContent;
if (handleSpecialFrame &&
NeedSpecialFrameReframe(aContainer, container, parentFrame,
aChild, aIndexInContainer, prevSibling,
nextSibling)) {
#ifdef DEBUG
nsIContent* parentContainer = blockContent->GetParent();
if (gNoisyContentUpdates) {
printf("nsCSSFrameConstructor::ContentInserted: parentFrame=");
nsFrame::ListTag(stdout, parentFrame);
printf(" is special inline\n");
printf(" ==> blockContent=%p, parentContainer=%p\n",
NS_STATIC_CAST(void*, blockContent),
NS_STATIC_CAST(void*, parentContainer));
}
#endif
NS_ASSERTION(GetFloatContainingBlock(parentFrame) == containingBlock,
"Unexpected block ancestor for parentFrame");
// Note that in this case we're guaranteed that the closest block
// containing parentFrame is |containingBlock|. So
// ReframeContainingBlock(parentFrame) will make sure to rebuild the
// first-letter stuff we just blew away.
return ReframeContainingBlock(parentFrame);
}
}
}
else if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == parentDisplay->mDisplay) {