XULFormControlAccessible.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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_XULFormControlAccessible_H_
  6. #define MOZILLA_A11Y_XULFormControlAccessible_H_
  7. // NOTE: alphabetically ordered
  8. #include "AccessibleWrap.h"
  9. #include "FormControlAccessible.h"
  10. #include "HyperTextAccessibleWrap.h"
  11. #include "XULSelectControlAccessible.h"
  12. namespace mozilla {
  13. namespace a11y {
  14. /**
  15. * Used for XUL progressmeter element.
  16. */
  17. typedef ProgressMeterAccessible<100> XULProgressMeterAccessible;
  18. /**
  19. * Used for XUL button.
  20. *
  21. * @note Don't inherit from LeafAccessible - it doesn't allow children
  22. * and a button can have a dropmarker child.
  23. */
  24. class XULButtonAccessible : public AccessibleWrap
  25. {
  26. public:
  27. enum { eAction_Click = 0 };
  28. XULButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
  29. // nsISupports
  30. NS_DECL_ISUPPORTS_INHERITED
  31. // Accessible
  32. virtual mozilla::a11y::role NativeRole() override;
  33. virtual uint64_t NativeState() override;
  34. // ActionAccessible
  35. virtual uint8_t ActionCount() override;
  36. virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
  37. virtual bool DoAction(uint8_t aIndex) override;
  38. // Widgets
  39. virtual bool IsWidget() const override;
  40. virtual bool IsActiveWidget() const override;
  41. virtual bool AreItemsOperable() const override;
  42. virtual Accessible* ContainerWidget() const override;
  43. virtual bool IsAcceptableChild(nsIContent* aEl) const override;
  44. protected:
  45. virtual ~XULButtonAccessible();
  46. // XULButtonAccessible
  47. bool ContainsMenu() const;
  48. };
  49. /**
  50. * Used for XUL checkbox element.
  51. */
  52. class XULCheckboxAccessible : public LeafAccessible
  53. {
  54. public:
  55. enum { eAction_Click = 0 };
  56. XULCheckboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
  57. // Accessible
  58. virtual mozilla::a11y::role NativeRole() override;
  59. virtual uint64_t NativeState() override;
  60. // ActionAccessible
  61. virtual uint8_t ActionCount() override;
  62. virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
  63. virtual bool DoAction(uint8_t aIndex) override;
  64. };
  65. /**
  66. * Used for XUL dropmarker element.
  67. */
  68. class XULDropmarkerAccessible : public LeafAccessible
  69. {
  70. public:
  71. enum { eAction_Click = 0 };
  72. XULDropmarkerAccessible(nsIContent* aContent, DocAccessible* aDoc);
  73. // Accessible
  74. virtual mozilla::a11y::role NativeRole() override;
  75. virtual uint64_t NativeState() override;
  76. // ActionAccessible
  77. virtual uint8_t ActionCount() override;
  78. virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
  79. virtual bool DoAction(uint8_t aIndex) override;
  80. private:
  81. bool DropmarkerOpen(bool aToggleOpen) const;
  82. };
  83. /**
  84. * Used for XUL groupbox element.
  85. */
  86. class XULGroupboxAccessible final : public AccessibleWrap
  87. {
  88. public:
  89. XULGroupboxAccessible(nsIContent* aContent, DocAccessible* aDoc);
  90. // Accessible
  91. virtual mozilla::a11y::role NativeRole() override;
  92. virtual Relation RelationByType(RelationType aType) override;
  93. protected:
  94. // Accessible
  95. virtual ENameValueFlag NativeName(nsString& aName) override;
  96. };
  97. /**
  98. * Used for XUL radio element (radio button).
  99. */
  100. class XULRadioButtonAccessible : public RadioButtonAccessible
  101. {
  102. public:
  103. XULRadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
  104. // Accessible
  105. virtual uint64_t NativeState() override;
  106. virtual uint64_t NativeInteractiveState() const override;
  107. // Widgets
  108. virtual Accessible* ContainerWidget() const override;
  109. };
  110. /**
  111. * Used for XUL radiogroup element.
  112. */
  113. class XULRadioGroupAccessible : public XULSelectControlAccessible
  114. {
  115. public:
  116. XULRadioGroupAccessible(nsIContent* aContent, DocAccessible* aDoc);
  117. // Accessible
  118. virtual mozilla::a11y::role NativeRole() override;
  119. virtual uint64_t NativeInteractiveState() const override;
  120. // Widgets
  121. virtual bool IsWidget() const override;
  122. virtual bool IsActiveWidget() const override;
  123. virtual bool AreItemsOperable() const override;
  124. };
  125. /**
  126. * Used for XUL statusbar element.
  127. */
  128. class XULStatusBarAccessible : public AccessibleWrap
  129. {
  130. public:
  131. XULStatusBarAccessible(nsIContent* aContent, DocAccessible* aDoc);
  132. // Accessible
  133. virtual mozilla::a11y::role NativeRole() override;
  134. };
  135. /**
  136. * Used for XUL toolbarbutton element.
  137. */
  138. class XULToolbarButtonAccessible : public XULButtonAccessible
  139. {
  140. public:
  141. XULToolbarButtonAccessible(nsIContent* aContent, DocAccessible* aDoc);
  142. // Accessible
  143. virtual void GetPositionAndSizeInternal(int32_t* aPosInSet,
  144. int32_t* aSetSize) override;
  145. // nsXULToolbarButtonAccessible
  146. static bool IsSeparator(Accessible* aAccessible);
  147. };
  148. /**
  149. * Used for XUL toolbar element.
  150. */
  151. class XULToolbarAccessible : public AccessibleWrap
  152. {
  153. public:
  154. XULToolbarAccessible(nsIContent* aContent, DocAccessible* aDoc);
  155. // Accessible
  156. virtual mozilla::a11y::role NativeRole() override;
  157. protected:
  158. // Accessible
  159. virtual ENameValueFlag NativeName(nsString& aName) override;
  160. };
  161. /**
  162. * Used for XUL toolbarseparator element.
  163. */
  164. class XULToolbarSeparatorAccessible : public LeafAccessible
  165. {
  166. public:
  167. XULToolbarSeparatorAccessible(nsIContent* aContent,
  168. DocAccessible* aDoc);
  169. // Accessible
  170. virtual mozilla::a11y::role NativeRole() override;
  171. virtual uint64_t NativeState() override;
  172. };
  173. } // namespace a11y
  174. } // namespace mozilla
  175. #endif