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/. */
6 #ifndef mozilla_a11y_BaseAccessibles_h__
7 #define mozilla_a11y_BaseAccessibles_h__
9 #include "AccessibleWrap.h"
10 #include "HyperTextAccessibleWrap.h"
15 * This file contains a number of classes that are used as base
16 * classes for the different accessibility implementations of
17 * the HTML and XUL widget sets. --jgaunt
24 * Leaf version of DOM Accessible -- has no children
26 class LeafAccessible
: public AccessibleWrap
{
28 LeafAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
);
31 NS_INLINE_DECL_REFCOUNTING_INHERITED(LeafAccessible
, AccessibleWrap
)
34 virtual LocalAccessible
* LocalChildAtPoint(
35 int32_t aX
, int32_t aY
, EWhichChildAtPoint aWhichChild
) override
;
36 bool InsertChildAt(uint32_t aIndex
, LocalAccessible
* aChild
) final
;
37 bool RemoveChild(LocalAccessible
* aChild
) final
;
39 virtual bool IsAcceptableChild(nsIContent
* aEl
) const override
;
42 virtual ~LeafAccessible() {}
46 * Used for text or image accessible nodes contained by link accessibles or
47 * accessibles for nodes with registered click event handler. It knows how to
48 * report the state of the host link (traveled or not) and can activate (click)
49 * the host accessible programmatically.
51 class LinkableAccessible
: public AccessibleWrap
{
53 enum { eAction_Jump
= 0 };
55 LinkableAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
56 : AccessibleWrap(aContent
, aDoc
) {}
58 NS_INLINE_DECL_REFCOUNTING_INHERITED(LinkableAccessible
, AccessibleWrap
)
61 virtual void Value(nsString
& aValue
) const override
;
62 virtual uint64_t NativeLinkState() const override
;
63 virtual void TakeFocus() const override
;
66 virtual uint8_t ActionCount() const override
;
67 virtual void ActionNameAt(uint8_t aIndex
, nsAString
& aName
) override
;
68 virtual bool DoAction(uint8_t index
) const override
;
69 virtual KeyBinding
AccessKey() const override
;
71 // ActionAccessible helpers
72 const LocalAccessible
* ActionWalk(bool* aIsLink
= nullptr,
73 bool* aIsOnclick
= nullptr) const;
74 // HyperLinkAccessible
75 virtual already_AddRefed
<nsIURI
> AnchorURIAt(
76 uint32_t aAnchorIndex
) const override
;
79 virtual ~LinkableAccessible() {}
83 * A simple accessible that gets its enumerated role.
85 template <a11y::role R
>
86 class EnumRoleAccessible
: public AccessibleWrap
{
88 EnumRoleAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
89 : AccessibleWrap(aContent
, aDoc
) {}
91 NS_IMETHOD
QueryInterface(REFNSIID aIID
, void** aPtr
) override
{
92 return LocalAccessible::QueryInterface(aIID
, aPtr
);
96 virtual a11y::role
NativeRole() const override
{ return R
; }
99 virtual ~EnumRoleAccessible() {}
103 * A wrapper accessible around native accessible to connect it with
104 * crossplatform accessible tree.
106 class DummyAccessible
: public AccessibleWrap
{
108 explicit DummyAccessible(DocAccessible
* aDocument
= nullptr)
109 : AccessibleWrap(nullptr, aDocument
) {
110 // IsDefunct() asserts if mContent is null, which is always true for
111 // DummyAccessible. We can prevent this by setting eSharedNode.
112 mStateFlags
|= eSharedNode
;
115 uint64_t NativeState() const final
;
116 uint64_t NativeInteractiveState() const final
;
117 uint64_t NativeLinkState() const final
;
118 bool NativelyUnavailable() const final
;
119 void ApplyARIAState(uint64_t* aState
) const final
;
122 virtual ~DummyAccessible() {}
126 } // namespace mozilla