1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set expandtab shiftwidth=2 tabstop=2: */
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/. */
7 #ifndef _CacheConstants_h_
8 #define _CacheConstants_h_
10 #include "nsGkAtoms.h"
11 #include "mozilla/a11y/RelationType.h"
18 static constexpr uint64_t NameAndDescription
= ((uint64_t)0x1) << 0;
19 static constexpr uint64_t Value
= ((uint64_t)0x1) << 1;
20 static constexpr uint64_t Bounds
= ((uint64_t)0x1) << 2;
21 static constexpr uint64_t Resolution
= ((uint64_t)0x1) << 3;
22 static constexpr uint64_t Text
= ((uint64_t)0x1) << 4;
23 static constexpr uint64_t DOMNodeIDAndClass
= ((uint64_t)0x1) << 5;
24 static constexpr uint64_t State
= ((uint64_t)0x1) << 6;
25 static constexpr uint64_t GroupInfo
= ((uint64_t)0x1) << 7;
26 static constexpr uint64_t Actions
= ((uint64_t)0x1) << 8;
27 static constexpr uint64_t Style
= ((uint64_t)0x1) << 9;
28 static constexpr uint64_t TransformMatrix
= ((uint64_t)0x1) << 10;
29 static constexpr uint64_t ScrollPosition
= ((uint64_t)0x1) << 11;
30 static constexpr uint64_t Table
= ((uint64_t)0x1) << 12;
31 static constexpr uint64_t Spelling
= ((uint64_t)0x1) << 13;
32 static constexpr uint64_t Viewport
= ((uint64_t)0x1) << 14;
33 static constexpr uint64_t ARIA
= ((uint64_t)0x1) << 15;
34 static constexpr uint64_t Relations
= ((uint64_t)0x1) << 16;
37 static constexpr uint64_t InnerHTML
= ((uint64_t)0x1) << 17;
39 static constexpr uint64_t All
= ~((uint64_t)0x0);
42 enum class CacheUpdateType
{
44 * An initial cache push of a loaded document or inserted subtree.
49 * An incremental cache push of one or more fields that have changed.
55 nsStaticAtom
* const mAtom
;
56 nsStaticAtom
* const mValidTag
;
58 RelationType mReverseType
;
62 * This array of RelationData lists our relation types (explicit and reverse)
63 * and the cache attribute atoms that store their targets. Attributes may
64 * describe different kinds of relations, depending on the element they
65 * originate on. For example, an <output> element's `for` attribute describes a
66 * CONTROLLER_FOR relation, while the `for` attribute of a <label> describes a
67 * LABEL_FOR relation. To ensure we process these attributes appropriately,
68 * RelationData.mValidTag contains the atom for the tag this attribute/relation
69 * type pairing is valid on. If the pairing is valid for all tag types, this
72 static constexpr RelationData kRelationTypeAtoms
[] = {
73 {nsGkAtoms::aria_labelledby
, nullptr, RelationType::LABELLED_BY
,
74 RelationType::LABEL_FOR
},
75 {nsGkAtoms::_for
, nsGkAtoms::label
, RelationType::LABEL_FOR
,
76 RelationType::LABELLED_BY
},
77 {nsGkAtoms::aria_controls
, nullptr, RelationType::CONTROLLER_FOR
,
78 RelationType::CONTROLLED_BY
},
79 {nsGkAtoms::_for
, nsGkAtoms::output
, RelationType::CONTROLLED_BY
,
80 RelationType::CONTROLLER_FOR
},
81 {nsGkAtoms::aria_describedby
, nullptr, RelationType::DESCRIBED_BY
,
82 RelationType::DESCRIPTION_FOR
},
83 {nsGkAtoms::aria_flowto
, nullptr, RelationType::FLOWS_TO
,
84 RelationType::FLOWS_FROM
},
85 {nsGkAtoms::aria_details
, nullptr, RelationType::DETAILS
,
86 RelationType::DETAILS_FOR
},
87 {nsGkAtoms::aria_errormessage
, nullptr, RelationType::ERRORMSG
,
88 RelationType::ERRORMSG_FOR
},
91 // The count of numbers needed to serialize an nsRect. This is used when
92 // flattening character rects into an array of ints.
93 constexpr int32_t kNumbersInRect
= 4;
96 * RemoteAccessible cache keys.
97 * Cache keys are nsAtoms, but this is mostly an implementation detail. Rather
98 * than creating new atoms specific to the RemoteAccessible cache, we often
99 * reuse existing atoms which are a reasonably close match for the value we're
100 * caching, though the choices aren't always clear or intuitive. For clarity, we
101 * alias the cache keys to atoms below. Code dealing with the RemoteAccessible
102 * cache should generally use these aliases rather than using nsAtoms directly.
103 * There are two exceptions:
104 * 1. Some ARIA attributes are copied directly from the DOM node, so these
105 * aren't aliased. Specifically, aria-level, aria-posinset and aria-setsize
106 * are copied as separate cache keys as part of CacheDomain::GroupInfo.
107 * 2. Keys for relations are defined in kRelationTypeAtoms above.
111 // uint64_t, CacheDomain::Actions
112 // As returned by Accessible::AccessKey.
113 static constexpr nsStaticAtom
* AccessKey
= nsGkAtoms::accesskey
;
114 // int32_t, no domain
115 static constexpr nsStaticAtom
* AppUnitsPerDevPixel
=
116 nsGkAtoms::_moz_device_pixel_ratio
;
117 // AccAttributes, CacheDomain::ARIA
118 // ARIA attributes that are exposed as object attributes; i.e. returned in
119 // Accessible::Attributes.
120 static constexpr nsStaticAtom
* ARIAAttributes
= nsGkAtoms::aria
;
121 // nsString, CacheUpdateType::Initial
122 // The ARIA role attribute if the role is unknown or if there are multiple
124 static constexpr nsStaticAtom
* ARIARole
= nsGkAtoms::role
;
125 // bool, CacheDomain::State
126 // The aria-selected attribute.
127 static constexpr nsStaticAtom
* ARIASelected
= nsGkAtoms::aria_selected
;
128 // nsTArray<uint64_t>, CacheDomain::Table
129 // The explicit headers of an HTML table cell.
130 static constexpr nsStaticAtom
* CellHeaders
= nsGkAtoms::headers
;
131 // int32_t, CacheDomain::Table
132 // The colspan of an HTML table cell.
133 static constexpr nsStaticAtom
* ColSpan
= nsGkAtoms::colspan
;
134 // nsTArray<int32_t, 2>, CacheDomain::Bounds
135 // The offset from an OuterDocAccessible (iframe) to its embedded document.
136 static constexpr nsStaticAtom
* CrossDocOffset
= nsGkAtoms::crossorigin
;
137 // nsAtom, CacheDomain::Style
138 // CSS display; block, inline, etc.
139 static constexpr nsStaticAtom
* CSSDisplay
= nsGkAtoms::display
;
140 // nsAtom, CacheDomain::Style
141 // CSS overflow; e.g. hidden.
142 static constexpr nsStaticAtom
* CSSOverflow
= nsGkAtoms::overflow
;
143 // nsAtom, CacheDomain::Style
144 // CSS position; e.g. fixed.
145 static constexpr nsStaticAtom
* CssPosition
= nsGkAtoms::position
;
146 // nsString, CacheDomain::NameAndDescription
147 static constexpr nsStaticAtom
* Description
= nsGkAtoms::description
;
148 // nsString, CacheDomain::Relations
149 // The "name" DOM attribute.
150 static constexpr nsStaticAtom
* DOMName
= nsGkAtoms::attributeName
;
151 // nsAtom, CacheDomain::DOMNodeIDAndClass
152 // The "class" DOM attribute.
153 static constexpr nsStaticAtom
* DOMNodeClass
= nsGkAtoms::_class
;
154 // nsAtom, CacheDomain::DOMNodeIDAndClass
155 static constexpr nsStaticAtom
* DOMNodeID
= nsGkAtoms::id
;
156 // AccGroupInfo, no domain
157 static constexpr nsStaticAtom
* GroupInfo
= nsGkAtoms::group
;
158 // nsTArray<int32_t>, no domain
159 // As returned by HyperTextAccessibleBase::CachedHyperTextOffsets.
160 static constexpr nsStaticAtom
* HyperTextOffsets
= nsGkAtoms::offset
;
161 // bool, CacheDomain::Actions
162 // Whether this image has a longdesc.
163 static constexpr nsStaticAtom
* HasLongdesc
= nsGkAtoms::longdesc
;
164 // nsString, CacheDomain::NameAndDescription
165 static constexpr nsStaticAtom
* HTMLPlaceholder
= nsGkAtoms::placeholder
;
167 // nsString, CacheDomain::InnerHTML
168 static constexpr nsStaticAtom
* InnerHTML
= nsGkAtoms::html
;
170 // nsAtom, CacheUpdateType::Initial
171 // The type of an <input> element; tel, email, etc.
172 static constexpr nsStaticAtom
* InputType
= nsGkAtoms::textInputType
;
173 // bool, CacheDomain::Bounds
174 // Whether the Accessible is fully clipped.
175 static constexpr nsStaticAtom
* IsClipped
= nsGkAtoms::clip_rule
;
176 // nsString, CacheUpdateType::Initial
177 static constexpr nsStaticAtom
* MimeType
= nsGkAtoms::headerContentType
;
178 // double, CacheDomain::Value
179 static constexpr nsStaticAtom
* MaxValue
= nsGkAtoms::max
;
180 // double, CacheDomain::Value
181 static constexpr nsStaticAtom
* MinValue
= nsGkAtoms::min
;
182 // nsString, CacheDomain::NameAndDescription
183 static constexpr nsStaticAtom
* Name
= nsGkAtoms::name
;
184 // ENameValueFlag, CacheDomain::NameAndDescription
185 // Returned by Accessible::Name.
186 static constexpr nsStaticAtom
* NameValueFlag
= nsGkAtoms::explicit_name
;
187 // double, CacheDomain::Value
188 // The numeric value returned by Accessible::CurValue.
189 static constexpr nsStaticAtom
* NumericValue
= nsGkAtoms::value
;
190 // float, CacheDomain::Style
191 static constexpr nsStaticAtom
* Opacity
= nsGkAtoms::opacity
;
192 // nsTArray<int32_t, 4>, CacheDomain::Bounds
193 // The screen bounds relative to the parent Accessible
194 // as returned by LocalAccessible::ParentRelativeBounds.
195 static constexpr nsStaticAtom
* ParentRelativeBounds
=
196 nsGkAtoms::relativeBounds
;
197 // nsAtom, CacheUpdateType::Initial
198 // The type of a popup (used for HTML popover).
199 static constexpr nsStaticAtom
* PopupType
= nsGkAtoms::ispopup
;
200 // nsAtom, CacheDomain::Actions
201 static constexpr nsStaticAtom
* PrimaryAction
= nsGkAtoms::action
;
203 // Document resolution.
204 static constexpr nsStaticAtom
* Resolution
= nsGkAtoms::resolution
;
205 // int32_t, CacheDomain::Table
206 // The rowspan of an HTML table cell.
207 static constexpr nsStaticAtom
* RowSpan
= nsGkAtoms::rowspan
;
208 // nsTArray<int32_t, 2>, CacheDomain::ScrollPosition
209 static constexpr nsStaticAtom
* ScrollPosition
= nsGkAtoms::scrollPosition
;
210 // nsTArray<int32_t>, CacheDomain::Spelling | CacheDomain::Text
211 // The offsets of spelling errors.
212 static constexpr nsStaticAtom
* SpellingErrors
= nsGkAtoms::spelling
;
213 // nsString, CacheDomain::Value
214 // The src URL of images.
215 static constexpr nsStaticAtom
* SrcURL
= nsGkAtoms::src
;
216 // uint64_t, CacheDomain::State
217 // As returned by Accessible::State.
218 static constexpr nsStaticAtom
* State
= nsGkAtoms::state
;
219 // double, CacheDomain::Value
220 // The value step returned by Accessible::Step.
221 static constexpr nsStaticAtom
* Step
= nsGkAtoms::step
;
222 // nsAtom, CacheUpdateType::Initial
223 // The tag name of the element.
224 static constexpr nsStaticAtom
* TagName
= nsGkAtoms::tag
;
225 // bool, CacheDomain::Table
226 // Whether this is a layout table.
227 static constexpr nsStaticAtom
* TableLayoutGuess
= nsGkAtoms::layout_guess
;
228 // nsString, CacheDomain::Text
229 // The text of TextLeafAccessibles.
230 static constexpr nsStaticAtom
* Text
= nsGkAtoms::text
;
231 // AccAttributes, CacheDomain::Text
232 // Text attributes; font, etc.
233 static constexpr nsStaticAtom
* TextAttributes
= nsGkAtoms::style
;
234 // nsTArray<int32_t, 4 * n>, CacheDomain::Text | CacheDomain::Bounds
235 // The bounds of each character in a text leaf.
236 static constexpr nsStaticAtom
* TextBounds
= nsGkAtoms::characterData
;
237 // nsTArray<int32_t>, CacheDomain::Text | CacheDomain::Bounds
238 // The text offsets where new lines start.
239 static constexpr nsStaticAtom
* TextLineStarts
= nsGkAtoms::line
;
240 // nsString, CacheDomain::Value
241 // The textual value returned by Accessible::Value (as opposed to
242 // the numeric value returned by Accessible::CurValue).
243 static constexpr nsStaticAtom
* TextValue
= nsGkAtoms::aria_valuetext
;
244 // gfx::Matrix4x4, CacheDomain::TransformMatrix
245 static constexpr nsStaticAtom
* TransformMatrix
= nsGkAtoms::transform
;
246 // nsTArray<uint64_t>, CacheDomain::Viewport
247 // The list of Accessibles in the viewport used for hit testing and on-screen
249 static constexpr nsStaticAtom
* Viewport
= nsGkAtoms::viewport
;
253 } // namespace mozilla