TextLeafAccessible.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef mozilla_a11y_TextLeafAccessible_h__
  6. #define mozilla_a11y_TextLeafAccessible_h__
  7. #include "BaseAccessibles.h"
  8. namespace mozilla {
  9. namespace a11y {
  10. /**
  11. * Generic class used for text nodes.
  12. */
  13. class TextLeafAccessible : public LinkableAccessible
  14. {
  15. public:
  16. TextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc);
  17. virtual ~TextLeafAccessible();
  18. // Accessible
  19. virtual mozilla::a11y::role NativeRole() override;
  20. virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
  21. uint32_t aLength = UINT32_MAX) override;
  22. virtual ENameValueFlag Name(nsString& aName) override;
  23. // TextLeafAccessible
  24. void SetText(const nsAString& aText) { mText = aText; }
  25. const nsString& Text() const { return mText; }
  26. protected:
  27. nsString mText;
  28. };
  29. ////////////////////////////////////////////////////////////////////////////////
  30. // Accessible downcast method
  31. inline TextLeafAccessible*
  32. Accessible::AsTextLeaf()
  33. {
  34. return IsTextLeaf() ? static_cast<TextLeafAccessible*>(this) : nullptr;
  35. }
  36. } // namespace a11y
  37. } // namespace mozilla
  38. #endif