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: #ifndef nsTextNode_h michael@0: #define nsTextNode_h michael@0: michael@0: /* michael@0: * Implementation of DOM Core's nsIDOMText node. michael@0: */ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/dom/Text.h" michael@0: #include "nsIDOMText.h" michael@0: #include "nsDebug.h" michael@0: michael@0: class nsNodeInfoManager; michael@0: michael@0: /** michael@0: * Class used to implement DOM text nodes michael@0: */ michael@0: class nsTextNode : public mozilla::dom::Text, michael@0: public nsIDOMText michael@0: { michael@0: private: michael@0: void Init() michael@0: { michael@0: NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE, michael@0: "Bad NodeType in aNodeInfo"); michael@0: } michael@0: michael@0: public: michael@0: nsTextNode(already_AddRefed& aNodeInfo) michael@0: : mozilla::dom::Text(aNodeInfo) michael@0: { michael@0: Init(); michael@0: } michael@0: michael@0: nsTextNode(nsNodeInfoManager* aNodeInfoManager) michael@0: : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) michael@0: { michael@0: Init(); michael@0: } michael@0: michael@0: virtual ~nsTextNode(); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIDOMNode michael@0: NS_FORWARD_NSIDOMNODE_TO_NSINODE michael@0: michael@0: // nsIDOMCharacterData michael@0: NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::) michael@0: using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function. michael@0: michael@0: // nsIDOMText michael@0: NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) michael@0: michael@0: // nsINode michael@0: virtual bool IsNodeOfType(uint32_t aFlags) const; michael@0: michael@0: virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, michael@0: bool aCloneText) const MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, michael@0: nsIContent* aBindingParent, michael@0: bool aCompileEventHandlers) MOZ_OVERRIDE; michael@0: virtual void UnbindFromTree(bool aDeep = true, michael@0: bool aNullParent = true) MOZ_OVERRIDE; michael@0: michael@0: nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength, michael@0: bool aNotify, nsIContent* aNextSibling); michael@0: michael@0: virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } michael@0: michael@0: #ifdef DEBUG michael@0: virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE; michael@0: virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE; michael@0: #endif michael@0: michael@0: protected: michael@0: virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: #endif // nsTextNode_h