Bumping gaia.json for 8 gaia revision(s) a=gaia-bump
[gecko.git] / dom / html / HTMLTemplateElement.cpp
blob2773213f719c6d520778534d96a8877938c30a14
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"
9 #include "nsGkAtoms.h"
10 #include "nsStyleConsts.h"
11 #include "nsIAtom.h"
12 #include "nsRuleData.h"
14 NS_IMPL_NS_NEW_HTML_ELEMENT(Template)
16 namespace mozilla {
17 namespace dom {
19 HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
20 : nsGenericHTMLElement(aNodeInfo)
22 SetHasWeirdParserInsertionMode();
24 nsIDocument* contentsOwner = OwnerDoc()->GetTemplateContentsOwner();
25 if (!contentsOwner) {
26 MOZ_CRASH("There should always be a template contents owner.");
29 mContent = contentsOwner->CreateDocumentFragment();
30 mContent->SetHost(this);
33 HTMLTemplateElement::~HTMLTemplateElement()
35 if (mContent) {
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,
46 nsGenericHTMLElement)
47 if (tmp->mContent) {
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,
54 nsGenericHTMLElement)
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)
64 JSObject*
65 HTMLTemplateElement::WrapNode(JSContext *aCx)
67 return HTMLTemplateElementBinding::Wrap(aCx, this);
70 } // namespace dom
71 } // namespace mozilla