/src/mozilla-central/dom/base/nsTextNode.h
Line | Count | Source (jump to first uncovered line) |
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 | | { |
25 | | private: |
26 | | void Init() |
27 | 0 | { |
28 | 0 | MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE, |
29 | 0 | "Bad NodeType in aNodeInfo"); |
30 | 0 | } |
31 | | |
32 | | public: |
33 | | explicit nsTextNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) |
34 | | : mozilla::dom::Text(std::move(aNodeInfo)) |
35 | 0 | { |
36 | 0 | Init(); |
37 | 0 | } |
38 | | |
39 | | explicit nsTextNode(nsNodeInfoManager* aNodeInfoManager) |
40 | | : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo()) |
41 | 0 | { |
42 | 0 | Init(); |
43 | 0 | } |
44 | | |
45 | | // nsISupports |
46 | | NS_DECL_ISUPPORTS_INHERITED |
47 | | |
48 | | // nsINode |
49 | | virtual bool IsNodeOfType(uint32_t aFlags) const override; |
50 | | |
51 | | virtual already_AddRefed<CharacterData> |
52 | | CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, |
53 | | bool aCloneText) const override; |
54 | | |
55 | | virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
56 | | nsIContent* aBindingParent) override; |
57 | | virtual void UnbindFromTree(bool aDeep = true, |
58 | | bool aNullParent = true) override; |
59 | | |
60 | | nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength, |
61 | | bool aNotify, nsIContent* aNextSibling); |
62 | | |
63 | | // Need to have a copy here because including nsDocument.h in this file will |
64 | | // fail to build on Windows. |
65 | | static bool IsShadowDOMEnabled(JSContext* aCx, JSObject* aObject); |
66 | | |
67 | | #ifdef DEBUG |
68 | | virtual void List(FILE* out, int32_t aIndent) const override; |
69 | | virtual void DumpContent(FILE* out, int32_t aIndent, bool aDumpAll) const override; |
70 | | #endif |
71 | | |
72 | | protected: |
73 | | virtual ~nsTextNode(); |
74 | | |
75 | | virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; |
76 | | }; |
77 | | |
78 | | #endif // nsTextNode_h |