Bug 1550519 - Show a translucent parent highlight when a subgrid is highlighted....
[gecko.git] / dom / base / Comment.cpp
blob898d696492305b3b26a51f15122b125d35dc1cef
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 * Implementations of DOM Core's Comment node.
9 */
11 #include "nsCOMPtr.h"
12 #include "mozilla/dom/Comment.h"
13 #include "mozilla/dom/CommentBinding.h"
14 #include "mozilla/IntegerPrintfMacros.h"
16 using namespace mozilla;
17 using namespace dom;
19 namespace mozilla {
20 namespace dom {
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());
28 if (aCloneText) {
29 it->mText = mText;
32 return it.forget();
35 #ifdef DEBUG
36 void Comment::List(FILE* out, int32_t aIndent) const {
37 int32_t indx;
38 for (indx = aIndent; --indx >= 0;) fputs(" ", out);
40 fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this,
41 mRefCnt.get());
43 nsAutoString tmp;
44 ToCString(tmp, 0, mText.GetLength());
45 fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
47 fputs("-->\n", out);
49 #endif
51 /* static */
52 already_AddRefed<Comment> Comment::Constructor(const GlobalObject& aGlobal,
53 const nsAString& aData,
54 ErrorResult& aRv) {
55 nsCOMPtr<nsPIDOMWindowInner> window =
56 do_QueryInterface(aGlobal.GetAsSupports());
57 if (!window || !window->GetDoc()) {
58 aRv.Throw(NS_ERROR_FAILURE);
59 return nullptr;
62 return window->GetDoc()->CreateComment(aData);
65 JSObject* Comment::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
66 return Comment_Binding::Wrap(aCx, this, aGivenProto);
69 } // namespace dom
70 } // namespace mozilla