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