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 #include "BaseAccessibles.h"
10 using namespace mozilla::a11y
;
12 ////////////////////////////////////////////////////////////////////////////////
14 ////////////////////////////////////////////////////////////////////////////////
16 LeafAccessible::LeafAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
)
17 : AccessibleWrap(aContent
, aDoc
) {
18 mStateFlags
|= eNoKidsFromDOM
;
21 ////////////////////////////////////////////////////////////////////////////////
22 // LeafAccessible: LocalAccessible public
24 LocalAccessible
* LeafAccessible::LocalChildAtPoint(
25 int32_t aX
, int32_t aY
, EWhichChildAtPoint aWhichChild
) {
26 // Don't walk into leaf accessibles.
30 bool LeafAccessible::InsertChildAt(uint32_t aIndex
, LocalAccessible
* aChild
) {
31 MOZ_ASSERT_UNREACHABLE("InsertChildAt called on leaf accessible!");
35 bool LeafAccessible::RemoveChild(LocalAccessible
* aChild
) {
36 MOZ_ASSERT_UNREACHABLE("RemoveChild called on leaf accessible!");
40 bool LeafAccessible::IsAcceptableChild(nsIContent
* aEl
) const {
41 // No children for leaf accessible.
45 ////////////////////////////////////////////////////////////////////////////////
47 ////////////////////////////////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////////////////////////////////
50 // LinkableAccessible. nsIAccessible
52 void LinkableAccessible::TakeFocus() const {
53 if (const LocalAccessible
* actionAcc
= ActionWalk()) {
54 actionAcc
->TakeFocus();
56 AccessibleWrap::TakeFocus();
60 uint64_t LinkableAccessible::NativeLinkState() const {
62 const LocalAccessible
* actionAcc
= ActionWalk(&isLink
);
64 return states::LINKED
| (actionAcc
->LinkState() & states::TRAVERSED
);
70 void LinkableAccessible::Value(nsString
& aValue
) const {
73 LocalAccessible::Value(aValue
);
74 if (!aValue
.IsEmpty()) {
79 const LocalAccessible
* actionAcc
= ActionWalk(&isLink
);
81 actionAcc
->Value(aValue
);
85 const LocalAccessible
* LinkableAccessible::ActionWalk(bool* aIsLink
,
86 bool* aIsOnclick
) const {
94 if (HasPrimaryAction()) {
102 const Accessible
* actionAcc
= ActionAncestor();
104 const LocalAccessible
* localAction
=
105 actionAcc
? const_cast<Accessible
*>(actionAcc
)->AsLocal() : nullptr;
111 if (localAction
->LinkState() & states::LINKED
) {
115 } else if (aIsOnclick
) {
122 KeyBinding
LinkableAccessible::AccessKey() const {
123 if (const LocalAccessible
* actionAcc
=
124 const_cast<LinkableAccessible
*>(this)->ActionWalk()) {
125 return actionAcc
->AccessKey();
128 return LocalAccessible::AccessKey();
131 ////////////////////////////////////////////////////////////////////////////////
133 ////////////////////////////////////////////////////////////////////////////////
135 uint64_t DummyAccessible::NativeState() const { return 0; }
136 uint64_t DummyAccessible::NativeInteractiveState() const { return 0; }
138 uint64_t DummyAccessible::NativeLinkState() const { return 0; }
140 bool DummyAccessible::NativelyUnavailable() const { return false; }
142 void DummyAccessible::ApplyARIAState(uint64_t* aState
) const {}