LCOV - code coverage report
Current view: top level - dom/base - Comment.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 9 27 33.3 %
Date: 2017-07-14 16:53:18 Functions: 5 10 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 nsIDOMComment 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           0 : Comment::~Comment()
      23             : {
      24           0 : }
      25             : 
      26         283 : NS_IMPL_ISUPPORTS_INHERITED(Comment, nsGenericDOMDataNode, nsIDOMNode,
      27             :                             nsIDOMCharacterData, nsIDOMComment)
      28             : 
      29             : bool
      30         134 : Comment::IsNodeOfType(uint32_t aFlags) const
      31             : {
      32         134 :   return !(aFlags & ~(eCONTENT | eCOMMENT | eDATA_NODE));
      33             : }
      34             : 
      35             : nsGenericDOMDataNode*
      36           7 : Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
      37             : {
      38          14 :   RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
      39          14 :   Comment *it = new Comment(ni.forget());
      40           7 :   if (it && aCloneText) {
      41           7 :     it->mText = mText;
      42             :   }
      43             : 
      44          14 :   return it;
      45             : }
      46             : 
      47             : #ifdef DEBUG
      48             : void
      49           0 : Comment::List(FILE* out, int32_t aIndent) const
      50             : {
      51             :   int32_t indx;
      52           0 :   for (indx = aIndent; --indx >= 0; ) fputs("  ", out);
      53             : 
      54           0 :   fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this, mRefCnt.get());
      55             : 
      56           0 :   nsAutoString tmp;
      57           0 :   ToCString(tmp, 0, mText.GetLength());
      58           0 :   fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
      59             : 
      60           0 :   fputs("-->\n", out);
      61           0 : }
      62             : #endif
      63             : 
      64             : /* static */ already_AddRefed<Comment>
      65           0 : Comment::Constructor(const GlobalObject& aGlobal,
      66             :                      const nsAString& aData, ErrorResult& aRv)
      67             : {
      68           0 :   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
      69           0 :   if (!window || !window->GetDoc()) {
      70           0 :     aRv.Throw(NS_ERROR_FAILURE);
      71           0 :     return nullptr;
      72             :   }
      73             : 
      74           0 :   return window->GetDoc()->CreateComment(aData);
      75             : }
      76             : 
      77             : JSObject*
      78           0 : Comment::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
      79             : {
      80           0 :   return CommentBinding::Wrap(aCx, this, aGivenProto);
      81             : }
      82             : 
      83             : } // namespace dom
      84             : } // namespace mozilla

Generated by: LCOV version 1.13