Bug 577309 part 13. Stop using content indices entirely in nsCSSFrameConstructor::ContentInserted. r=tnikkel

This commit is contained in:
Boris Zbarsky 2010-07-15 00:38:23 -04:00
parent 2c37598755
commit e7c8d97165
3 changed files with 29 additions and 55 deletions

View File

@ -6180,7 +6180,7 @@ nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent,
}
NS_ASSERTION(!content->GetPrimaryFrame(),
"Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
ContentInserted(aParentContent, content, aContentIndex, nsnull, PR_FALSE);
ContentInserted(aParentContent, content, nsnull, PR_FALSE);
}
// We want to disable lazy frame construction for nodes that are under an
@ -6340,8 +6340,8 @@ nsCSSFrameConstructor::CreateNeededFrames(nsIContent* aContent)
if (inRun) {
inRun = PR_FALSE;
// generate a ContentRangeInserted for [startOfRun,i)
ContentRangeInserted(aContent, firstChildInRun, child, startOfRun, i,
nsnull, PR_FALSE);
ContentRangeInserted(aContent, firstChildInRun, child, nsnull,
PR_FALSE);
}
}
}
@ -6380,14 +6380,13 @@ void nsCSSFrameConstructor::CreateNeededFrames()
void
nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
PRInt32 aStartIndexInContainer,
PRInt32 aEndIndexInContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRBool aAllowLazyConstruction)
{
for (PRUint32 i = aStartIndexInContainer;
i < (PRUint32)aEndIndexInContainer;
i++) {
nsIContent* child = aContainer->GetChildAt(i);
for (nsIContent* child = aStartChild;
child != aEndChild;
child = child->GetNextSibling()) {
if ((child->GetPrimaryFrame() ||
mPresShell->FrameManager()->GetUndisplayedContent(child))
#ifdef MOZ_XUL
@ -6401,8 +6400,8 @@ nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
// its insertion parent. Skip it.
continue;
}
// Call ContentInserted with this index.
ContentInserted(aContainer, child, i, mTempFrameTreeState,
// Call ContentInserted with this node.
ContentInserted(aContainer, child, mTempFrameTreeState,
aAllowLazyConstruction);
}
}
@ -6412,8 +6411,6 @@ nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aContainer,
nsIFrame* aParentFrame,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRInt32 aStartIndexInContainer,
PRInt32 aEndIndexInContainer,
PRBool aAllowLazyConstruction)
{
// See if we have an XBL insertion point. If so, then that's our
@ -6460,14 +6457,10 @@ nsCSSFrameConstructor::GetRangeInsertionPoint(nsIContent* aContainer,
// has explicit children, then we must fall back.
if (multiple || aEndChild != nsnull || childCount > 0) {
// Now comes the fun part. For each inserted child, make a
// ContentInserted call as if it had just gotten inserted at the index
// it's at in aContainer and let ContentInserted handle the mess. If our
// insertion point is non-XBL that's the correct index, and otherwise
// ContentInserted will ignore the passed-in index.
PRUint32 endIndex = aEndChild == nsnull ?
aContainer->GetChildCount() : aEndIndexInContainer;
IssueSingleInsertNofications(aContainer, aStartIndexInContainer,
endIndex, aAllowLazyConstruction);
// ContentInserted call as if it had just gotten inserted and
// let ContentInserted handle the mess.
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
return nsnull;
}
}
@ -6545,7 +6538,6 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
LAYOUT_PHASE_TEMP_EXIT();
parentFrame = GetRangeInsertionPoint(aContainer, parentFrame,
aFirstNewContent, nsnull,
aNewIndexInContainer, -1,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
if (!parentFrame) {
@ -6801,15 +6793,12 @@ PRBool NotifyListBoxBody(nsPresContext* aPresContext,
nsresult
nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer,
nsILayoutHistoryState* aFrameState,
PRBool aAllowLazyConstruction)
{
return ContentRangeInserted(aContainer,
aChild,
aChild->GetNextSibling(),
aIndexInContainer,
aIndexInContainer+1,
aFrameState,
aAllowLazyConstruction);
}
@ -6836,8 +6825,6 @@ nsresult
nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRInt32 aIndexInContainer,
PRInt32 aEndIndexInContainer,
nsILayoutHistoryState* aFrameState,
PRBool aAllowLazyConstruction)
{
@ -6871,9 +6858,8 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
PRBool isSingleInsert = (aStartChild->GetNextSibling() == aEndChild);
NS_ASSERTION(isSingleInsert || !aAllowLazyConstruction,
"range insert shouldn't be lazy");
NS_ASSERTION(isSingleInsert || !aContainer ||
PRUint32(aEndIndexInContainer) < aContainer->GetChildCount(),
"end index should not include all nodes");
NS_ASSERTION(isSingleInsert || aEndChild,
"range should not include all nodes after aStartChild");
#ifdef MOZ_XUL
if (aContainer && IsXULListBox(aContainer)) {
@ -6889,8 +6875,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// We don't handle a range insert to a listbox parent, issue single
// ContertInserted calls for each node inserted.
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(aContainer, aIndexInContainer,
aEndIndexInContainer,
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
@ -6958,8 +6943,6 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
LAYOUT_PHASE_TEMP_EXIT();
parentFrame = GetRangeInsertionPoint(aContainer, parentFrame,
aStartChild, aEndChild,
aIndexInContainer,
aEndIndexInContainer,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
if (!parentFrame) {
@ -6976,8 +6959,8 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (!isSingleInsert && !isRangeInsertSafe) {
// must fall back to a single ContertInserted for each child in the range
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(aContainer, aIndexInContainer,
aEndIndexInContainer, aAllowLazyConstruction);
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
}
@ -7097,8 +7080,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
// must fall back to a single ContertInserted for each child in the range
LAYOUT_PHASE_TEMP_EXIT();
IssueSingleInsertNofications(aContainer, aIndexInContainer,
aEndIndexInContainer,
IssueSingleInsertNofications(aContainer, aStartChild, aEndChild,
aAllowLazyConstruction);
LAYOUT_PHASE_TEMP_REENTER();
return NS_OK;
@ -9097,8 +9079,7 @@ nsCSSFrameConstructor::RecreateFramesForContent(nsIContent* aContent,
PostRestyleEvent(aContent->AsElement(), nsRestyleHint(0),
nsChangeHint_ReconstructFrame);
} else {
rv = ContentInserted(container, aContent, indexInContainer,
mTempFrameTreeState, PR_FALSE);
rv = ContentInserted(container, aContent, mTempFrameTreeState, PR_FALSE);
}
}
}

View File

@ -143,10 +143,10 @@ private:
nsIContent* aChild);
// Issues a single ContentInserted for each child of aContainer in the range
// [aStartIndexInContainer, aEndIndexInContainer).
// [aStartChild, aEndChild).
void IssueSingleInsertNofications(nsIContent* aContainer,
PRInt32 aStartIndexInContainer,
PRInt32 aEndIndexInContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRBool aAllowLazyConstruction);
// Checks if the children of aContainer in the range [aStartChild, aEndChild)
@ -158,8 +158,6 @@ private:
nsIFrame* aParentFrame,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRInt32 aStartIndexInContainer,
PRInt32 aEndIndexInContainer,
PRBool aAllowLazyConstruction);
// Returns true if parent was recreated due to frameset child, false otherwise.
@ -223,22 +221,18 @@ public:
// can be done lazily.
nsresult ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer,
nsILayoutHistoryState* aFrameState,
PRBool aAllowLazyConstruction);
// Like ContentInserted but handles inserting the children of aContainer in
// the range [aIndexInContainer, aEndIndexInContainer). aStartChild is the
// child at aIndexInContainer, and must be non-null. aEndChild is the node at
// aEndIndexInContainer (which may be null if the range is at the end of the
// child list). If aAllowLazyConstruction is true then frame construction of
// the range [aStartChild, aEndChild). aStartChild must be non-null.
// aEndChild may be null to indicate the range includes all kids after
// aStartChild. If aAllowLazyConstruction is true then frame construction of
// the new children can be done lazily. It is only allowed to be true when
// inserting a single node.
nsresult ContentRangeInserted(nsIContent* aContainer,
nsIContent* aStartChild,
nsIContent* aEndChild,
PRInt32 aIndexInContainer,
PRInt32 aEndIndexInContainer,
nsILayoutHistoryState* aFrameState,
PRBool aAllowLazyConstruction);

View File

@ -2632,7 +2632,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
// Have the style sheet processor construct frame for the root
// content object down
mFrameConstructor->ContentInserted(nsnull, root, 0, nsnull, PR_FALSE);
mFrameConstructor->ContentInserted(nsnull, root, nsnull, PR_FALSE);
VERIFY_STYLE_TREE;
// Something in mFrameConstructor->ContentInserted may have caused
@ -4999,8 +4999,7 @@ PresShell::ContentInserted(nsIDocument* aDocument,
if (aContainer)
mFrameConstructor->RestyleForInsertOrChange(aContainer->AsElement(), aChild);
mFrameConstructor->ContentInserted(aContainer, aChild,
aIndexInContainer, nsnull, PR_TRUE);
mFrameConstructor->ContentInserted(aContainer, aChild, nsnull, PR_TRUE);
VERIFY_STYLE_TREE;
}