Bug 1598841 - nsCanvasFrame anonymous content needs to be document-level. r=bdahl,heycam

Otherwise code like StyleChildrenIterator won't find it, plus it is the right
thing to do anyway.

You don't really want this to inherit from the root element, even though given
this content is under our control (only in chrome documents) it is less of an
issue.

Differential Revision: https://phabricator.services.mozilla.com/D56637

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-12-11 22:27:07 +00:00
parent e642c8a1b2
commit 51c8170136
2 changed files with 16 additions and 4 deletions

View File

@ -9419,11 +9419,8 @@ void nsContentUtils::AppendDocumentLevelNativeAnonymousContentTo(
"scroll frame should always implement nsIAnonymousContentCreator");
creator->AppendAnonymousContentTo(aElements, 0);
}
if (nsCanvasFrame* canvasFrame = presShell->GetCanvasFrame()) {
if (Element* container = canvasFrame->GetCustomContentContainer()) {
aElements.AppendElement(container);
}
canvasFrame->AppendAnonymousContentTo(aElements, 0);
}
}

View File

@ -159,6 +159,9 @@ nsresult nsCanvasFrame::CreateAnonymousContent(
nodeInfo.forget(), dom::NOT_FROM_PARSER);
NS_ENSURE_SUCCESS(rv, rv);
mPopupgroupContent->SetProperty(nsGkAtoms::docLevelNativeAnonymousContent,
reinterpret_cast<void*>(true));
aElements.AppendElement(mPopupgroupContent);
nodeInfo = nodeInfoManager->GetNodeInfo(
@ -175,9 +178,21 @@ nsresult nsCanvasFrame::CreateAnonymousContent(
mTooltipContent->SetAttr(kNameSpaceID_None, nsGkAtoms::page,
NS_LITERAL_STRING("true"), false);
mTooltipContent->SetProperty(nsGkAtoms::docLevelNativeAnonymousContent,
reinterpret_cast<void*>(true));
aElements.AppendElement(mTooltipContent);
}
#ifdef DEBUG
for (auto& element : aElements) {
MOZ_ASSERT(element.mContent->GetProperty(
nsGkAtoms::docLevelNativeAnonymousContent),
"NAC from the canvas frame needs to be document-level, otherwise"
" it (1) inherits from the document which is unexpected, and (2)"
" StyleChildrenIterator won't be able to find it properly");
}
#endif
return NS_OK;
}