1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/src/nsTextNode.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef nsTextNode_h 1.10 +#define nsTextNode_h 1.11 + 1.12 +/* 1.13 + * Implementation of DOM Core's nsIDOMText node. 1.14 + */ 1.15 + 1.16 +#include "mozilla/Attributes.h" 1.17 +#include "mozilla/dom/Text.h" 1.18 +#include "nsIDOMText.h" 1.19 +#include "nsDebug.h" 1.20 + 1.21 +class nsNodeInfoManager; 1.22 + 1.23 +/** 1.24 + * Class used to implement DOM text nodes 1.25 + */ 1.26 +class nsTextNode : public mozilla::dom::Text, 1.27 + public nsIDOMText 1.28 +{ 1.29 +private: 1.30 + void Init() 1.31 + { 1.32 + NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE, 1.33 + "Bad NodeType in aNodeInfo"); 1.34 + } 1.35 + 1.36 +public: 1.37 + nsTextNode(already_AddRefed<nsINodeInfo>& aNodeInfo) 1.38 + : mozilla::dom::Text(aNodeInfo) 1.39 + { 1.40 + Init(); 1.41 + } 1.42 + 1.43 + nsTextNode(nsNodeInfoManager* aNodeInfoManager) 1.44 + : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) 1.45 + { 1.46 + Init(); 1.47 + } 1.48 + 1.49 + virtual ~nsTextNode(); 1.50 + 1.51 + // nsISupports 1.52 + NS_DECL_ISUPPORTS_INHERITED 1.53 + 1.54 + // nsIDOMNode 1.55 + NS_FORWARD_NSIDOMNODE_TO_NSINODE 1.56 + 1.57 + // nsIDOMCharacterData 1.58 + NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::) 1.59 + using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function. 1.60 + 1.61 + // nsIDOMText 1.62 + NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) 1.63 + 1.64 + // nsINode 1.65 + virtual bool IsNodeOfType(uint32_t aFlags) const; 1.66 + 1.67 + virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, 1.68 + bool aCloneText) const MOZ_OVERRIDE; 1.69 + 1.70 + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, 1.71 + nsIContent* aBindingParent, 1.72 + bool aCompileEventHandlers) MOZ_OVERRIDE; 1.73 + virtual void UnbindFromTree(bool aDeep = true, 1.74 + bool aNullParent = true) MOZ_OVERRIDE; 1.75 + 1.76 + nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength, 1.77 + bool aNotify, nsIContent* aNextSibling); 1.78 + 1.79 + virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } 1.80 + 1.81 +#ifdef DEBUG 1.82 + virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE; 1.83 + virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE; 1.84 +#endif 1.85 + 1.86 +protected: 1.87 + virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; 1.88 +}; 1.89 + 1.90 +#endif // nsTextNode_h