diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 792633de9139..67d23dc32106 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -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); } } diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index e1d260f54707..d07eb06e1a44 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -159,6 +159,9 @@ nsresult nsCanvasFrame::CreateAnonymousContent( nodeInfo.forget(), dom::NOT_FROM_PARSER); NS_ENSURE_SUCCESS(rv, rv); + mPopupgroupContent->SetProperty(nsGkAtoms::docLevelNativeAnonymousContent, + reinterpret_cast(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(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; }