Bug 1319255 part 3. Don't create special elements for <shadow> and <content> unless webcomponents are enabled. r=wchen

This commit is contained in:
Boris Zbarsky
2016-11-22 22:41:51 -05:00
parent 8bef5cc522
commit e70d825476
4 changed files with 73 additions and 4 deletions

View File

@@ -8,10 +8,31 @@
#include "ChildIterator.h"
#include "nsContentUtils.h"
#include "nsDocument.h"
#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "mozilla/dom/HTMLShadowElementBinding.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Shadow)
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Shadow) to add check for web components
// being enabled.
nsGenericHTMLElement*
NS_NewHTMLShadowElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
// When this check is removed, remove the nsDocument.h and
// HTMLUnknownElement.h includes. Also remove nsINode::IsHTMLShadowElement.
//
// We have to jump through some hoops to be able to produce both NodeInfo* and
// already_AddRefed<NodeInfo>& for our callees.
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
if (!nsDocument::IsWebComponentsEnabled(nodeInfo)) {
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
}
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
return new mozilla::dom::HTMLShadowElement(nodeInfoArg);
}
using namespace mozilla::dom;