Bug 1835710 - Cancel off-thread JIT compilation before changing nursery allocation...
[gecko.git] / dom / base / DocumentFragment.cpp
blob62cc75fd20b1ac89221f6302ad4fcd454889cdca
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 /*
8 * Implementation of DOM Core's DocumentFragment.
9 */
11 #include "mozilla/dom/DocumentFragment.h"
12 #include "mozilla/dom/Element.h" // for NS_IMPL_ELEMENT_CLONE
13 #include "mozilla/dom/NodeInfo.h"
14 #include "nsNodeInfoManager.h"
15 #include "nsError.h"
16 #include "nsGkAtoms.h"
17 #include "nsDOMString.h"
18 #include "nsContentUtils.h" // for NS_INTERFACE_MAP_ENTRY_TEAROFF
19 #include "mozilla/dom/DocumentFragmentBinding.h"
20 #include "nsPIDOMWindow.h"
21 #include "mozilla/dom/Document.h"
22 #include "mozilla/IntegerPrintfMacros.h"
24 namespace mozilla::dom {
26 JSObject* DocumentFragment::WrapNode(JSContext* aCx,
27 JS::Handle<JSObject*> aGivenProto) {
28 return DocumentFragment_Binding::Wrap(aCx, this, aGivenProto);
31 #ifdef MOZ_DOM_LIST
32 void DocumentFragment::List(FILE* out, int32_t aIndent) const {
33 int32_t indent;
34 for (indent = aIndent; --indent >= 0;) {
35 fputs(" ", out);
38 fprintf(out, "DocumentFragment@%p", (void*)this);
40 fprintf(out, " flags=[%08x]", static_cast<unsigned int>(GetFlags()));
41 fprintf(out, " refcount=%" PRIuPTR "<", mRefCnt.get());
43 nsIContent* child = GetFirstChild();
44 if (child) {
45 fputs("\n", out);
47 for (; child; child = child->GetNextSibling()) {
48 child->List(out, aIndent + 1);
51 for (indent = aIndent; --indent >= 0;) {
52 fputs(" ", out);
56 fputs(">\n", out);
59 void DocumentFragment::DumpContent(FILE* out, int32_t aIndent,
60 bool aDumpAll) const {
61 int32_t indent;
62 for (indent = aIndent; --indent >= 0;) {
63 fputs(" ", out);
66 fputs("<DocumentFragment>", out);
68 if (aIndent) {
69 fputs("\n", out);
72 for (nsIContent* child = GetFirstChild(); child;
73 child = child->GetNextSibling()) {
74 int32_t indent = aIndent ? aIndent + 1 : 0;
75 child->DumpContent(out, indent, aDumpAll);
77 for (indent = aIndent; --indent >= 0;) {
78 fputs(" ", out);
80 fputs("</DocumentFragment>", out);
82 if (aIndent) {
83 fputs("\n", out);
86 #endif
88 /* static */
89 already_AddRefed<DocumentFragment> DocumentFragment::Constructor(
90 const GlobalObject& aGlobal, ErrorResult& aRv) {
91 nsCOMPtr<nsPIDOMWindowInner> window =
92 do_QueryInterface(aGlobal.GetAsSupports());
93 if (!window || !window->GetDoc()) {
94 aRv.Throw(NS_ERROR_FAILURE);
95 return nullptr;
98 return window->GetDoc()->CreateDocumentFragment();
101 NS_IMPL_CYCLE_COLLECTION_INHERITED(DocumentFragment, FragmentOrElement, mHost)
103 // QueryInterface implementation for DocumentFragment
104 NS_INTERFACE_MAP_BEGIN(DocumentFragment)
105 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
106 NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(DocumentFragment)
107 NS_INTERFACE_MAP_ENTRY(nsIContent)
108 NS_INTERFACE_MAP_ENTRY(nsINode)
109 NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
110 NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
111 new nsNodeSupportsWeakRefTearoff(this))
112 // DOM bindings depend on the identity pointer being the
113 // same as nsINode (which nsIContent inherits).
114 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
115 NS_INTERFACE_MAP_END
117 NS_IMPL_ADDREF_INHERITED(DocumentFragment, FragmentOrElement)
118 NS_IMPL_RELEASE_INHERITED(DocumentFragment, FragmentOrElement)
120 NS_IMPL_ELEMENT_CLONE(DocumentFragment)
122 } // namespace mozilla::dom