nsTextNode.h (1731B)
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 nsTextNode_h 8 #define nsTextNode_h 9 10 /* 11 * Implementation of DOM Core's Text node. 12 */ 13 14 #include "mozilla/dom/Text.h" 15 #include "nsDebug.h" 16 17 class nsNodeInfoManager; 18 19 /** 20 * Class used to implement DOM text nodes 21 */ 22 class nsTextNode : public mozilla::dom::Text { 23 private: 24 void Init() { 25 MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE, "Bad NodeType in aNodeInfo"); 26 } 27 28 public: 29 explicit nsTextNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) 30 : mozilla::dom::Text(std::move(aNodeInfo)) { 31 Init(); 32 } 33 34 explicit nsTextNode(nsNodeInfoManager* aNodeInfoManager) 35 : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) { 36 Init(); 37 } 38 39 // nsISupports 40 NS_DECL_ISUPPORTS_INHERITED 41 42 // nsINode 43 already_AddRefed<CharacterData> CloneDataNode( 44 mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override; 45 46 nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength, 47 bool aNotify, nsIContent* aNextSibling); 48 49 #ifdef MOZ_DOM_LIST 50 virtual void List(FILE* out, int32_t aIndent) const override; 51 virtual void DumpContent(FILE* out, int32_t aIndent, 52 bool aDumpAll) const override; 53 #endif 54 55 protected: 56 virtual ~nsTextNode(); 57 58 virtual JSObject* WrapNode(JSContext* aCx, 59 JS::Handle<JSObject*> aGivenProto) override; 60 }; 61 62 #endif // nsTextNode_h