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/. */
8 * Implementations of DOM Core's Comment node.
12 #include "mozilla/dom/Comment.h"
13 #include "mozilla/dom/CommentBinding.h"
14 #include "mozilla/IntegerPrintfMacros.h"
16 using namespace mozilla
;
22 Comment::~Comment() {}
24 already_AddRefed
<CharacterData
> Comment::CloneDataNode(
25 mozilla::dom::NodeInfo
* aNodeInfo
, bool aCloneText
) const {
26 RefPtr
<mozilla::dom::NodeInfo
> ni
= aNodeInfo
;
27 RefPtr
<Comment
> it
= new Comment(ni
.forget());
36 void Comment::List(FILE* out
, int32_t aIndent
) const {
38 for (indx
= aIndent
; --indx
>= 0;) fputs(" ", out
);
40 fprintf(out
, "Comment@%p refcount=%" PRIuPTR
"<!--", (void*)this,
44 ToCString(tmp
, 0, mText
.GetLength());
45 fputs(NS_LossyConvertUTF16toASCII(tmp
).get(), out
);
52 already_AddRefed
<Comment
> Comment::Constructor(const GlobalObject
& aGlobal
,
53 const nsAString
& aData
,
55 nsCOMPtr
<nsPIDOMWindowInner
> window
=
56 do_QueryInterface(aGlobal
.GetAsSupports());
57 if (!window
|| !window
->GetDoc()) {
58 aRv
.Throw(NS_ERROR_FAILURE
);
62 return window
->GetDoc()->CreateComment(aData
);
65 JSObject
* Comment::WrapNode(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
66 return Comment_Binding::Wrap(aCx
, this, aGivenProto
);
70 } // namespace mozilla