Bug 500124. Fix regression from bug 495385 by initializing text items correctly. Also avoid reframing text nodes in ContentRemoved when we know the text node doesn't need to be unsuppressed. r+sr=bzbarsky
This commit is contained in:
@@ -6137,7 +6137,8 @@ MaybeGetListBoxBodyFrame(nsIContent* aContainer, nsIContent* aChild)
|
||||
#endif
|
||||
|
||||
void
|
||||
nsCSSFrameConstructor::AddTextItemIfNeeded(nsIFrame* aParentFrame,
|
||||
nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState,
|
||||
nsIFrame* aParentFrame,
|
||||
nsIContent* aParentContent,
|
||||
PRInt32 aContentIndex,
|
||||
FrameConstructionItemList& aItems)
|
||||
@@ -6157,16 +6158,8 @@ nsCSSFrameConstructor::AddTextItemIfNeeded(nsIFrame* aParentFrame,
|
||||
// Already has a frame, don't do anything.
|
||||
return;
|
||||
}
|
||||
// OK, we should try to create something
|
||||
const FrameConstructionData* data = FindTextData(aParentFrame);
|
||||
if (!data)
|
||||
return;
|
||||
nsRefPtr<nsStyleContext> sc =
|
||||
ResolveStyleContext(aParentFrame, content);
|
||||
if (!sc)
|
||||
return;
|
||||
aItems.AppendItem(data, content, content->Tag(), content->GetNameSpaceID(),
|
||||
aContentIndex, sc.forget());
|
||||
|
||||
AddFrameConstructionItems(aState, content, aContentIndex, aParentFrame, aItems);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -6395,7 +6388,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
|
||||
// (text in an XBL binding is not suppressed) or generated content
|
||||
// (and bare text nodes are not generated). Native anonymous content
|
||||
// generated by frames never participates in inline layout.
|
||||
AddTextItemIfNeeded(parentFrame, aContainer,
|
||||
AddTextItemIfNeeded(state, parentFrame, aContainer,
|
||||
aNewIndexInContainer - 1, items);
|
||||
}
|
||||
for (PRUint32 i = aNewIndexInContainer, count = aContainer->GetChildCount();
|
||||
@@ -6752,7 +6745,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
|
||||
// If there's a text node in the normal content list just before
|
||||
// the new node, and it has no frame, make a frame construction item
|
||||
// for it, because it might need a frame now.
|
||||
AddTextItemIfNeeded(parentFrame, aContainer, aIndexInContainer - 1,
|
||||
AddTextItemIfNeeded(state, parentFrame, aContainer, aIndexInContainer - 1,
|
||||
items);
|
||||
}
|
||||
|
||||
@@ -6762,7 +6755,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
|
||||
// If there's a text frame in the normal content list just after
|
||||
// the new node, and it has no frame, make a frame construction item
|
||||
// for it, because it might need a frame now.
|
||||
AddTextItemIfNeeded(parentFrame, aContainer, aIndexInContainer + 1,
|
||||
AddTextItemIfNeeded(state, parentFrame, aContainer, aIndexInContainer + 1,
|
||||
items);
|
||||
}
|
||||
|
||||
@@ -7366,11 +7359,19 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
|
||||
// Adjacent whitespace-only text nodes might have been suppressed if
|
||||
// this node does not have inline ends. Create frames for them now
|
||||
// if necessary.
|
||||
if (aIndexInContainer > 0) {
|
||||
ReframeTextIfNeeded(aContainer, aIndexInContainer - 1);
|
||||
}
|
||||
PRInt32 childCount = aContainer->GetChildCount();
|
||||
if (aIndexInContainer < childCount) {
|
||||
// Reframe any text node just before the node being removed, if there is
|
||||
// one, and if it's not the last child or the first child. If a whitespace
|
||||
// textframe was being suppressed and it's now the last child or first
|
||||
// child then it can stay suppressed since the parent must be a block
|
||||
// and hence it's adjacent to a block end.
|
||||
PRInt32 prevSiblingIndex = aIndexInContainer - 1;
|
||||
if (prevSiblingIndex > 0 && prevSiblingIndex < childCount - 1) {
|
||||
ReframeTextIfNeeded(aContainer, prevSiblingIndex);
|
||||
}
|
||||
// Reframe any text node just after the node being removed, if there is
|
||||
// one, and if it's not the last child or the first child.
|
||||
if (aIndexInContainer > 0 && aIndexInContainer < childCount - 1) {
|
||||
ReframeTextIfNeeded(aContainer, aIndexInContainer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user