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/. */
7 #ifndef mozilla_a11y_Accessible_inl_h_
8 #define mozilla_a11y_Accessible_inl_h_
10 #include "DocAccessible.h"
12 #include "nsCoreUtils.h"
13 #include "mozilla/dom/Element.h"
14 #include "mozilla/PresShell.h"
23 inline mozilla::a11y::role
LocalAccessible::Role() const {
24 const nsRoleMapEntry
* roleMapEntry
= ARIARoleMap();
25 mozilla::a11y::role r
=
26 (!roleMapEntry
|| roleMapEntry
->roleRule
!= kUseMapRole
)
29 r
= ARIATransformRole(r
);
30 return GetMinimumRole(r
);
33 inline mozilla::a11y::role
LocalAccessible::ARIARole() {
34 const nsRoleMapEntry
* roleMapEntry
= ARIARoleMap();
35 if (!roleMapEntry
|| roleMapEntry
->roleRule
!= kUseMapRole
) {
36 return mozilla::a11y::roles::NOTHING
;
39 return ARIATransformRole(roleMapEntry
->role
);
42 inline void LocalAccessible::SetRoleMapEntry(
43 const nsRoleMapEntry
* aRoleMapEntry
) {
44 mRoleMapEntryIndex
= aria::GetIndexFromRoleMap(aRoleMapEntry
);
47 inline bool LocalAccessible::NativeHasNumericValue() const {
48 return mGenericTypes
& eNumericValue
;
51 inline bool LocalAccessible::ARIAHasNumericValue() const {
52 const nsRoleMapEntry
* roleMapEntry
= ARIARoleMap();
53 if (!roleMapEntry
|| roleMapEntry
->valueRule
== eNoValue
) return false;
55 if (roleMapEntry
->valueRule
== eHasValueMinMaxIfFocusable
) {
56 return InteractiveState() & states::FOCUSABLE
;
62 inline bool LocalAccessible::HasNumericValue() const {
63 return NativeHasNumericValue() || ARIAHasNumericValue();
66 inline bool LocalAccessible::IsDefunct() const {
67 MOZ_ASSERT(mStateFlags
& eIsDefunct
|| IsApplication() || IsDoc() ||
68 mStateFlags
& eSharedNode
|| mContent
,
70 return mStateFlags
& eIsDefunct
;
73 inline void LocalAccessible::ScrollTo(uint32_t aHow
) const {
75 RefPtr
<PresShell
> presShell
= mDoc
->PresShellPtr();
76 nsCOMPtr
<nsIContent
> content
= mContent
;
77 nsCoreUtils::ScrollTo(presShell
, content
, aHow
);
81 inline bool LocalAccessible::InsertAfter(LocalAccessible
* aNewChild
,
82 LocalAccessible
* aRefChild
) {
83 MOZ_ASSERT(aNewChild
, "No new child to insert");
85 if (aRefChild
&& aRefChild
->LocalParent() != this) {
87 logging::TreeInfo("broken accessible tree", 0, "parent", this,
88 "prev sibling parent", aRefChild
->LocalParent(), "child",
90 if (logging::IsEnabled(logging::eVerbose
)) {
91 logging::Tree("TREE", "Document tree", mDoc
);
92 logging::DOMTree("TREE", "DOM document tree", mDoc
);
95 MOZ_ASSERT_UNREACHABLE("Broken accessible tree");
96 mDoc
->UnbindFromDocument(aNewChild
);
100 return InsertChildAt(aRefChild
? aRefChild
->IndexInParent() + 1 : 0,
105 } // namespace mozilla