Bug 1904048 - Add prototype for ImageBitmap's BindingJSObjectMallocBytes. r=aosmond
[gecko.git] / dom / base / Text.h
blob9f69b47091bc23bd634915fda6623f9f03d025d5
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/. */
7 #ifndef mozilla_dom_Text_h
8 #define mozilla_dom_Text_h
10 #include "mozilla/dom/CharacterData.h"
12 namespace mozilla {
13 class ErrorResult;
15 namespace dom {
17 class Text : public CharacterData {
18 public:
19 NS_IMPL_FROMNODE_HELPER(Text, IsText())
21 explicit Text(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
22 : CharacterData(std::move(aNodeInfo)) {}
24 // WebIDL API
25 already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv);
26 void GetWholeText(nsAString& aWholeText);
28 static already_AddRefed<Text> Constructor(const GlobalObject& aGlobal,
29 const nsAString& aData,
30 ErrorResult& aRv);
32 nsresult BindToTree(BindContext&, nsINode& aParent) override;
33 void UnbindFromTree(UnbindContext&) override;
35 /**
36 * Method to see if the text node contains data that is useful
37 * for a translation: i.e., it consists of more than just whitespace,
38 * digits and punctuation.
40 bool HasTextForTranslation();
43 } // namespace dom
44 } // namespace mozilla
46 inline mozilla::dom::Text* nsINode::GetAsText() {
47 return IsText() ? AsText() : nullptr;
50 inline const mozilla::dom::Text* nsINode::GetAsText() const {
51 return IsText() ? AsText() : nullptr;
54 inline mozilla::dom::Text* nsINode::AsText() {
55 MOZ_ASSERT(IsText());
56 return static_cast<mozilla::dom::Text*>(this);
59 inline const mozilla::dom::Text* nsINode::AsText() const {
60 MOZ_ASSERT(IsText());
61 return static_cast<const mozilla::dom::Text*>(this);
64 #endif // mozilla_dom_Text_h