1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/HTMLTemplateElement.h"
7 #include "mozilla/dom/HTMLTemplateElementBinding.h"
10 #include "nsStyleConsts.h"
12 #include "nsRuleData.h"
14 NS_IMPL_NS_NEW_HTML_ELEMENT(Template
)
19 HTMLTemplateElement::HTMLTemplateElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
)
20 : nsGenericHTMLElement(aNodeInfo
)
22 SetHasWeirdParserInsertionMode();
24 nsIDocument
* contentsOwner
= OwnerDoc()->GetTemplateContentsOwner();
26 MOZ_CRASH("There should always be a template contents owner.");
29 mContent
= contentsOwner
->CreateDocumentFragment();
30 mContent
->SetHost(this);
33 HTMLTemplateElement::~HTMLTemplateElement()
36 mContent
->SetHost(nullptr);
40 NS_IMPL_ADDREF_INHERITED(HTMLTemplateElement
, Element
)
41 NS_IMPL_RELEASE_INHERITED(HTMLTemplateElement
, Element
)
43 NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTemplateElement
)
45 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTemplateElement
,
48 tmp
->mContent
->SetHost(nullptr);
49 tmp
->mContent
= nullptr;
51 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
53 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTemplateElement
,
55 NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent
)
56 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
58 // QueryInterface implementation for HTMLTemplateElement
59 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(HTMLTemplateElement
)
60 NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement
)
62 NS_IMPL_ELEMENT_CLONE(HTMLTemplateElement
)
65 HTMLTemplateElement::WrapNode(JSContext
*aCx
)
67 return HTMLTemplateElementBinding::Wrap(aCx
, this);
71 } // namespace mozilla