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 mozilla_dom_Text_h
8 #define mozilla_dom_Text_h
9 
10 #include "nsGenericDOMDataNode.h"
11 #include "mozilla/ErrorResult.h"
12 
13 namespace mozilla {
14 namespace dom {
15 
16 class Text : public nsGenericDOMDataNode
17 {
18 public:
Text(already_AddRefed<mozilla::dom::NodeInfo> & aNodeInfo)19   explicit Text(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
20     : nsGenericDOMDataNode(aNodeInfo)
21   {}
22 
Text(already_AddRefed<mozilla::dom::NodeInfo> && aNodeInfo)23   explicit Text(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
24     : nsGenericDOMDataNode(aNodeInfo)
25   {}
26 
27   using nsGenericDOMDataNode::GetWholeText;
28 
29   // WebIDL API
30   already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv);
GetWholeText(nsAString & aWholeText,ErrorResult & rv)31   void GetWholeText(nsAString& aWholeText, ErrorResult& rv)
32   {
33     rv = GetWholeText(aWholeText);
34   }
35 
36   static already_AddRefed<Text>
37   Constructor(const GlobalObject& aGlobal,
38               const nsAString& aData, ErrorResult& aRv);
39 };
40 
41 } // namespace dom
42 } // namespace mozilla
43 
GetAsText()44 inline mozilla::dom::Text* nsINode::GetAsText()
45 {
46   return IsNodeOfType(eTEXT) ? static_cast<mozilla::dom::Text*>(this)
47                              : nullptr;
48 }
49 
GetAsText()50 inline const mozilla::dom::Text* nsINode::GetAsText() const
51 {
52   return IsNodeOfType(eTEXT) ? static_cast<const mozilla::dom::Text*>(this)
53                              : nullptr;
54 }
55 
56 #endif // mozilla_dom_Text_h
57