XULElementAccessibles.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_XULElementAccessibles_h__
  6. #define mozilla_a11y_XULElementAccessibles_h__
  7. #include "HyperTextAccessibleWrap.h"
  8. #include "TextLeafAccessibleWrap.h"
  9. namespace mozilla {
  10. namespace a11y {
  11. class XULLabelTextLeafAccessible;
  12. /**
  13. * Used for XUL description and label elements.
  14. */
  15. class XULLabelAccessible : public HyperTextAccessibleWrap
  16. {
  17. public:
  18. XULLabelAccessible(nsIContent* aContent, DocAccessible* aDoc);
  19. // Accessible
  20. virtual void Shutdown() override;
  21. virtual a11y::role NativeRole() override;
  22. virtual uint64_t NativeState() override;
  23. virtual Relation RelationByType(RelationType aType) override;
  24. void UpdateLabelValue(const nsString& aValue);
  25. protected:
  26. // Accessible
  27. virtual ENameValueFlag NativeName(nsString& aName) override;
  28. private:
  29. RefPtr<XULLabelTextLeafAccessible> mValueTextLeaf;
  30. };
  31. inline XULLabelAccessible*
  32. Accessible::AsXULLabel()
  33. {
  34. return IsXULLabel() ? static_cast<XULLabelAccessible*>(this) : nullptr;
  35. }
  36. /**
  37. * Used to implement text interface on XUL label accessible in case when text
  38. * is provided by @value attribute (no underlying text frame).
  39. */
  40. class XULLabelTextLeafAccessible final : public TextLeafAccessibleWrap
  41. {
  42. public:
  43. XULLabelTextLeafAccessible(nsIContent* aContent, DocAccessible* aDoc) :
  44. TextLeafAccessibleWrap(aContent, aDoc)
  45. { mStateFlags |= eSharedNode; }
  46. virtual ~XULLabelTextLeafAccessible() { }
  47. // Accessible
  48. virtual a11y::role NativeRole() override;
  49. virtual uint64_t NativeState() override;
  50. };
  51. /**
  52. * Used for XUL tooltip element.
  53. */
  54. class XULTooltipAccessible : public LeafAccessible
  55. {
  56. public:
  57. XULTooltipAccessible(nsIContent* aContent, DocAccessible* aDoc);
  58. // Accessible
  59. virtual a11y::role NativeRole() override;
  60. virtual uint64_t NativeState() override;
  61. };
  62. class XULLinkAccessible : public XULLabelAccessible
  63. {
  64. public:
  65. XULLinkAccessible(nsIContent* aContent, DocAccessible* aDoc);
  66. // Accessible
  67. virtual void Value(nsString& aValue) override;
  68. virtual a11y::role NativeRole() override;
  69. virtual uint64_t NativeLinkState() const override;
  70. // ActionAccessible
  71. virtual uint8_t ActionCount() override;
  72. virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
  73. virtual bool DoAction(uint8_t aIndex) override;
  74. // HyperLinkAccessible
  75. virtual bool IsLink() override;
  76. virtual uint32_t StartOffset() override;
  77. virtual uint32_t EndOffset() override;
  78. virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
  79. protected:
  80. virtual ~XULLinkAccessible();
  81. // Accessible
  82. virtual ENameValueFlag NativeName(nsString& aName) override;
  83. enum { eAction_Jump = 0 };
  84. };
  85. } // namespace a11y
  86. } // namespace mozilla
  87. #endif