michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Implementations of DOM Core's nsIDOMComment node. michael@0: */ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "mozilla/dom/Comment.h" michael@0: #include "mozilla/dom/CommentBinding.h" michael@0: #include "mozilla/IntegerPrintfMacros.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace dom; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: Comment::~Comment() michael@0: { michael@0: } michael@0: michael@0: NS_IMPL_ISUPPORTS_INHERITED(Comment, nsGenericDOMDataNode, nsIDOMNode, michael@0: nsIDOMCharacterData, nsIDOMComment) michael@0: michael@0: bool michael@0: Comment::IsNodeOfType(uint32_t aFlags) const michael@0: { michael@0: return !(aFlags & ~(eCONTENT | eCOMMENT | eDATA_NODE)); michael@0: } michael@0: michael@0: nsGenericDOMDataNode* michael@0: Comment::CloneDataNode(nsINodeInfo *aNodeInfo, bool aCloneText) const michael@0: { michael@0: nsCOMPtr ni = aNodeInfo; michael@0: Comment *it = new Comment(ni.forget()); michael@0: if (it && aCloneText) { michael@0: it->mText = mText; michael@0: } michael@0: michael@0: return it; michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: void michael@0: Comment::List(FILE* out, int32_t aIndent) const michael@0: { michael@0: int32_t indx; michael@0: for (indx = aIndent; --indx >= 0; ) fputs(" ", out); michael@0: michael@0: fprintf(out, "Comment@%p refcount=%" PRIuPTR "\n", out); michael@0: } michael@0: #endif michael@0: michael@0: /* static */ already_AddRefed michael@0: Comment::Constructor(const GlobalObject& aGlobal, michael@0: const nsAString& aData, ErrorResult& aRv) michael@0: { michael@0: nsCOMPtr window = do_QueryInterface(aGlobal.GetAsSupports()); michael@0: if (!window || !window->GetDoc()) { michael@0: aRv.Throw(NS_ERROR_FAILURE); michael@0: return nullptr; michael@0: } michael@0: michael@0: return window->GetDoc()->CreateComment(aData); michael@0: } michael@0: michael@0: JSObject* michael@0: Comment::WrapNode(JSContext *aCx) michael@0: { michael@0: return CommentBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla