Bug 1908539 restrict MacOS platform audio processing to Nightly r=webrtc-reviewers...
[gecko.git] / dom / base / DocumentFragment.h
blob9b8cc69673978cf8457cb835e5a41bdb22078d2a
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/. */
7 #ifndef mozilla_dom_DocumentFragment_h__
8 #define mozilla_dom_DocumentFragment_h__
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/BorrowedAttrInfo.h"
12 #include "mozilla/dom/FragmentOrElement.h"
13 #include "nsStringFwd.h"
15 // XXX Avoid including this here by moving function bodies to the cpp file.
16 #include "mozilla/dom/Element.h"
18 class nsAtom;
19 class nsIContent;
21 namespace mozilla::dom {
23 class Document;
24 class Element;
26 class DocumentFragment : public FragmentOrElement {
27 private:
28 void Init() {
29 MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_FRAGMENT_NODE &&
30 mNodeInfo->Equals(nsGkAtoms::documentFragmentNodeName,
31 kNameSpaceID_None),
32 "Bad NodeType in aNodeInfo");
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;
42 // nsISupports
43 NS_DECL_ISUPPORTS_INHERITED
44 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment, FragmentOrElement)
46 explicit DocumentFragment(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
47 : FragmentOrElement(std::move(aNodeInfo)), mHost(nullptr) {
48 Init();
51 explicit DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
52 : FragmentOrElement(aNodeInfoManager->GetNodeInfo(
53 nsGkAtoms::documentFragmentNodeName, nullptr, kNameSpaceID_None,
54 DOCUMENT_FRAGMENT_NODE)),
55 mHost(nullptr) {
56 Init();
59 NS_IMPL_FROMNODE_HELPER(DocumentFragment, IsDocumentFragment());
61 JSObject* WrapNode(JSContext* aCx,
62 JS::Handle<JSObject*> aGivenProto) override;
64 nsresult BindToTree(BindContext&, nsINode& aParent) override {
65 NS_ASSERTION(false, "Trying to bind a fragment to a tree");
66 return NS_ERROR_NOT_IMPLEMENTED;
69 virtual void UnbindFromTree(UnbindContext&) override {
70 NS_ASSERTION(false, "Trying to unbind a fragment from a tree");
73 Element* GetNameSpaceElement() override { return nullptr; }
75 Element* GetHost() const { return mHost; }
77 void SetHost(Element* aHost) { mHost = aHost; }
79 void GetInnerHTML(nsAString& aInnerHTML) { GetMarkup(false, aInnerHTML); }
80 void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError) {
81 SetInnerHTMLInternal(aInnerHTML, aError);
84 static already_AddRefed<DocumentFragment> Constructor(
85 const GlobalObject& aGlobal, ErrorResult& aRv);
87 #ifdef MOZ_DOM_LIST
88 virtual void List(FILE* out, int32_t aIndent) const override;
89 virtual void DumpContent(FILE* out, int32_t aIndent,
90 bool aDumpAll) const override;
91 #endif
93 protected:
94 virtual ~DocumentFragment() = default;
96 nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
97 RefPtr<Element> mHost;
100 } // namespace mozilla::dom
102 inline mozilla::dom::DocumentFragment* nsINode::AsDocumentFragment() {
103 MOZ_ASSERT(IsDocumentFragment());
104 return static_cast<mozilla::dom::DocumentFragment*>(this);
107 inline const mozilla::dom::DocumentFragment* nsINode::AsDocumentFragment()
108 const {
109 MOZ_ASSERT(IsDocumentFragment());
110 return static_cast<const mozilla::dom::DocumentFragment*>(this);
113 #endif // mozilla_dom_DocumentFragment_h__