Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/DocumentFragment.h
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
#ifndef mozilla_dom_DocumentFragment_h__
8
#define mozilla_dom_DocumentFragment_h__
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/dom/BorrowedAttrInfo.h"
12
#include "mozilla/dom/FragmentOrElement.h"
13
#include "nsStringFwd.h"
14
15
class nsAtom;
16
class nsIDocument;
17
class nsIContent;
18
19
namespace mozilla {
20
namespace dom {
21
22
class Element;
23
24
class DocumentFragment : public FragmentOrElement
25
{
26
private:
27
  void Init()
28
0
  {
29
0
    MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_FRAGMENT_NODE &&
30
0
               mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
31
0
                                 kNameSpaceID_None),
32
0
               "Bad NodeType in aNodeInfo");
33
0
  }
34
35
public:
36
  using FragmentOrElement::GetFirstChild;
37
  using nsINode::QuerySelector;
38
  using nsINode::QuerySelectorAll;
39
  // Make sure bindings can see our superclass' protected GetElementById method.
40
  using nsINode::GetElementById;
41
42
  // nsISupports
43
  NS_DECL_ISUPPORTS_INHERITED
44
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment, FragmentOrElement)
45
46
  explicit DocumentFragment(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
47
    : FragmentOrElement(std::move(aNodeInfo)), mHost(nullptr)
48
0
  {
49
0
    Init();
50
0
  }
51
52
  explicit DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
53
    : FragmentOrElement(aNodeInfoManager->GetNodeInfo(
54
                                            nsGkAtoms::documentFragmentNodeName,
55
                                            nullptr, kNameSpaceID_None,
56
                                            DOCUMENT_FRAGMENT_NODE)),
57
      mHost(nullptr)
58
0
  {
59
0
    Init();
60
0
  }
61
62
  virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
63
64
  virtual bool IsNodeOfType(uint32_t aFlags) const override;
65
66
  nsresult BindToTree(nsIDocument* aDocument,
67
                      nsIContent* aParent,
68
                      nsIContent* aBindingParent) override
69
0
  {
70
0
    NS_ASSERTION(false, "Trying to bind a fragment to a tree");
71
0
    return NS_ERROR_NOT_IMPLEMENTED;
72
0
  }
73
74
  virtual void UnbindFromTree(bool aDeep, bool aNullParent) override
75
0
  {
76
0
    NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
77
0
  }
78
79
  virtual Element* GetNameSpaceElement() override
80
0
  {
81
0
    return nullptr;
82
0
  }
83
84
0
  Element* GetHost() const { return mHost; }
85
86
0
  void SetHost(Element* aHost) { mHost = aHost; }
87
88
  static already_AddRefed<DocumentFragment>
89
  Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
90
91
#ifdef DEBUG
92
  virtual void List(FILE* out, int32_t aIndent) const override;
93
  virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override;
94
#endif
95
96
protected:
97
  virtual ~DocumentFragment()
98
0
  {
99
0
  }
100
101
  nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
102
  RefPtr<Element> mHost;
103
};
104
105
} // namespace dom
106
} // namespace mozilla
107
108
inline mozilla::dom::DocumentFragment*
109
nsINode::AsDocumentFragment()
110
0
{
111
0
  MOZ_ASSERT(IsDocumentFragment());
112
0
  return static_cast<mozilla::dom::DocumentFragment*>(this);
113
0
}
114
115
inline const mozilla::dom::DocumentFragment*
116
nsINode::AsDocumentFragment() const
117
0
{
118
0
  MOZ_ASSERT(IsDocumentFragment());
119
0
  return static_cast<const mozilla::dom::DocumentFragment*>(this);
120
0
}
121
122
#endif // mozilla_dom_DocumentFragment_h__