/src/mozilla-central/accessible/generic/Accessible-inl.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_a11y_Accessible_inl_h_ |
8 | | #define mozilla_a11y_Accessible_inl_h_ |
9 | | |
10 | | #include "DocAccessible.h" |
11 | | #include "ARIAMap.h" |
12 | | #include "nsCoreUtils.h" |
13 | | |
14 | | #ifdef A11Y_LOG |
15 | | #include "Logging.h" |
16 | | #endif |
17 | | |
18 | | namespace mozilla { |
19 | | namespace a11y { |
20 | | |
21 | | inline mozilla::a11y::role |
22 | | Accessible::Role() const |
23 | 0 | { |
24 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
25 | 0 | if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole) |
26 | 0 | return ARIATransformRole(NativeRole()); |
27 | 0 | |
28 | 0 | return ARIATransformRole(roleMapEntry->role); |
29 | 0 | } |
30 | | |
31 | | inline bool |
32 | | Accessible::HasARIARole() const |
33 | 0 | { |
34 | 0 | return mRoleMapEntryIndex != aria::NO_ROLE_MAP_ENTRY_INDEX; |
35 | 0 | } |
36 | | |
37 | | inline bool |
38 | | Accessible::IsARIARole(nsAtom* aARIARole) const |
39 | 0 | { |
40 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
41 | 0 | return roleMapEntry && roleMapEntry->Is(aARIARole); |
42 | 0 | } |
43 | | |
44 | | inline bool |
45 | | Accessible::HasStrongARIARole() const |
46 | 0 | { |
47 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
48 | 0 | return roleMapEntry && roleMapEntry->roleRule == kUseMapRole; |
49 | 0 | } |
50 | | |
51 | | inline const nsRoleMapEntry* |
52 | | Accessible::ARIARoleMap() const |
53 | 0 | { |
54 | 0 | return aria::GetRoleMapFromIndex(mRoleMapEntryIndex); |
55 | 0 | } |
56 | | |
57 | | inline mozilla::a11y::role |
58 | | Accessible::ARIARole() |
59 | 0 | { |
60 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
61 | 0 | if (!roleMapEntry || roleMapEntry->roleRule != kUseMapRole) |
62 | 0 | return mozilla::a11y::roles::NOTHING; |
63 | 0 | |
64 | 0 | return ARIATransformRole(roleMapEntry->role); |
65 | 0 | } |
66 | | |
67 | | inline void |
68 | | Accessible::SetRoleMapEntry(const nsRoleMapEntry* aRoleMapEntry) |
69 | 0 | { |
70 | 0 | mRoleMapEntryIndex = aria::GetIndexFromRoleMap(aRoleMapEntry); |
71 | 0 | } |
72 | | |
73 | | inline bool |
74 | | Accessible::IsSearchbox() const |
75 | 0 | { |
76 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
77 | 0 | return (roleMapEntry && roleMapEntry->Is(nsGkAtoms::searchbox)) || |
78 | 0 | (mContent->IsHTMLElement(nsGkAtoms::input) && |
79 | 0 | mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type, |
80 | 0 | nsGkAtoms::search, eCaseMatters)); |
81 | 0 | } |
82 | | |
83 | | inline bool |
84 | | Accessible::HasGenericType(AccGenericType aType) const |
85 | 0 | { |
86 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
87 | 0 | return (mGenericTypes & aType) || |
88 | 0 | (roleMapEntry && roleMapEntry->IsOfType(aType)); |
89 | 0 | } |
90 | | |
91 | | inline bool |
92 | | Accessible::HasNumericValue() const |
93 | 0 | { |
94 | 0 | if (mStateFlags & eHasNumericValue) |
95 | 0 | return true; |
96 | 0 | |
97 | 0 | const nsRoleMapEntry* roleMapEntry = ARIARoleMap(); |
98 | 0 | if (!roleMapEntry || roleMapEntry->valueRule == eNoValue) |
99 | 0 | return false; |
100 | 0 | |
101 | 0 | if (roleMapEntry->valueRule == eHasValueMinMaxIfFocusable) |
102 | 0 | return InteractiveState() & states::FOCUSABLE; |
103 | 0 | |
104 | 0 | return true; |
105 | 0 | } |
106 | | |
107 | | inline bool |
108 | | Accessible::IsDefunct() const |
109 | 0 | { |
110 | 0 | MOZ_ASSERT(mStateFlags & eIsDefunct || IsApplication() || IsDoc() || |
111 | 0 | mStateFlags & eSharedNode || mContent, |
112 | 0 | "No content"); |
113 | 0 | return mStateFlags & eIsDefunct; |
114 | 0 | } |
115 | | |
116 | | inline void |
117 | | Accessible::ScrollTo(uint32_t aHow) const |
118 | 0 | { |
119 | 0 | if (mContent) |
120 | 0 | nsCoreUtils::ScrollTo(mDoc->PresShell(), mContent, aHow); |
121 | 0 | } |
122 | | |
123 | | inline bool |
124 | | Accessible::InsertAfter(Accessible* aNewChild, Accessible* aRefChild) |
125 | 0 | { |
126 | 0 | MOZ_ASSERT(aNewChild, "No new child to insert"); |
127 | 0 |
|
128 | 0 | if (aRefChild && aRefChild->Parent() != this) { |
129 | 0 | #ifdef A11Y_LOG |
130 | 0 | logging::TreeInfo("broken accessible tree", 0, |
131 | 0 | "parent", this, "prev sibling parent", |
132 | 0 | aRefChild->Parent(), "child", aNewChild, nullptr); |
133 | 0 | if (logging::IsEnabled(logging::eVerbose)) { |
134 | 0 | logging::Tree("TREE", "Document tree", mDoc); |
135 | 0 | logging::DOMTree("TREE", "DOM document tree", mDoc); |
136 | 0 | } |
137 | 0 | #endif |
138 | 0 | MOZ_ASSERT_UNREACHABLE("Broken accessible tree"); |
139 | 0 | mDoc->UnbindFromDocument(aNewChild); |
140 | 0 | return false; |
141 | 0 | } |
142 | 0 |
|
143 | 0 | return InsertChildAt(aRefChild ? aRefChild->IndexInParent() + 1 : 0, |
144 | 0 | aNewChild); |
145 | 0 | } |
146 | | |
147 | | } // namespace a11y |
148 | | } // namespace mozilla |
149 | | |
150 | | #endif |