Bug 612128 - Part 2: Set the editable flag on the entire subtree rooted at the anonymous content for those nodes which need it; r=roc a=bz

This commit is contained in:
Ehsan Akhgari
2010-11-22 03:13:37 -05:00
parent 09572a06df
commit edcd065e4a

View File

@@ -3927,6 +3927,21 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState,
return NS_OK;
}
static void
SetFlagsOnSubtree(nsIContent *aNode, PtrBits aFlagsToSet)
{
// Set the flag on the node itself
aNode->SetFlags(aFlagsToSet);
// Set the flag on all of its children recursively
PRUint32 count;
nsIContent * const *children = aNode->GetChildArray(&count);
for (PRUint32 index = 0; index < count; ++index) {
SetFlagsOnSubtree(children[index], aFlagsToSet);
}
}
nsresult
nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent,
nsIFrame* aParentFrame,
@@ -3961,8 +3976,10 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent,
rv = content->BindToTree(mDocument, aParent, aParent, PR_TRUE);
// If the anonymous content creator requested that the content should be
// editable, honor its request.
// We need to set the flag on the whole subtree, because existing
// children's flags have already been set as part of the BindToTree operation.
if (anonContentIsEditable) {
content->SetFlags(NODE_IS_EDITABLE);
SetFlagsOnSubtree(content, NODE_IS_EDITABLE);
}
if (NS_FAILED(rv)) {
content->UnbindFromTree();