Bug 992521 - Part 5: Bind native anonymous content to null document when node is contained by a ShadowRoot. r=smaug

This commit is contained in:
William Chen 2014-06-07 01:42:55 -07:00
parent d5a9346ba8
commit 00bef8c70a

View File

@ -1797,7 +1797,12 @@ nsCSSFrameConstructor::CreateGeneratedContentItem(nsFrameConstructorState& aStat
return;
container->SetIsNativeAnonymousRoot();
rv = container->BindToTree(mDocument, aParentContent, aParentContent, true);
// If the parent is in a shadow tree, make sure we don't
// bind with a document because shadow roots and its descendants
// are not in document.
nsIDocument* bindDocument =
aParentContent->HasFlag(NODE_IS_IN_SHADOW_TREE) ? nullptr : mDocument;
rv = container->BindToTree(bindDocument, aParentContent, aParentContent, true);
if (NS_FAILED(rv)) {
container->UnbindFromTree();
return;
@ -4050,7 +4055,13 @@ nsCSSFrameConstructor::GetAnonymousContent(nsIContent* aParent,
ConnectAnonymousTreeDescendants(content, aContent[i].mChildren);
bool anonContentIsEditable = content->HasFlag(NODE_IS_EDITABLE);
rv = content->BindToTree(mDocument, aParent, aParent, true);
// If the parent is in a shadow tree, make sure we don't
// bind with a document because shadow roots and its descendants
// are not in document.
nsIDocument* bindDocument =
aParent->HasFlag(NODE_IS_IN_SHADOW_TREE) ? nullptr : mDocument;
rv = content->BindToTree(bindDocument, aParent, aParent, 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