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/CDATASection.h"
8 #include "mozilla/dom/CDATASectionBinding.h"
9 #include "mozilla/IntegerPrintfMacros.h"
10 
11 namespace mozilla {
12 namespace dom {
13 
14 CDATASection::~CDATASection() = default;
15 
WrapNode(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)16 JSObject* CDATASection::WrapNode(JSContext* aCx,
17                                  JS::Handle<JSObject*> aGivenProto) {
18   return CDATASection_Binding::Wrap(aCx, this, aGivenProto);
19 }
20 
IsNodeOfType(uint32_t aFlags) const21 bool CDATASection::IsNodeOfType(uint32_t aFlags) const { return false; }
22 
CloneDataNode(mozilla::dom::NodeInfo * aNodeInfo,bool aCloneText) const23 already_AddRefed<CharacterData> CDATASection::CloneDataNode(
24     mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
25   RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
26   auto* nim = ni->NodeInfoManager();
27   RefPtr<CDATASection> it = new (nim) CDATASection(ni.forget());
28   if (aCloneText) {
29     it->mText = mText;
30   }
31 
32   return it.forget();
33 }
34 
35 #ifdef MOZ_DOM_LIST
List(FILE * out,int32_t aIndent) const36 void CDATASection::List(FILE* out, int32_t aIndent) const {
37   int32_t index;
38   for (index = aIndent; --index >= 0;) fputs("  ", out);
39 
40   fprintf(out, "CDATASection refcount=%" PRIuPTR "<", mRefCnt.get());
41 
42   nsAutoString tmp;
43   ToCString(tmp, 0, mText.GetLength());
44   fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
45 
46   fputs(">\n", out);
47 }
48 
DumpContent(FILE * out,int32_t aIndent,bool aDumpAll) const49 void CDATASection::DumpContent(FILE* out, int32_t aIndent,
50                                bool aDumpAll) const {}
51 #endif
52 
53 }  // namespace dom
54 }  // namespace mozilla
55