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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "AccessibleWrap.h"
10 /******************************************************************************
11 The following nsIAccessible states aren't translated, just ignored:
12 STATE_READONLY: Supported indirectly via EXT_STATE_EDITABLE
13 STATE_HOTTRACKED: No ATK equivalent. No known use case.
14 The nsIAccessible state is not currently supported.
15 STATE_FLOATING: No ATK equivalent. No known use case.
16 The nsIAccessible state is not currently supported.
17 STATE_MOVEABLE: No ATK equivalent. No known use case.
18 The nsIAccessible state is not currently supported.
19 STATE_SELFVOICING: No ATK equivalent -- the object has self-TTS.
20 The nsIAccessible state is not currently supported.
21 STATE_LINKED: The object is formatted as a hyperlink. Supported via ATK_ROLE_LINK.
22 STATE_EXTSELECTABLE: Indicates that an object extends its selection.
23 This is supported via STATE_MULTISELECTABLE.
24 STATE_PROTECTED: The object is a password-protected edit control.
25 Supported via ATK_ROLE_PASSWORD_TEXT
26 STATE_HASPOPUP: Object displays a pop-up menu or window when invoked.
27 No ATK equivalent. The nsIAccessible state is not currently supported.
28 STATE_PINNED: The object is pinned, usually indicating it is fixed in place and has permanence.
29 No ATK equivalent. The nsIAccessible state is not currently supported.
31 The following ATK states are not supported:
32 ATK_STATE_ARMED: No clear use case, used briefly when button is activated
33 ATK_STATE_HAS_TOOLTIP: No clear use case, no IA2 equivalent
34 ATK_STATE_ICONIFIED: Mozilla does not have elements which are collapsable into icons
35 ATK_STATE_TRUNCATED: No clear use case. Indicates that an object's onscreen content is truncated,
36 e.g. a text value in a spreadsheet cell. No IA2 state.
37 ******************************************************************************/
39 enum EStateMapEntryType
{
41 kMapOpposite
, // For example, UNAVAILABLE is the opposite of ENABLED
42 kNoStateChange
, // Don't fire state change event
46 const AtkStateType kNone
= ATK_STATE_INVALID
;
49 AtkStateType atkState
;
50 EStateMapEntryType stateMapEntryType
;
52 static int32_t GetStateIndexFor(uint64_t aState
)
54 int32_t stateIndex
= -1;
59 return stateIndex
; // Returns -1 if not mapped
64 // Map array from cross platform states to ATK states
65 static const AtkStateMap gAtkStateMap
[] = { // Cross Platform States
66 { kNone
, kMapOpposite
}, // states::UNAVAILABLE = 1 << 0
67 { ATK_STATE_SELECTED
, kMapDirectly
}, // states::SELECTED = 1 << 1
68 { ATK_STATE_FOCUSED
, kMapDirectly
}, // states::FOCUSED = 1 << 2
69 { ATK_STATE_PRESSED
, kMapDirectly
}, // states::PRESSED = 1 << 3
70 { ATK_STATE_CHECKED
, kMapDirectly
}, // states::CHECKED = 1 << 4
71 { ATK_STATE_INDETERMINATE
, kMapDirectly
}, // states::MIXED = 1 << 5
72 { kNone
, kMapDirectly
}, // states::READONLY = 1 << 6
73 { kNone
, kMapDirectly
}, // states::HOTTRACKED = 1 << 7
74 { ATK_STATE_DEFAULT
, kMapDirectly
}, // states::DEFAULT = 1 << 8
75 { ATK_STATE_EXPANDED
, kMapDirectly
}, // states::EXPANDED = 1 << 9
76 { kNone
, kNoStateChange
}, // states::COLLAPSED = 1 << 10
77 { ATK_STATE_BUSY
, kMapDirectly
}, // states::BUSY = 1 << 11
78 { kNone
, kMapDirectly
}, // states::FLOATING = 1 << 12
79 { kNone
, kMapDirectly
}, // states::CHECKABLE = 1 << 13
80 { ATK_STATE_ANIMATED
, kMapDirectly
}, // states::ANIMATED = 1 << 14
81 { ATK_STATE_VISIBLE
, kMapOpposite
}, // states::INVISIBLE = 1 << 15
82 { ATK_STATE_SHOWING
, kMapOpposite
}, // states::OFFSCREEN = 1 << 16
83 { ATK_STATE_RESIZABLE
, kMapDirectly
}, // states::SIZEABLE = 1 << 17
84 { kNone
, kMapDirectly
}, // states::MOVEABLE = 1 << 18
85 { kNone
, kMapDirectly
}, // states::SELFVOICING = 1 << 19
86 { ATK_STATE_FOCUSABLE
, kMapDirectly
}, // states::FOCUSABLE = 1 << 20
87 { ATK_STATE_SELECTABLE
, kMapDirectly
}, // states::SELECTABLE = 1 << 21
88 { kNone
, kMapDirectly
}, // states::LINKED = 1 << 22
89 { ATK_STATE_VISITED
, kMapDirectly
}, // states::TRAVERSED = 1 << 23
90 { ATK_STATE_MULTISELECTABLE
, kMapDirectly
}, // states::MULTISELECTABLE = 1 << 24
91 { kNone
, kMapDirectly
}, // states::EXTSELECTABLE = 1 << 25
92 { ATK_STATE_REQUIRED
, kMapDirectly
}, // states::STATE_REQUIRED = 1 << 26
93 { kNone
, kMapDirectly
}, // states::ALERT_MEDIUM = 1 << 27
94 { ATK_STATE_INVALID_ENTRY
, kMapDirectly
}, // states::INVALID = 1 << 28
95 { kNone
, kMapDirectly
}, // states::PROTECTED = 1 << 29
96 { kNone
, kMapDirectly
}, // states::HASPOPUP = 1 << 30
97 { ATK_STATE_SUPPORTS_AUTOCOMPLETION
, kMapDirectly
}, // states::SUPPORTS_AUTOCOMPLETION = 1 << 31
98 { ATK_STATE_DEFUNCT
, kMapDirectly
}, // states::DEFUNCT = 1 << 32
99 { ATK_STATE_SELECTABLE_TEXT
, kMapDirectly
}, // states::SELECTABLE_TEXT = 1 << 33
100 { ATK_STATE_EDITABLE
, kMapDirectly
}, // states::EDITABLE = 1 << 34
101 { ATK_STATE_ACTIVE
, kMapDirectly
}, // states::ACTIVE = 1 << 35
102 { ATK_STATE_MODAL
, kMapDirectly
}, // states::MODAL = 1 << 36
103 { ATK_STATE_MULTI_LINE
, kMapDirectly
}, // states::MULTI_LINE = 1 << 37
104 { ATK_STATE_HORIZONTAL
, kMapDirectly
}, // states::HORIZONTAL = 1 << 38
105 { ATK_STATE_OPAQUE
, kMapDirectly
}, // states::OPAQUE = 1 << 39
106 { ATK_STATE_SINGLE_LINE
, kMapDirectly
}, // states::SINGLE_LINE = 1 << 40
107 { ATK_STATE_TRANSIENT
, kMapDirectly
}, // states::TRANSIENT = 1 << 41
108 { ATK_STATE_VERTICAL
, kMapDirectly
}, // states::VERTICAL = 1 << 42
109 { ATK_STATE_STALE
, kMapDirectly
}, // states::STALE = 1 << 43
110 { ATK_STATE_ENABLED
, kMapDirectly
}, // states::ENABLED = 1 << 44
111 { ATK_STATE_SENSITIVE
, kMapDirectly
}, // states::SENSITIVE = 1 << 45
112 { ATK_STATE_EXPANDABLE
, kMapDirectly
}, // states::EXPANDABLE = 1 << 46
113 { kNone
, kMapDirectly
}, // states::PINNED = 1 << 47
114 { kNone
, kNoSuchState
}, // = 1 << 48