Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/base/Comment.cpp
Line
Count
Source (jump to first uncovered line)
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
/*
8
 * Implementations of DOM Core's Comment node.
9
 */
10
11
#include "nsCOMPtr.h"
12
#include "mozilla/dom/Comment.h"
13
#include "mozilla/dom/CommentBinding.h"
14
#include "mozilla/IntegerPrintfMacros.h"
15
16
using namespace mozilla;
17
using namespace dom;
18
19
namespace mozilla {
20
namespace dom {
21
22
Comment::~Comment()
23
{
24
}
25
26
already_AddRefed<CharacterData>
27
Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
28
0
{
29
0
  RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
30
0
  RefPtr<Comment> it = new Comment(ni.forget());
31
0
  if (aCloneText) {
32
0
    it->mText = mText;
33
0
  }
34
0
35
0
  return it.forget();
36
0
}
37
38
#ifdef DEBUG
39
void
40
Comment::List(FILE* out, int32_t aIndent) const
41
{
42
  int32_t indx;
43
  for (indx = aIndent; --indx >= 0; ) fputs("  ", out);
44
45
  fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this, mRefCnt.get());
46
47
  nsAutoString tmp;
48
  ToCString(tmp, 0, mText.GetLength());
49
  fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
50
51
  fputs("-->\n", out);
52
}
53
#endif
54
55
/* static */ already_AddRefed<Comment>
56
Comment::Constructor(const GlobalObject& aGlobal,
57
                     const nsAString& aData, ErrorResult& aRv)
58
0
{
59
0
  nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
60
0
  if (!window || !window->GetDoc()) {
61
0
    aRv.Throw(NS_ERROR_FAILURE);
62
0
    return nullptr;
63
0
  }
64
0
65
0
  return window->GetDoc()->CreateComment(aData);
66
0
}
67
68
JSObject*
69
Comment::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
70
0
{
71
0
  return Comment_Binding::Wrap(aCx, this, aGivenProto);
72
0
}
73
74
} // namespace dom
75
} // namespace mozilla