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