Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/html/HTMLTemplateElement.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "mozilla/dom/HTMLTemplateElement.h"
8
#include "mozilla/dom/HTMLTemplateElementBinding.h"
9
10
#include "mozilla/MappedDeclarations.h"
11
#include "nsGkAtoms.h"
12
#include "nsStyleConsts.h"
13
#include "nsAtom.h"
14
15
NS_IMPL_NS_NEW_HTML_ELEMENT(Template)
16
17
namespace mozilla {
18
namespace dom {
19
20
HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
21
  : nsGenericHTMLElement(std::move(aNodeInfo))
22
0
{
23
0
  SetHasWeirdParserInsertionMode();
24
0
25
0
  nsIDocument* contentsOwner = OwnerDoc()->GetTemplateContentsOwner();
26
0
  if (!contentsOwner) {
27
0
    MOZ_CRASH("There should always be a template contents owner.");
28
0
  }
29
0
30
0
  mContent = contentsOwner->CreateDocumentFragment();
31
0
  mContent->SetHost(this);
32
0
}
33
34
HTMLTemplateElement::~HTMLTemplateElement()
35
0
{
36
0
  if (mContent) {
37
0
    mContent->SetHost(nullptr);
38
0
  }
39
0
}
40
41
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLTemplateElement,
42
                                               nsGenericHTMLElement)
43
44
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTemplateElement)
45
46
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTemplateElement,
47
0
                                                nsGenericHTMLElement)
48
0
  if (tmp->mContent) {
49
0
    tmp->mContent->SetHost(nullptr);
50
0
    tmp->mContent = nullptr;
51
0
  }
52
0
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
53
54
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTemplateElement,
55
0
                                                  nsGenericHTMLElement)
56
0
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent)
57
0
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
58
59
NS_IMPL_ELEMENT_CLONE(HTMLTemplateElement)
60
61
JSObject*
62
HTMLTemplateElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
63
0
{
64
0
  return HTMLTemplateElement_Binding::Wrap(aCx, this, aGivenProto);
65
0
}
66
67
} // namespace dom
68
} // namespace mozilla
69