|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsTextNode_h |
|
7 #define nsTextNode_h |
|
8 |
|
9 /* |
|
10 * Implementation of DOM Core's nsIDOMText node. |
|
11 */ |
|
12 |
|
13 #include "mozilla/Attributes.h" |
|
14 #include "mozilla/dom/Text.h" |
|
15 #include "nsIDOMText.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 public nsIDOMText |
|
25 { |
|
26 private: |
|
27 void Init() |
|
28 { |
|
29 NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::TEXT_NODE, |
|
30 "Bad NodeType in aNodeInfo"); |
|
31 } |
|
32 |
|
33 public: |
|
34 nsTextNode(already_AddRefed<nsINodeInfo>& aNodeInfo) |
|
35 : mozilla::dom::Text(aNodeInfo) |
|
36 { |
|
37 Init(); |
|
38 } |
|
39 |
|
40 nsTextNode(nsNodeInfoManager* aNodeInfoManager) |
|
41 : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) |
|
42 { |
|
43 Init(); |
|
44 } |
|
45 |
|
46 virtual ~nsTextNode(); |
|
47 |
|
48 // nsISupports |
|
49 NS_DECL_ISUPPORTS_INHERITED |
|
50 |
|
51 // nsIDOMNode |
|
52 NS_FORWARD_NSIDOMNODE_TO_NSINODE |
|
53 |
|
54 // nsIDOMCharacterData |
|
55 NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::) |
|
56 using nsGenericDOMDataNode::SetData; // Prevent hiding overloaded virtual function. |
|
57 |
|
58 // nsIDOMText |
|
59 NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) |
|
60 |
|
61 // nsINode |
|
62 virtual bool IsNodeOfType(uint32_t aFlags) const; |
|
63 |
|
64 virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, |
|
65 bool aCloneText) const MOZ_OVERRIDE; |
|
66 |
|
67 virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
|
68 nsIContent* aBindingParent, |
|
69 bool aCompileEventHandlers) MOZ_OVERRIDE; |
|
70 virtual void UnbindFromTree(bool aDeep = true, |
|
71 bool aNullParent = true) MOZ_OVERRIDE; |
|
72 |
|
73 nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength, |
|
74 bool aNotify, nsIContent* aNextSibling); |
|
75 |
|
76 virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } |
|
77 |
|
78 #ifdef DEBUG |
|
79 virtual void List(FILE* out, int32_t aIndent) const MOZ_OVERRIDE; |
|
80 virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const MOZ_OVERRIDE; |
|
81 #endif |
|
82 |
|
83 protected: |
|
84 virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE; |
|
85 }; |
|
86 |
|
87 #endif // nsTextNode_h |