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 #ifndef mozilla_dom_Comment_h 8 #define mozilla_dom_Comment_h 9 10 #include "mozilla/Attributes.h" 11 #include "mozilla/dom/CharacterData.h" 12 13 namespace mozilla { 14 namespace dom { 15 16 class Comment final : public CharacterData { 17 private: Init()18 void Init() { 19 MOZ_ASSERT(mNodeInfo->NodeType() == COMMENT_NODE, 20 "Bad NodeType in aNodeInfo"); 21 } 22 23 virtual ~Comment(); 24 25 public: Comment(already_AddRefed<mozilla::dom::NodeInfo> && aNodeInfo)26 explicit Comment(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) 27 : CharacterData(std::move(aNodeInfo)) { 28 Init(); 29 } 30 Comment(nsNodeInfoManager * aNodeInfoManager)31 explicit Comment(nsNodeInfoManager* aNodeInfoManager) 32 : CharacterData(aNodeInfoManager->GetCommentNodeInfo()) { 33 Init(); 34 } 35 36 NS_IMPL_FROMNODE_HELPER(Comment, IsComment()) 37 38 // nsISupports 39 NS_INLINE_DECL_REFCOUNTING_INHERITED(Comment, CharacterData) 40 41 virtual already_AddRefed<CharacterData> CloneDataNode( 42 mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override; 43 44 #ifdef DEBUG 45 virtual void List(FILE* out, int32_t aIndent) const override; 46 virtual void DumpContent(FILE* out = stdout, int32_t aIndent = 0, 47 bool aDumpAll = true) const override { 48 return; 49 } 50 #endif 51 52 static already_AddRefed<Comment> Constructor(const GlobalObject& aGlobal, 53 const nsAString& aData, 54 ErrorResult& aRv); 55 56 protected: 57 virtual JSObject* WrapNode(JSContext* aCx, 58 JS::Handle<JSObject*> aGivenProto) override; 59 }; 60 61 } // namespace dom 62 } // namespace mozilla 63 64 #endif // mozilla_dom_Comment_h 65