Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
ui::AXNode Class Referencefinal

#include <ax_node.h>

Classes

class  ChildIteratorBase
 
class  OwnerTree
 

Public Types

using AXID = int32_t
 
using UnignoredChildIterator = ChildIteratorBase< AXNode, &AXNode::GetNextUnignoredSibling, &AXNode::GetPreviousUnignoredSibling, &AXNode::GetFirstUnignoredChild, &AXNode::GetLastUnignoredChild >
 

Public Member Functions

 AXNode (OwnerTree *tree, AXNode *parent, int32_t id, size_t index_in_parent, size_t unignored_index_in_parent=0)
 
virtual ~AXNode ()
 
OwnerTreetree () const
 
AXID id () const
 
AXNodeparent () const
 
const AXNodeDatadata () const
 
const std::vector< AXNode * > & children () const
 
size_t index_in_parent () const
 
AXNodeData && TakeData ()
 
size_t GetUnignoredChildCount () const
 
AXNodeGetUnignoredChildAtIndex (size_t index) const
 
AXNodeGetUnignoredParent () const
 
OwnerTree::Selection GetUnignoredSelection () const
 
size_t GetUnignoredIndexInParent () const
 
size_t GetIndexInParent () const
 
AXNodeGetFirstUnignoredChild () const
 
AXNodeGetLastUnignoredChild () const
 
AXNodeGetDeepestFirstUnignoredChild () const
 
AXNodeGetDeepestLastUnignoredChild () const
 
AXNodeGetNextUnignoredSibling () const
 
AXNodeGetPreviousUnignoredSibling () const
 
AXNodeGetNextUnignoredInTreeOrder () const
 
AXNodeGetPreviousUnignoredInTreeOrder () const
 
UnignoredChildIterator UnignoredChildrenBegin () const
 
UnignoredChildIterator UnignoredChildrenEnd () const
 
AXNodeGetFirstChild () const
 
AXNodeGetLastChild () const
 
AXNodeGetPreviousSibling () const
 
AXNodeGetNextSibling () const
 
bool IsText () const
 
bool IsLineBreak () const
 
void SetData (const AXNodeData &src)
 
void SetLocation (int32_t offset_container_id, const gfx::RectF &location, gfx::Transform *transform)
 
void SetIndexInParent (size_t index_in_parent)
 
void UpdateUnignoredCachedValues ()
 
void SwapChildren (std::vector< AXNode * > *children)
 
void Destroy ()
 
bool IsDescendantOf (const AXNode *ancestor) const
 
bool IsDescendantOfCrossingTreeBoundary (const AXNode *ancestor) const
 
AXNodeGetParentCrossingTreeBoundary () const
 
std::vector< intGetOrComputeLineStartOffsets ()
 
bool HasBoolAttribute (ax::mojom::BoolAttribute attribute) const
 
bool GetBoolAttribute (ax::mojom::BoolAttribute attribute) const
 
bool GetBoolAttribute (ax::mojom::BoolAttribute attribute, bool *value) const
 
bool HasFloatAttribute (ax::mojom::FloatAttribute attribute) const
 
float GetFloatAttribute (ax::mojom::FloatAttribute attribute) const
 
bool GetFloatAttribute (ax::mojom::FloatAttribute attribute, float *value) const
 
bool HasIntAttribute (ax::mojom::IntAttribute attribute) const
 
int GetIntAttribute (ax::mojom::IntAttribute attribute) const
 
bool GetIntAttribute (ax::mojom::IntAttribute attribute, int *value) const
 
bool HasStringAttribute (ax::mojom::StringAttribute attribute) const
 
const std::string & GetStringAttribute (ax::mojom::StringAttribute attribute) const
 
bool GetStringAttribute (ax::mojom::StringAttribute attribute, std::string *value) const
 
bool GetString16Attribute (ax::mojom::StringAttribute attribute, std::u16string *value) const
 
std::u16string GetString16Attribute (ax::mojom::StringAttribute attribute) const
 
bool HasIntListAttribute (ax::mojom::IntListAttribute attribute) const
 
const std::vector< int32_t > & GetIntListAttribute (ax::mojom::IntListAttribute attribute) const
 
bool GetIntListAttribute (ax::mojom::IntListAttribute attribute, std::vector< int32_t > *value) const
 
bool HasStringListAttribute (ax::mojom::StringListAttribute attribute) const
 
const std::vector< std::string > & GetStringListAttribute (ax::mojom::StringListAttribute attribute) const
 
bool GetStringListAttribute (ax::mojom::StringListAttribute attribute, std::vector< std::string > *value) const
 
bool GetHtmlAttribute (const char *attribute, std::u16string *value) const
 
bool GetHtmlAttribute (const char *attribute, std::string *value) const
 
std::optional< intGetHierarchicalLevel () const
 
bool IsOrderedSetItem () const
 
bool IsOrderedSet () const
 
std::optional< intGetPosInSet ()
 
std::optional< intGetSetSize ()
 
bool SetRoleMatchesItemRole (const AXNode *ordered_set) const
 
bool IsIgnoredContainerForOrderedSet () const
 
const std::string & GetInheritedStringAttribute (ax::mojom::StringAttribute attribute) const
 
std::u16string GetInheritedString16Attribute (ax::mojom::StringAttribute attribute) const
 
std::string GetInnerText () const
 
std::string GetLanguage () const
 
bool IsTable () const
 
std::optional< intGetTableColCount () const
 
std::optional< intGetTableRowCount () const
 
std::optional< intGetTableAriaColCount () const
 
std::optional< intGetTableAriaRowCount () const
 
std::optional< intGetTableCellCount () const
 
std::optional< bool > GetTableHasColumnOrRowHeaderNode () const
 
AXNodeGetTableCaption () const
 
AXNodeGetTableCellFromIndex (int index) const
 
AXNodeGetTableCellFromCoords (int row_index, int col_index) const
 
std::vector< AXNode::AXIDGetTableColHeaderNodeIds () const
 
std::vector< AXNode::AXIDGetTableColHeaderNodeIds (int col_index) const
 
std::vector< AXNode::AXIDGetTableRowHeaderNodeIds (int row_index) const
 
std::vector< AXNode::AXIDGetTableUniqueCellIds () const
 
const std::vector< AXNode * > * GetExtraMacNodes () const
 
bool IsTableRow () const
 
std::optional< intGetTableRowRowIndex () const
 
std::vector< AXNode::AXIDGetTableRowNodeIds () const
 
bool IsTableCellOrHeader () const
 
std::optional< intGetTableCellIndex () const
 
std::optional< intGetTableCellColIndex () const
 
std::optional< intGetTableCellRowIndex () const
 
std::optional< intGetTableCellColSpan () const
 
std::optional< intGetTableCellRowSpan () const
 
std::optional< intGetTableCellAriaColIndex () const
 
std::optional< intGetTableCellAriaRowIndex () const
 
std::vector< AXNode::AXIDGetTableCellColHeaderNodeIds () const
 
std::vector< AXNode::AXIDGetTableCellRowHeaderNodeIds () const
 
void GetTableCellColHeaders (std::vector< AXNode * > *col_headers) const
 
void GetTableCellRowHeaders (std::vector< AXNode * > *row_headers) const
 
bool IsCellOrHeaderOfARIATable () const
 
bool IsCellOrHeaderOfARIAGrid () const
 
bool IsEmbeddedGroup () const
 
bool IsIgnored () const
 
bool IsChildOfLeaf () const
 
bool IsLeaf () const
 
bool IsInListMarker () const
 
bool IsCollapsedMenuListPopUpButton () const
 
AXNodeGetCollapsedMenuListPopUpButtonAncestor () const
 
AXNodeGetTextFieldAncestor () const
 
AXNodeGetOrderedSet () const
 
AXNodeGetLowestPlatformAncestor () const
 

Static Public Attributes

static constexpr AXID kInvalidAXID = -1
 

Detailed Description

Definition at line 33 of file ax_node.h.

Member Typedef Documentation

◆ AXID

using ui::AXNode::AXID = int32_t

Definition at line 36 of file ax_node.h.

◆ UnignoredChildIterator

Definition at line 138 of file ax_node.h.

Constructor & Destructor Documentation

◆ AXNode()

ui::AXNode::AXNode ( AXNode::OwnerTree tree,
AXNode parent,
int32_t  id,
size_t  index_in_parent,
size_t  unignored_index_in_parent = 0 
)

Definition at line 23 of file ax_node.cc.

28 : tree_(tree),
29 index_in_parent_(index_in_parent),
30 unignored_index_in_parent_(unignored_index_in_parent),
31 parent_(parent) {
32 data_.id = id;
33}
AXID id() const
Definition: ax_node.h:110
OwnerTree * tree() const
Definition: ax_node.h:109
AXNode * parent() const
Definition: ax_node.h:111
size_t index_in_parent() const
Definition: ax_node.h:114

◆ ~AXNode()

ui::AXNode::~AXNode ( )
virtualdefault

Member Function Documentation

◆ children()

const std::vector< AXNode * > & ui::AXNode::children ( ) const
inline

Definition at line 113 of file ax_node.h.

113{ return children_; }

◆ data()

const AXNodeData & ui::AXNode::data ( ) const
inline

Definition at line 112 of file ax_node.h.

112{ return data_; }

◆ Destroy()

void ui::AXNode::Destroy ( )

Definition at line 403 of file ax_node.cc.

403 {
404 delete this;
405}

◆ GetBoolAttribute() [1/2]

bool ui::AXNode::GetBoolAttribute ( ax::mojom::BoolAttribute  attribute) const
inline

Definition at line 211 of file ax_node.h.

211 {
212 return data().GetBoolAttribute(attribute);
213 }
const AXNodeData & data() const
Definition: ax_node.h:112
bool GetBoolAttribute(ax::mojom::BoolAttribute attribute) const

◆ GetBoolAttribute() [2/2]

bool ui::AXNode::GetBoolAttribute ( ax::mojom::BoolAttribute  attribute,
bool *  value 
) const
inline

Definition at line 214 of file ax_node.h.

214 {
215 return data().GetBoolAttribute(attribute, value);
216 }
uint8_t value

◆ GetCollapsedMenuListPopUpButtonAncestor()

AXNode * ui::AXNode::GetCollapsedMenuListPopUpButtonAncestor ( ) const

Definition at line 1177 of file ax_node.cc.

1177 {
1178 AXNode* node = GetOrderedSet();
1179
1180 if (!node)
1181 return nullptr;
1182
1183 // The ordered set returned is either the popup element child of the popup
1184 // button (e.g., the AXMenuListPopup) or the popup button itself. We need
1185 // |node| to point to the popup button itself.
1186 if (node->data().role != ax::mojom::Role::kPopUpButton) {
1187 node = node->parent();
1188 if (!node)
1189 return nullptr;
1190 }
1191
1192 return node->IsCollapsedMenuListPopUpButton() ? node : nullptr;
1193}
AXNode(OwnerTree *tree, AXNode *parent, int32_t id, size_t index_in_parent, size_t unignored_index_in_parent=0)
Definition: ax_node.cc:23
AXNode * GetOrderedSet() const
Definition: ax_node.cc:1032

◆ GetDeepestFirstUnignoredChild()

AXNode * ui::AXNode::GetDeepestFirstUnignoredChild ( ) const

Definition at line 86 of file ax_node.cc.

86 {
88 return nullptr;
89
90 AXNode* deepest_child = GetFirstUnignoredChild();
91 while (deepest_child->GetUnignoredChildCount()) {
92 deepest_child = deepest_child->GetFirstUnignoredChild();
93 }
94
95 return deepest_child;
96}
size_t GetUnignoredChildCount() const
Definition: ax_node.cc:37
AXNode * GetFirstUnignoredChild() const
Definition: ax_node.cc:76

◆ GetDeepestLastUnignoredChild()

AXNode * ui::AXNode::GetDeepestLastUnignoredChild ( ) const

Definition at line 98 of file ax_node.cc.

98 {
100 return nullptr;
101
102 AXNode* deepest_child = GetLastUnignoredChild();
103 while (deepest_child->GetUnignoredChildCount()) {
104 deepest_child = deepest_child->GetLastUnignoredChild();
105 }
106
107 return deepest_child;
108}
AXNode * GetLastUnignoredChild() const
Definition: ax_node.cc:81

◆ GetExtraMacNodes()

const std::vector< AXNode * > * ui::AXNode::GetExtraMacNodes ( ) const

Definition at line 678 of file ax_node.cc.

678 {
679 // Should only be available on the table node itself, not any of its children.
680 const AXTableInfo* table_info = tree_->GetTableInfo(this);
681 if (!table_info)
682 return nullptr;
683
684 return &table_info->extra_mac_nodes;
685}
virtual AXTableInfo * GetTableInfo(const AXNode *table_node) const =0
std::vector< AXNode * > extra_mac_nodes
Definition: ax_table_info.h:85

◆ GetFirstChild()

AXNode * ui::AXNode::GetFirstChild ( ) const

Definition at line 322 of file ax_node.cc.

322 {
323 if (children().empty())
324 return nullptr;
325 return children()[0];
326}
const std::vector< AXNode * > & children() const
Definition: ax_node.h:113
EMSCRIPTEN_KEEPALIVE void empty()

◆ GetFirstUnignoredChild()

AXNode * ui::AXNode::GetFirstUnignoredChild ( ) const

Definition at line 76 of file ax_node.cc.

76 {
78 return ComputeFirstUnignoredChildRecursive();
79}
virtual bool GetTreeUpdateInProgressState() const =0
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ GetFloatAttribute() [1/2]

float ui::AXNode::GetFloatAttribute ( ax::mojom::FloatAttribute  attribute) const
inline

Definition at line 221 of file ax_node.h.

221 {
222 return data().GetFloatAttribute(attribute);
223 }
float GetFloatAttribute(ax::mojom::FloatAttribute attribute) const

◆ GetFloatAttribute() [2/2]

bool ui::AXNode::GetFloatAttribute ( ax::mojom::FloatAttribute  attribute,
float *  value 
) const
inline

Definition at line 224 of file ax_node.h.

225 {
226 return data().GetFloatAttribute(attribute, value);
227 }

◆ GetHierarchicalLevel()

std::optional< int > ui::AXNode::GetHierarchicalLevel ( ) const

Definition at line 927 of file ax_node.cc.

927 {
928 int hierarchical_level =
930
931 // According to the WAI_ARIA spec, a defined hierarchical level value is
932 // greater than 0.
933 // https://www.w3.org/TR/wai-aria-1.1/#aria-level
934 if (hierarchical_level > 0)
935 return hierarchical_level;
936
937 return std::nullopt;
938}
int GetIntAttribute(ax::mojom::IntAttribute attribute) const
Definition: ax_node.h:232

◆ GetHtmlAttribute() [1/2]

bool ui::AXNode::GetHtmlAttribute ( const char *  attribute,
std::string *  value 
) const
inline

Definition at line 287 of file ax_node.h.

287 {
288 return data().GetHtmlAttribute(attribute, value);
289 }
bool GetHtmlAttribute(const char *attribute, std::u16string *value) const

◆ GetHtmlAttribute() [2/2]

bool ui::AXNode::GetHtmlAttribute ( const char *  attribute,
std::u16string *  value 
) const
inline

Definition at line 284 of file ax_node.h.

284 {
285 return data().GetHtmlAttribute(attribute, value);
286 }

◆ GetIndexInParent()

size_t ui::AXNode::GetIndexInParent ( ) const

Definition at line 71 of file ax_node.cc.

71 {
73 return index_in_parent_;
74}

◆ GetInheritedString16Attribute()

std::u16string ui::AXNode::GetInheritedString16Attribute ( ax::mojom::StringAttribute  attribute) const

Definition at line 467 of file ax_node.cc.

468 {
470}
const std::string & GetInheritedStringAttribute(ax::mojom::StringAttribute attribute) const
Definition: ax_node.cc:456
std::u16string UTF8ToUTF16(std::string src)
Definition: string_utils.cc:67

◆ GetInheritedStringAttribute()

const std::string & ui::AXNode::GetInheritedStringAttribute ( ax::mojom::StringAttribute  attribute) const

Definition at line 456 of file ax_node.cc.

457 {
458 const AXNode* current_node = this;
459 do {
460 if (current_node->data().HasStringAttribute(attribute))
461 return current_node->data().GetStringAttribute(attribute);
462 current_node = current_node->parent();
463 } while (current_node);
464 return base::EmptyString();
465}
const std::string & EmptyString()

◆ GetInnerText()

std::string ui::AXNode::GetInnerText ( ) const

Definition at line 472 of file ax_node.cc.

472 {
473 // If a text field has no descendants, then we compute its inner text from its
474 // value or its placeholder. Otherwise we prefer to look at its descendant
475 // text nodes because Blink doesn't always add all trailing white space to the
476 // value attribute.
477 const bool is_plain_text_field_without_descendants =
479 if (is_plain_text_field_without_descendants) {
480 std::string value =
482 // If the value is empty, then there might be some placeholder text in the
483 // text field, or any other name that is derived from visible contents, even
484 // if the text field has no children.
485 if (!value.empty())
486 return value;
487 }
488
489 // Ordinarily, plain text fields are leaves. We need to exclude them from the
490 // set of leaf nodes when they expose any descendants. This is because we want
491 // to compute their inner text from their descendant text nodes as we don't
492 // always trust the "value" attribute provided by Blink.
493 const bool is_plain_text_field_with_descendants =
495 if (IsLeaf() && !is_plain_text_field_with_descendants) {
496 switch (data().GetNameFrom()) {
499 // The accessible name is not displayed on screen, e.g. aria-label, or is
500 // not displayed directly inside the node, e.g. an associated label
501 // element.
503 // The node's accessible name is explicitly empty.
505 // The accessible name does not represent the entirety of the node's inner
506 // text, e.g. a table's caption or a figure's figcaption.
509 // The accessible name is not displayed directly inside the node but is
510 // visible via e.g. a tooltip.
512 return std::string();
513
515 // The placeholder text is initially displayed inside the text field and
516 // takes the place of its value.
518 // The value attribute takes the place of the node's inner text, e.g. the
519 // value of a submit button is displayed inside the button itself.
522 }
523 }
524
525 std::string inner_text;
526 for (auto it = UnignoredChildrenBegin(); it != UnignoredChildrenEnd(); ++it) {
527 inner_text += it->GetInnerText();
528 }
529 return inner_text;
530}
UnignoredChildIterator UnignoredChildrenEnd() const
Definition: ax_node.cc:316
bool IsLeaf() const
Definition: ax_node.cc:1088
UnignoredChildIterator UnignoredChildrenBegin() const
Definition: ax_node.cc:311
bool IsTextField() const
ax::mojom::NameFrom GetNameFrom() const
const std::string & GetStringAttribute(ax::mojom::StringAttribute attribute) const

◆ GetIntAttribute() [1/2]

int ui::AXNode::GetIntAttribute ( ax::mojom::IntAttribute  attribute) const
inline

Definition at line 232 of file ax_node.h.

232 {
233 return data().GetIntAttribute(attribute);
234 }
int GetIntAttribute(ax::mojom::IntAttribute attribute) const

◆ GetIntAttribute() [2/2]

bool ui::AXNode::GetIntAttribute ( ax::mojom::IntAttribute  attribute,
int value 
) const
inline

Definition at line 235 of file ax_node.h.

235 {
236 return data().GetIntAttribute(attribute, value);
237 }

◆ GetIntListAttribute() [1/2]

const std::vector< int32_t > & ui::AXNode::GetIntListAttribute ( ax::mojom::IntListAttribute  attribute) const
inline

Definition at line 263 of file ax_node.h.

264 {
265 return data().GetIntListAttribute(attribute);
266 }
const std::vector< int32_t > & GetIntListAttribute(ax::mojom::IntListAttribute attribute) const

◆ GetIntListAttribute() [2/2]

bool ui::AXNode::GetIntListAttribute ( ax::mojom::IntListAttribute  attribute,
std::vector< int32_t > *  value 
) const
inline

Definition at line 267 of file ax_node.h.

268 {
269 return data().GetIntListAttribute(attribute, value);
270 }

◆ GetLanguage()

std::string ui::AXNode::GetLanguage ( ) const

Definition at line 532 of file ax_node.cc.

532 {
533 return std::string();
534}

◆ GetLastChild()

AXNode * ui::AXNode::GetLastChild ( ) const

Definition at line 329 of file ax_node.cc.

329 {
330 size_t n = children().size();
331 if (n == 0)
332 return nullptr;
333 return children()[n - 1];
334}

◆ GetLastUnignoredChild()

AXNode * ui::AXNode::GetLastUnignoredChild ( ) const

Definition at line 81 of file ax_node.cc.

81 {
83 return ComputeLastUnignoredChildRecursive();
84}

◆ GetLowestPlatformAncestor()

AXNode * ui::AXNode::GetLowestPlatformAncestor ( ) const

Definition at line 1202 of file ax_node.cc.

1202 {
1203 AXNode* current_node = const_cast<AXNode*>(this);
1204 AXNode* lowest_unignored_node = current_node;
1205 for (; lowest_unignored_node && lowest_unignored_node->IsIgnored();
1206 lowest_unignored_node = lowest_unignored_node->parent()) {
1207 }
1208
1209 // `highest_leaf_node` could be nullptr.
1210 AXNode* highest_leaf_node = lowest_unignored_node;
1211 // For the purposes of this method, a leaf node does not include leaves in the
1212 // internal accessibility tree, only in the platform exposed tree.
1213 for (AXNode* ancestor_node = lowest_unignored_node; ancestor_node;
1214 ancestor_node = ancestor_node->GetUnignoredParent()) {
1215 if (ancestor_node->IsLeaf())
1216 highest_leaf_node = ancestor_node;
1217 }
1218 if (highest_leaf_node)
1219 return highest_leaf_node;
1220
1221 if (lowest_unignored_node)
1222 return lowest_unignored_node;
1223 return current_node;
1224}

◆ GetNextSibling()

AXNode * ui::AXNode::GetNextSibling ( ) const

Definition at line 347 of file ax_node.cc.

347 {
348 if (!parent())
349 return nullptr;
350 size_t nextIndex = index_in_parent() + 1;
351 if (nextIndex >= parent()->children().size())
352 return nullptr;
353 return parent()->children()[nextIndex];
354}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ GetNextUnignoredInTreeOrder()

AXNode * ui::AXNode::GetNextUnignoredInTreeOrder ( ) const

Definition at line 284 of file ax_node.cc.

284 {
286 return GetFirstUnignoredChild();
287
288 const AXNode* node = this;
289 while (node) {
290 AXNode* sibling = node->GetNextUnignoredSibling();
291 if (sibling)
292 return sibling;
293
294 node = node->GetUnignoredParent();
295 }
296
297 return nullptr;
298}

◆ GetNextUnignoredSibling()

AXNode * ui::AXNode::GetNextUnignoredSibling ( ) const

Definition at line 155 of file ax_node.cc.

155 {
157 const AXNode* current = this;
158
159 // If there are children of the |current| node still to consider.
160 bool considerChildren = false;
161
162 while (current) {
163 // A |candidate| sibling to consider.
164 // If it is unignored then we have found our result.
165 // Otherwise promote it to |current| and consider its children.
166 AXNode* candidate;
167
168 if (considerChildren && (candidate = current->GetFirstChild())) {
169 if (!candidate->IsIgnored())
170 return candidate;
171 current = candidate;
172
173 } else if ((candidate = current->GetNextSibling())) {
174 if (!candidate->IsIgnored())
175 return candidate;
176 current = candidate;
177 // Look through the ignored candidate node to consider their children as
178 // though they were siblings.
179 considerChildren = true;
180
181 } else {
182 // Continue our search through a parent iff they are ignored.
183 //
184 // If |current| has an ignored parent, then we consider the parent's
185 // siblings as though they were siblings of |current|.
186 //
187 // Given a tree:
188 // 1
189 // ├── 2(?)
190 // │ └── [4]
191 // └── 3
192 //
193 // Node 4's view of siblings:
194 // literal tree: null <-- [4] --> null
195 //
196 // If node 2 is not ignored, then node 4's view doesn't change, and we
197 // have no more nodes to consider:
198 // unignored tree: null <-- [4] --> null
199 //
200 // If instead node 2 is ignored, then node 4's view of siblings grows to
201 // include node 3, and we have more nodes to consider:
202 // unignored tree: null <-- [4] --> 3
203 current = current->parent();
204 if (!current || !current->IsIgnored())
205 return nullptr;
206
207 // We have already considered all relevant descendants of |current|.
208 considerChildren = false;
209 }
210 }
211
212 return nullptr;
213}

◆ GetOrComputeLineStartOffsets()

std::vector< int > ui::AXNode::GetOrComputeLineStartOffsets ( )

Definition at line 416 of file ax_node.cc.

416 {
417 std::vector<int> line_offsets;
419 &line_offsets)) {
420 return line_offsets;
421 }
422
423 int start_offset = 0;
424 ComputeLineStartOffsets(&line_offsets, &start_offset);
426 line_offsets);
427 return line_offsets;
428}
const std::vector< int32_t > & GetIntListAttribute(ax::mojom::IntListAttribute attribute) const
Definition: ax_node.h:263
void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector< int32_t > &value)

◆ GetOrderedSet()

AXNode * ui::AXNode::GetOrderedSet ( ) const

Definition at line 1032 of file ax_node.cc.

1032 {
1033 AXNode* result = parent();
1034 // Continue walking up while parent is invalid, ignored, a generic container,
1035 // unknown, or embedded group.
1036 while (result && result->IsIgnoredContainerForOrderedSet()) {
1037 result = result->parent();
1038 }
1039
1040 return result;
1041}
GAsyncResult * result

◆ GetParentCrossingTreeBoundary()

AXNode * ui::AXNode::GetParentCrossingTreeBoundary ( ) const

Definition at line 1249 of file ax_node.cc.

1249 {
1251 if (parent_)
1252 return parent_;
1253 const AXTreeManager* manager =
1255 if (manager)
1256 return manager->GetParentNodeFromParentTreeAsAXNode();
1257 return nullptr;
1258}
virtual AXTreeID GetAXTreeID() const =0
AXTreeManager * GetManager(AXTreeID tree_id)
static AXTreeManagerMap & GetInstance()
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
Definition: switches.h:218

◆ GetPosInSet()

std::optional< int > ui::AXNode::GetPosInSet ( )

Definition at line 949 of file ax_node.cc.

949 {
950 return tree_->GetPosInSet(*this);
951}
virtual std::optional< int > GetPosInSet(const AXNode &node)=0

◆ GetPreviousSibling()

AXNode * ui::AXNode::GetPreviousSibling ( ) const

Definition at line 337 of file ax_node.cc.

337 {
338 // Root nodes lack a parent, their index_in_parent should be 0.
339 BASE_DCHECK(!parent() ? index_in_parent() == 0 : true);
340 size_t index = index_in_parent();
341 if (index == 0)
342 return nullptr;
343 return parent()->children()[index - 1];
344}

◆ GetPreviousUnignoredInTreeOrder()

AXNode * ui::AXNode::GetPreviousUnignoredInTreeOrder ( ) const

Definition at line 300 of file ax_node.cc.

300 {
302 if (!sibling)
303 return GetUnignoredParent();
304
305 if (sibling->GetUnignoredChildCount())
306 return sibling->GetDeepestLastUnignoredChild();
307
308 return sibling;
309}
AXNode * GetUnignoredParent() const
Definition: ax_node.cc:58
AXNode * GetPreviousUnignoredSibling() const
Definition: ax_node.cc:224

◆ GetPreviousUnignoredSibling()

AXNode * ui::AXNode::GetPreviousUnignoredSibling ( ) const

Definition at line 224 of file ax_node.cc.

224 {
226 const AXNode* current = this;
227
228 // If there are children of the |current| node still to consider.
229 bool considerChildren = false;
230
231 while (current) {
232 // A |candidate| sibling to consider.
233 // If it is unignored then we have found our result.
234 // Otherwise promote it to |current| and consider its children.
235 AXNode* candidate;
236
237 if (considerChildren && (candidate = current->GetLastChild())) {
238 if (!candidate->IsIgnored())
239 return candidate;
240 current = candidate;
241
242 } else if ((candidate = current->GetPreviousSibling())) {
243 if (!candidate->IsIgnored())
244 return candidate;
245 current = candidate;
246 // Look through the ignored candidate node to consider their children as
247 // though they were siblings.
248 considerChildren = true;
249
250 } else {
251 // Continue our search through a parent iff they are ignored.
252 //
253 // If |current| has an ignored parent, then we consider the parent's
254 // siblings as though they were siblings of |current|.
255 //
256 // Given a tree:
257 // 1
258 // ├── 2
259 // └── 3(?)
260 // └── [4]
261 //
262 // Node 4's view of siblings:
263 // literal tree: null <-- [4] --> null
264 //
265 // If node 3 is not ignored, then node 4's view doesn't change, and we
266 // have no more nodes to consider:
267 // unignored tree: null <-- [4] --> null
268 //
269 // If instead node 3 is ignored, then node 4's view of siblings grows to
270 // include node 2, and we have more nodes to consider:
271 // unignored tree: 2 <-- [4] --> null
272 current = current->parent();
273 if (!current || !current->IsIgnored())
274 return nullptr;
275
276 // We have already considered all relevant descendants of |current|.
277 considerChildren = false;
278 }
279 }
280
281 return nullptr;
282}

◆ GetSetSize()

std::optional< int > ui::AXNode::GetSetSize ( )

Definition at line 954 of file ax_node.cc.

954 {
955 return tree_->GetSetSize(*this);
956}
virtual std::optional< int > GetSetSize(const AXNode &node)=0

◆ GetString16Attribute() [1/2]

std::u16string ui::AXNode::GetString16Attribute ( ax::mojom::StringAttribute  attribute) const
inline

Definition at line 255 of file ax_node.h.

256 {
257 return data().GetString16Attribute(attribute);
258 }
bool GetString16Attribute(ax::mojom::StringAttribute attribute, std::u16string *value) const

◆ GetString16Attribute() [2/2]

bool ui::AXNode::GetString16Attribute ( ax::mojom::StringAttribute  attribute,
std::u16string *  value 
) const
inline

Definition at line 251 of file ax_node.h.

252 {
253 return data().GetString16Attribute(attribute, value);
254 }

◆ GetStringAttribute() [1/2]

const std::string & ui::AXNode::GetStringAttribute ( ax::mojom::StringAttribute  attribute) const
inline

Definition at line 242 of file ax_node.h.

243 {
244 return data().GetStringAttribute(attribute);
245 }

◆ GetStringAttribute() [2/2]

bool ui::AXNode::GetStringAttribute ( ax::mojom::StringAttribute  attribute,
std::string *  value 
) const
inline

Definition at line 246 of file ax_node.h.

247 {
248 return data().GetStringAttribute(attribute, value);
249 }

◆ GetStringListAttribute() [1/2]

const std::vector< std::string > & ui::AXNode::GetStringListAttribute ( ax::mojom::StringListAttribute  attribute) const
inline

Definition at line 275 of file ax_node.h.

276 {
277 return data().GetStringListAttribute(attribute);
278 }
const std::vector< std::string > & GetStringListAttribute(ax::mojom::StringListAttribute attribute) const

◆ GetStringListAttribute() [2/2]

bool ui::AXNode::GetStringListAttribute ( ax::mojom::StringListAttribute  attribute,
std::vector< std::string > *  value 
) const
inline

Definition at line 279 of file ax_node.h.

280 {
281 return data().GetStringListAttribute(attribute, value);
282 }

◆ GetTableAriaColCount()

std::optional< int > ui::AXNode::GetTableAriaColCount ( ) const

Definition at line 558 of file ax_node.cc.

558 {
559 const AXTableInfo* table_info = GetAncestorTableInfo();
560 if (!table_info)
561 return std::nullopt;
562 return std::make_optional(table_info->aria_col_count);
563}

◆ GetTableAriaRowCount()

std::optional< int > ui::AXNode::GetTableAriaRowCount ( ) const

Definition at line 565 of file ax_node.cc.

565 {
566 const AXTableInfo* table_info = GetAncestorTableInfo();
567 if (!table_info)
568 return std::nullopt;
569 return std::make_optional(table_info->aria_row_count);
570}

◆ GetTableCaption()

AXNode * ui::AXNode::GetTableCaption ( ) const

Definition at line 603 of file ax_node.cc.

603 {
604 const AXTableInfo* table_info = GetAncestorTableInfo();
605 if (!table_info)
606 return nullptr;
607
608 return tree_->GetFromId(table_info->caption_id);
609}
virtual AXNode * GetFromId(int32_t id) const =0

◆ GetTableCellAriaColIndex()

std::optional< int > ui::AXNode::GetTableCellAriaColIndex ( ) const

Definition at line 822 of file ax_node.cc.

822 {
823 const AXTableInfo* table_info = GetAncestorTableInfo();
824 if (!table_info)
825 return std::nullopt;
826
827 std::optional<int> index = GetTableCellIndex();
828 if (!index)
829 return std::nullopt;
830
831 return static_cast<int>(table_info->cell_data_vector[*index].aria_col_index);
832}
std::optional< int > GetTableCellIndex() const
Definition: ax_node.cc:758

◆ GetTableCellAriaRowIndex()

std::optional< int > ui::AXNode::GetTableCellAriaRowIndex ( ) const

Definition at line 834 of file ax_node.cc.

834 {
835 const AXTableInfo* table_info = GetAncestorTableInfo();
836 if (!table_info)
837 return std::nullopt;
838
839 std::optional<int> index = GetTableCellIndex();
840 if (!index)
841 return std::nullopt;
842
843 return static_cast<int>(table_info->cell_data_vector[*index].aria_row_index);
844}

◆ GetTableCellColHeaderNodeIds()

std::vector< AXNode::AXID > ui::AXNode::GetTableCellColHeaderNodeIds ( ) const

Definition at line 846 of file ax_node.cc.

846 {
847 const AXTableInfo* table_info = GetAncestorTableInfo();
848 if (!table_info || table_info->col_count <= 0)
849 return std::vector<AXNode::AXID>();
850
851 // If this node is not a cell, then return the headers for the first column.
852 int col_index = GetTableCellColIndex().value_or(0);
853
854 return std::vector<AXNode::AXID>(table_info->col_headers[col_index]);
855}
std::optional< int > GetTableCellColIndex() const
Definition: ax_node.cc:772

◆ GetTableCellColHeaders()

void ui::AXNode::GetTableCellColHeaders ( std::vector< AXNode * > *  col_headers) const

Definition at line 857 of file ax_node.cc.

857 {
858 BASE_DCHECK(col_headers);
859
860 std::vector<int32_t> col_header_ids = GetTableCellColHeaderNodeIds();
861 IdVectorToNodeVector(col_header_ids, col_headers);
862}
std::vector< AXNode::AXID > GetTableCellColHeaderNodeIds() const
Definition: ax_node.cc:846

◆ GetTableCellColIndex()

std::optional< int > ui::AXNode::GetTableCellColIndex ( ) const

Definition at line 772 of file ax_node.cc.

772 {
773 const AXTableInfo* table_info = GetAncestorTableInfo();
774 if (!table_info)
775 return std::nullopt;
776
777 std::optional<int> index = GetTableCellIndex();
778 if (!index)
779 return std::nullopt;
780
781 return static_cast<int>(table_info->cell_data_vector[*index].col_index);
782}

◆ GetTableCellColSpan()

std::optional< int > ui::AXNode::GetTableCellColSpan ( ) const

Definition at line 796 of file ax_node.cc.

796 {
797 // If it's not a table cell, don't return a col span.
798 if (!IsTableCellOrHeader())
799 return std::nullopt;
800
801 // Otherwise, try to return a colspan, with 1 as the default if it's not
802 // specified.
803 int col_span;
805 return col_span;
806 return 1;
807}
bool IsTableCellOrHeader() const
Definition: ax_node.cc:754

◆ GetTableCellCount()

std::optional< int > ui::AXNode::GetTableCellCount ( ) const

Definition at line 572 of file ax_node.cc.

572 {
573 const AXTableInfo* table_info = GetAncestorTableInfo();
574 if (!table_info)
575 return std::nullopt;
576
577 return static_cast<int>(table_info->unique_cell_ids.size());
578}

◆ GetTableCellFromCoords()

AXNode * ui::AXNode::GetTableCellFromCoords ( int  row_index,
int  col_index 
) const

Definition at line 611 of file ax_node.cc.

611 {
612 const AXTableInfo* table_info = GetAncestorTableInfo();
613 if (!table_info)
614 return nullptr;
615
616 // There is a table but the given coordinates are outside the table.
617 if (row_index < 0 ||
618 static_cast<size_t>(row_index) >= table_info->row_count ||
619 col_index < 0 ||
620 static_cast<size_t>(col_index) >= table_info->col_count) {
621 return nullptr;
622 }
623
624 return tree_->GetFromId(table_info->cell_ids[static_cast<size_t>(row_index)]
625 [static_cast<size_t>(col_index)]);
626}

◆ GetTableCellFromIndex()

AXNode * ui::AXNode::GetTableCellFromIndex ( int  index) const

Definition at line 588 of file ax_node.cc.

588 {
589 const AXTableInfo* table_info = GetAncestorTableInfo();
590 if (!table_info)
591 return nullptr;
592
593 // There is a table but there is no cell with the given index.
594 if (index < 0 ||
595 static_cast<size_t>(index) >= table_info->unique_cell_ids.size()) {
596 return nullptr;
597 }
598
599 return tree_->GetFromId(
600 table_info->unique_cell_ids[static_cast<size_t>(index)]);
601}

◆ GetTableCellIndex()

std::optional< int > ui::AXNode::GetTableCellIndex ( ) const

Definition at line 758 of file ax_node.cc.

758 {
759 if (!IsTableCellOrHeader())
760 return std::nullopt;
761
762 const AXTableInfo* table_info = GetAncestorTableInfo();
763 if (!table_info)
764 return std::nullopt;
765
766 const auto& iter = table_info->cell_id_to_index.find(id());
767 if (iter != table_info->cell_id_to_index.end())
768 return static_cast<int>(iter->second);
769 return std::nullopt;
770}

◆ GetTableCellRowHeaderNodeIds()

std::vector< AXNode::AXID > ui::AXNode::GetTableCellRowHeaderNodeIds ( ) const

Definition at line 864 of file ax_node.cc.

864 {
865 const AXTableInfo* table_info = GetAncestorTableInfo();
866 if (!table_info || table_info->row_count <= 0)
867 return std::vector<AXNode::AXID>();
868
869 // If this node is not a cell, then return the headers for the first row.
870 int row_index = GetTableCellRowIndex().value_or(0);
871
872 return std::vector<AXNode::AXID>(table_info->row_headers[row_index]);
873}
std::optional< int > GetTableCellRowIndex() const
Definition: ax_node.cc:784

◆ GetTableCellRowHeaders()

void ui::AXNode::GetTableCellRowHeaders ( std::vector< AXNode * > *  row_headers) const

Definition at line 875 of file ax_node.cc.

875 {
876 BASE_DCHECK(row_headers);
877
878 std::vector<int32_t> row_header_ids = GetTableCellRowHeaderNodeIds();
879 IdVectorToNodeVector(row_header_ids, row_headers);
880}
std::vector< AXNode::AXID > GetTableCellRowHeaderNodeIds() const
Definition: ax_node.cc:864

◆ GetTableCellRowIndex()

std::optional< int > ui::AXNode::GetTableCellRowIndex ( ) const

Definition at line 784 of file ax_node.cc.

784 {
785 const AXTableInfo* table_info = GetAncestorTableInfo();
786 if (!table_info)
787 return std::nullopt;
788
789 std::optional<int> index = GetTableCellIndex();
790 if (!index)
791 return std::nullopt;
792
793 return static_cast<int>(table_info->cell_data_vector[*index].row_index);
794}

◆ GetTableCellRowSpan()

std::optional< int > ui::AXNode::GetTableCellRowSpan ( ) const

Definition at line 809 of file ax_node.cc.

809 {
810 // If it's not a table cell, don't return a row span.
811 if (!IsTableCellOrHeader())
812 return std::nullopt;
813
814 // Otherwise, try to return a row span, with 1 as the default if it's not
815 // specified.
816 int row_span;
818 return row_span;
819 return 1;
820}

◆ GetTableColCount()

std::optional< int > ui::AXNode::GetTableColCount ( ) const

Definition at line 544 of file ax_node.cc.

544 {
545 const AXTableInfo* table_info = GetAncestorTableInfo();
546 if (!table_info)
547 return std::nullopt;
548 return static_cast<int>(table_info->col_count);
549}

◆ GetTableColHeaderNodeIds() [1/2]

std::vector< AXNode::AXID > ui::AXNode::GetTableColHeaderNodeIds ( ) const

Definition at line 628 of file ax_node.cc.

628 {
629 const AXTableInfo* table_info = GetAncestorTableInfo();
630 if (!table_info)
631 return std::vector<AXNode::AXID>();
632
633 std::vector<AXNode::AXID> col_header_ids;
634 // Flatten and add column header ids of each column to |col_header_ids|.
635 for (std::vector<AXNode::AXID> col_headers_at_index :
636 table_info->col_headers) {
637 col_header_ids.insert(col_header_ids.end(), col_headers_at_index.begin(),
638 col_headers_at_index.end());
639 }
640
641 return col_header_ids;
642}

◆ GetTableColHeaderNodeIds() [2/2]

std::vector< AXNode::AXID > ui::AXNode::GetTableColHeaderNodeIds ( int  col_index) const

Definition at line 644 of file ax_node.cc.

645 {
646 const AXTableInfo* table_info = GetAncestorTableInfo();
647 if (!table_info)
648 return std::vector<AXNode::AXID>();
649
650 if (col_index < 0 || static_cast<size_t>(col_index) >= table_info->col_count)
651 return std::vector<AXNode::AXID>();
652
653 return std::vector<AXNode::AXID>(
654 table_info->col_headers[static_cast<size_t>(col_index)]);
655}

◆ GetTableHasColumnOrRowHeaderNode()

std::optional< bool > ui::AXNode::GetTableHasColumnOrRowHeaderNode ( ) const

Definition at line 580 of file ax_node.cc.

580 {
581 const AXTableInfo* table_info = GetAncestorTableInfo();
582 if (!table_info)
583 return std::nullopt;
584
585 return !table_info->all_headers.empty();
586}

◆ GetTableRowCount()

std::optional< int > ui::AXNode::GetTableRowCount ( ) const

Definition at line 551 of file ax_node.cc.

551 {
552 const AXTableInfo* table_info = GetAncestorTableInfo();
553 if (!table_info)
554 return std::nullopt;
555 return static_cast<int>(table_info->row_count);
556}

◆ GetTableRowHeaderNodeIds()

std::vector< AXNode::AXID > ui::AXNode::GetTableRowHeaderNodeIds ( int  row_index) const

Definition at line 657 of file ax_node.cc.

658 {
659 const AXTableInfo* table_info = GetAncestorTableInfo();
660 if (!table_info)
661 return std::vector<AXNode::AXID>();
662
663 if (row_index < 0 || static_cast<size_t>(row_index) >= table_info->row_count)
664 return std::vector<AXNode::AXID>();
665
666 return std::vector<AXNode::AXID>(
667 table_info->row_headers[static_cast<size_t>(row_index)]);
668}

◆ GetTableRowNodeIds()

std::vector< AXNode::AXID > ui::AXNode::GetTableRowNodeIds ( ) const

Definition at line 709 of file ax_node.cc.

709 {
710 std::vector<AXNode::AXID> row_node_ids;
711 const AXTableInfo* table_info = GetAncestorTableInfo();
712 if (!table_info)
713 return row_node_ids;
714
715 for (AXNode* node : table_info->row_nodes)
716 row_node_ids.push_back(node->data().id);
717
718 return row_node_ids;
719}

◆ GetTableRowRowIndex()

std::optional< int > ui::AXNode::GetTableRowRowIndex ( ) const

Definition at line 695 of file ax_node.cc.

695 {
696 if (!IsTableRow())
697 return std::nullopt;
698
699 const AXTableInfo* table_info = GetAncestorTableInfo();
700 if (!table_info)
701 return std::nullopt;
702
703 const auto& iter = table_info->row_id_to_index.find(id());
704 if (iter == table_info->row_id_to_index.end())
705 return std::nullopt;
706 return static_cast<int>(iter->second);
707}
bool IsTableRow() const
Definition: ax_node.cc:691

◆ GetTableUniqueCellIds()

std::vector< AXNode::AXID > ui::AXNode::GetTableUniqueCellIds ( ) const

Definition at line 670 of file ax_node.cc.

670 {
671 const AXTableInfo* table_info = GetAncestorTableInfo();
672 if (!table_info)
673 return std::vector<AXNode::AXID>();
674
675 return std::vector<AXNode::AXID>(table_info->unique_cell_ids);
676}

◆ GetTextFieldAncestor()

AXNode * ui::AXNode::GetTextFieldAncestor ( ) const

Definition at line 1226 of file ax_node.cc.

1226 {
1228
1231 return parent;
1232
1234 }
1235
1236 return nullptr;
1237}
bool IsPlainTextField() const
bool HasState(ax::mojom::State state) const
bool IsRichTextField() const

◆ GetUnignoredChildAtIndex()

AXNode * ui::AXNode::GetUnignoredChildAtIndex ( size_t  index) const

Definition at line 47 of file ax_node.cc.

47 {
49 size_t count = 0;
50 for (auto it = UnignoredChildrenBegin(); it != UnignoredChildrenEnd(); ++it) {
51 if (count == index)
52 return it.get();
53 ++count;
54 }
55 return nullptr;
56}
int count
Definition: FontMgrTest.cpp:50

◆ GetUnignoredChildCount()

size_t ui::AXNode::GetUnignoredChildCount ( ) const

Definition at line 37 of file ax_node.cc.

37 {
38 // TODO(nektar): Should BASE_DCHECK if the node is not ignored.
40 return unignored_child_count_;
41}

◆ GetUnignoredIndexInParent()

size_t ui::AXNode::GetUnignoredIndexInParent ( ) const

Definition at line 66 of file ax_node.cc.

66 {
68 return unignored_index_in_parent_;
69}

◆ GetUnignoredParent()

AXNode * ui::AXNode::GetUnignoredParent ( ) const

Definition at line 58 of file ax_node.cc.

58 {
60 AXNode* result = parent();
61 while (result && result->IsIgnored())
62 result = result->parent();
63 return result;
64}

◆ GetUnignoredSelection()

AXTree::Selection ui::AXNode::GetUnignoredSelection ( ) const

Definition at line 1260 of file ax_node.cc.

1260 {
1261 BASE_DCHECK(tree())
1262 << "Cannot retrieve the current selection if the node is not "
1263 "attached to an accessibility tree.\n"
1264 << *this;
1265 AXTree::Selection selection = tree()->GetUnignoredSelection();
1266
1267 // "selection.anchor_offset" and "selection.focus_ofset" might need to be
1268 // adjusted if the anchor or the focus nodes include ignored children.
1269 //
1270 // TODO(nektar): Move this logic into its own "AXSelection" class and cache
1271 // the result for faster reuse.
1272 const AXNode* anchor = tree()->GetFromId(selection.anchor_object_id);
1273 if (anchor && !anchor->IsLeaf()) {
1274 BASE_DCHECK(selection.anchor_offset >= 0);
1275 if (static_cast<size_t>(selection.anchor_offset) <
1276 anchor->children().size()) {
1277 const AXNode* anchor_child = anchor->children()[selection.anchor_offset];
1278 BASE_DCHECK(anchor_child);
1279 selection.anchor_offset =
1280 static_cast<int>(anchor_child->GetUnignoredIndexInParent());
1281 } else {
1282 selection.anchor_offset =
1283 static_cast<int>(anchor->GetUnignoredChildCount());
1284 }
1285 }
1286
1287 const AXNode* focus = tree()->GetFromId(selection.focus_object_id);
1288 if (focus && !focus->IsLeaf()) {
1289 BASE_DCHECK(selection.focus_offset >= 0);
1290 if (static_cast<size_t>(selection.focus_offset) <
1291 focus->children().size()) {
1292 const AXNode* focus_child = focus->children()[selection.focus_offset];
1293 BASE_DCHECK(focus_child);
1294 selection.focus_offset =
1295 static_cast<int>(focus_child->GetUnignoredIndexInParent());
1296 } else {
1297 selection.focus_offset =
1298 static_cast<int>(focus->GetUnignoredChildCount());
1299 }
1300 }
1301 return selection;
1302}
virtual Selection GetUnignoredSelection() const =0

◆ HasBoolAttribute()

bool ui::AXNode::HasBoolAttribute ( ax::mojom::BoolAttribute  attribute) const
inline

Definition at line 208 of file ax_node.h.

208 {
209 return data().HasBoolAttribute(attribute);
210 }
bool HasBoolAttribute(ax::mojom::BoolAttribute attribute) const

◆ HasFloatAttribute()

bool ui::AXNode::HasFloatAttribute ( ax::mojom::FloatAttribute  attribute) const
inline

Definition at line 218 of file ax_node.h.

218 {
219 return data().HasFloatAttribute(attribute);
220 }
bool HasFloatAttribute(ax::mojom::FloatAttribute attribute) const

◆ HasIntAttribute()

bool ui::AXNode::HasIntAttribute ( ax::mojom::IntAttribute  attribute) const
inline

Definition at line 229 of file ax_node.h.

229 {
230 return data().HasIntAttribute(attribute);
231 }
bool HasIntAttribute(ax::mojom::IntAttribute attribute) const

◆ HasIntListAttribute()

bool ui::AXNode::HasIntListAttribute ( ax::mojom::IntListAttribute  attribute) const
inline

Definition at line 260 of file ax_node.h.

260 {
261 return data().HasIntListAttribute(attribute);
262 }
bool HasIntListAttribute(ax::mojom::IntListAttribute attribute) const

◆ HasStringAttribute()

bool ui::AXNode::HasStringAttribute ( ax::mojom::StringAttribute  attribute) const
inline

Definition at line 239 of file ax_node.h.

239 {
240 return data().HasStringAttribute(attribute);
241 }
bool HasStringAttribute(ax::mojom::StringAttribute attribute) const

◆ HasStringListAttribute()

bool ui::AXNode::HasStringListAttribute ( ax::mojom::StringListAttribute  attribute) const
inline

Definition at line 272 of file ax_node.h.

272 {
273 return data().HasStringListAttribute(attribute);
274 }
bool HasStringListAttribute(ax::mojom::StringListAttribute attribute) const

◆ id()

AXID ui::AXNode::id ( ) const
inline

Definition at line 110 of file ax_node.h.

110{ return data_.id; }

◆ index_in_parent()

size_t ui::AXNode::index_in_parent ( ) const
inline

Definition at line 114 of file ax_node.h.

114{ return index_in_parent_; }

◆ IsCellOrHeaderOfARIAGrid()

bool ui::AXNode::IsCellOrHeaderOfARIAGrid ( ) const

Definition at line 895 of file ax_node.cc.

895 {
896 if (!IsTableCellOrHeader())
897 return false;
898
899 const AXNode* node = this;
900 while (node && !node->IsTable())
901 node = node->parent();
902 if (!node)
903 return false;
904
905 return node->data().role == ax::mojom::Role::kGrid ||
906 node->data().role == ax::mojom::Role::kTreeGrid;
907}

◆ IsCellOrHeaderOfARIATable()

bool ui::AXNode::IsCellOrHeaderOfARIATable ( ) const

Definition at line 882 of file ax_node.cc.

882 {
883 if (!IsTableCellOrHeader())
884 return false;
885
886 const AXNode* node = this;
887 while (node && !node->IsTable())
888 node = node->parent();
889 if (!node)
890 return false;
891
892 return node->data().role == ax::mojom::Role::kTable;
893}

◆ IsChildOfLeaf()

bool ui::AXNode::IsChildOfLeaf ( ) const

Definition at line 1078 of file ax_node.cc.

1078 {
1079 const AXNode* ancestor = GetUnignoredParent();
1080 while (ancestor) {
1081 if (ancestor->IsLeaf())
1082 return true;
1083 ancestor = ancestor->GetUnignoredParent();
1084 }
1085 return false;
1086}

◆ IsCollapsedMenuListPopUpButton()

bool ui::AXNode::IsCollapsedMenuListPopUpButton ( ) const

Definition at line 1162 of file ax_node.cc.

1162 {
1163 if (data().role != ax::mojom::Role::kPopUpButton ||
1164 !data().HasState(ax::mojom::State::kCollapsed)) {
1165 return false;
1166 }
1167
1168 // When a popup button contains a menu list popup, its only child is unignored
1169 // and is a menu list popup.
1171 if (!node)
1172 return false;
1173
1174 return node->data().role == ax::mojom::Role::kMenuListPopup;
1175}

◆ IsDescendantOf()

bool ui::AXNode::IsDescendantOf ( const AXNode ancestor) const

Definition at line 407 of file ax_node.cc.

407 {
408 if (this == ancestor)
409 return true;
410 if (parent())
411 return parent()->IsDescendantOf(ancestor);
412
413 return false;
414}
bool IsDescendantOf(const AXNode *ancestor) const
Definition: ax_node.cc:407

◆ IsDescendantOfCrossingTreeBoundary()

bool ui::AXNode::IsDescendantOfCrossingTreeBoundary ( const AXNode ancestor) const

Definition at line 1239 of file ax_node.cc.

1239 {
1240 if (!ancestor)
1241 return false;
1242 if (this == ancestor)
1243 return true;
1246 return false;
1247}
AXNode * GetParentCrossingTreeBoundary() const
Definition: ax_node.cc:1249
bool IsDescendantOfCrossingTreeBoundary(const AXNode *ancestor) const
Definition: ax_node.cc:1239

◆ IsEmbeddedGroup()

bool ui::AXNode::IsEmbeddedGroup ( ) const

Definition at line 1195 of file ax_node.cc.

1195 {
1196 if (data().role != ax::mojom::Role::kGroup || !parent())
1197 return false;
1198
1199 return ui::IsSetLike(parent()->data().role);
1200}
bool IsSetLike(const ax::mojom::Role role)

◆ IsIgnored()

bool ui::AXNode::IsIgnored ( ) const

Definition at line 1074 of file ax_node.cc.

1074 {
1075 return data().IsIgnored();
1076}
bool IsIgnored() const

◆ IsIgnoredContainerForOrderedSet()

bool ui::AXNode::IsIgnoredContainerForOrderedSet ( ) const

Definition at line 1009 of file ax_node.cc.

1009 {
1010 return IsIgnored() || IsEmbeddedGroup() ||
1014}
bool IsEmbeddedGroup() const
Definition: ax_node.cc:1195
bool IsIgnored() const
Definition: ax_node.cc:1074
ax::mojom::Role role
Definition: ax_node_data.h:277

◆ IsInListMarker()

bool ui::AXNode::IsInListMarker ( ) const

Definition at line 1139 of file ax_node.cc.

1139 {
1140 if (data().role == ax::mojom::Role::kListMarker)
1141 return true;
1142
1143 // List marker node's children can only be text elements.
1144 if (!IsText())
1145 return false;
1146
1147 // There is no need to iterate over all the ancestors of the current anchor
1148 // since a list marker node only has children on 2 levels.
1149 // i.e.:
1150 // AXLayoutObject role=kListMarker
1151 // ++StaticText
1152 // ++++InlineTextBox
1153 AXNode* parent_node = GetUnignoredParent();
1154 if (parent_node && parent_node->data().role == ax::mojom::Role::kListMarker)
1155 return true;
1156
1157 AXNode* grandparent_node = parent_node->GetUnignoredParent();
1158 return grandparent_node &&
1159 grandparent_node->data().role == ax::mojom::Role::kListMarker;
1160}
bool IsText() const
Definition: ax_node.cc:356

◆ IsLeaf()

bool ui::AXNode::IsLeaf ( ) const

Definition at line 1088 of file ax_node.cc.

1088 {
1089 // A node is also a leaf if all of it's descendants are ignored.
1091 return true;
1092
1093#if defined(OS_WIN)
1094 // On Windows, we want to hide the subtree of a collapsed <select> element.
1095 // Otherwise, ATs are always going to announce its options whether it's
1096 // collapsed or expanded. In the AXTree, this element corresponds to a node
1097 // with role ax::mojom::Role::kPopUpButton that is the parent of a node with
1098 // role ax::mojom::Role::kMenuListPopup.
1100 return true;
1101#endif // defined(OS_WIN)
1102
1103 // These types of objects may have children that we use as internal
1104 // implementation details, but we want to expose them as leaves to platform
1105 // accessibility APIs because screen readers might be confused if they find
1106 // any children.
1107 if (data().IsPlainTextField() || IsText())
1108 return true;
1109
1110 // Roles whose children are only presentational according to the ARIA and
1111 // HTML5 Specs should be hidden from screen readers.
1112 switch (data().role) {
1113 // According to the ARIA and Core-AAM specs:
1114 // https://w3c.github.io/aria/#button,
1115 // https://www.w3.org/TR/core-aam-1.1/#exclude_elements
1116 // buttons' children are presentational only and should be hidden from
1117 // screen readers. However, we cannot enforce the leafiness of buttons
1118 // because they may contain many rich, interactive descendants such as a day
1119 // in a calendar, and screen readers will need to interact with these
1120 // contents. See https://crbug.com/689204.
1121 // So we decided to not enforce the leafiness of buttons and expose all
1122 // children.
1124 return false;
1133 return true;
1134 default:
1135 return false;
1136 }
1137}
bool IsCollapsedMenuListPopUpButton() const
Definition: ax_node.cc:1162

◆ IsLineBreak()

bool ui::AXNode::IsLineBreak ( ) const

◆ IsOrderedSet()

bool ui::AXNode::IsOrderedSet ( ) const

Definition at line 944 of file ax_node.cc.

944 {
945 return ui::IsSetLike(data().role);
946}

◆ IsOrderedSetItem()

bool ui::AXNode::IsOrderedSetItem ( ) const

Definition at line 940 of file ax_node.cc.

940 {
941 return ui::IsItemLike(data().role);
942}
bool IsItemLike(const ax::mojom::Role role)

◆ IsTable()

bool ui::AXNode::IsTable ( ) const

Definition at line 540 of file ax_node.cc.

540 {
541 return IsTableLike(data().role);
542}
bool IsTableLike(const ax::mojom::Role role)

◆ IsTableCellOrHeader()

bool ui::AXNode::IsTableCellOrHeader ( ) const

Definition at line 754 of file ax_node.cc.

754 {
755 return IsCellOrTableHeader(data().role);
756}
bool IsCellOrTableHeader(const ax::mojom::Role role)

◆ IsTableRow()

bool ui::AXNode::IsTableRow ( ) const

Definition at line 691 of file ax_node.cc.

691 {
692 return ui::IsTableRow(data().role);
693}
bool IsTableRow(ax::mojom::Role role)

◆ IsText()

bool ui::AXNode::IsText ( ) const

Definition at line 356 of file ax_node.cc.

356 {
357 // In Legacy Layout, a list marker has no children and is thus represented on
358 // all platforms as a leaf node that exposes the marker itself, i.e., it forms
359 // part of the AX tree's text representation. In contrast, in Layout NG, a
360 // list marker has a static text child.
362 return !children().size();
363 return ui::IsText(data().role);
364}
bool IsText(ax::mojom::Role role)

◆ parent()

AXNode * ui::AXNode::parent ( ) const
inline

Definition at line 111 of file ax_node.h.

111{ return parent_; }

◆ SetData()

void ui::AXNode::SetData ( const AXNodeData src)

Definition at line 373 of file ax_node.cc.

373 {
374 data_ = src;
375}

◆ SetIndexInParent()

void ui::AXNode::SetIndexInParent ( size_t  index_in_parent)

Definition at line 390 of file ax_node.cc.

390 {
391 index_in_parent_ = index_in_parent;
392}

◆ SetLocation()

void ui::AXNode::SetLocation ( int32_t  offset_container_id,
const gfx::RectF location,
gfx::Transform transform 
)

Definition at line 377 of file ax_node.cc.

379 {
380 data_.relative_bounds.offset_container_id = offset_container_id;
381 data_.relative_bounds.bounds = location;
382 if (transform) {
384 std::make_unique<gfx::Transform>(*transform);
385 } else {
386 data_.relative_bounds.transform.reset();
387 }
388}
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition: p3.cpp:47
AXRelativeBounds relative_bounds
Definition: ax_node_data.h:293
std::unique_ptr< gfx::Transform > transform

◆ SetRoleMatchesItemRole()

bool ui::AXNode::SetRoleMatchesItemRole ( const AXNode ordered_set) const

Definition at line 960 of file ax_node.cc.

960 {
961 ax::mojom::Role item_role = data().role;
962 // Switch on role of ordered set
963 switch (ordered_set->data().role) {
965 return item_role == ax::mojom::Role::kArticle;
967 return item_role == ax::mojom::Role::kListItem;
969 return item_role == ax::mojom::Role::kComment ||
970 item_role == ax::mojom::Role::kListItem ||
971 item_role == ax::mojom::Role::kMenuItem ||
972 item_role == ax::mojom::Role::kMenuItemRadio ||
973 item_role == ax::mojom::Role::kListBoxOption ||
974 item_role == ax::mojom::Role::kTreeItem;
976 return item_role == ax::mojom::Role::kMenuItem ||
977 item_role == ax::mojom::Role::kMenuItemRadio ||
980 return item_role == ax::mojom::Role::kMenuItem ||
981 item_role == ax::mojom::Role::kMenuItemRadio ||
984 return item_role == ax::mojom::Role::kTab;
986 return item_role == ax::mojom::Role::kTreeItem;
988 return item_role == ax::mojom::Role::kListBoxOption;
990 return item_role == ax::mojom::Role::kMenuListOption ||
991 item_role == ax::mojom::Role::kMenuItem ||
992 item_role == ax::mojom::Role::kMenuItemRadio ||
995 return item_role == ax::mojom::Role::kRadioButton;
997 // Only the term for each description list entry should receive posinset
998 // and setsize.
999 return item_role == ax::mojom::Role::kDescriptionListTerm ||
1000 item_role == ax::mojom::Role::kTerm;
1002 // kPopUpButtons can wrap a kMenuListPopUp.
1003 return item_role == ax::mojom::Role::kMenuListPopup;
1004 default:
1005 return false;
1006 }
1007}

◆ SwapChildren()

void ui::AXNode::SwapChildren ( std::vector< AXNode * > *  children)

Definition at line 399 of file ax_node.cc.

399 {
400 children->swap(children_);
401}

◆ TakeData()

AXNodeData && ui::AXNode::TakeData ( )

Definition at line 43 of file ax_node.cc.

43 {
44 return std::move(data_);
45}

◆ tree()

OwnerTree * ui::AXNode::tree ( ) const
inline

Definition at line 109 of file ax_node.h.

109{ return tree_; }

◆ UnignoredChildrenBegin()

AXNode::UnignoredChildIterator ui::AXNode::UnignoredChildrenBegin ( ) const

Definition at line 311 of file ax_node.cc.

311 {
314}
ChildIteratorBase< AXNode, &AXNode::GetNextUnignoredSibling, &AXNode::GetPreviousUnignoredSibling, &AXNode::GetFirstUnignoredChild, &AXNode::GetLastUnignoredChild > UnignoredChildIterator
Definition: ax_node.h:143

◆ UnignoredChildrenEnd()

AXNode::UnignoredChildIterator ui::AXNode::UnignoredChildrenEnd ( ) const

Definition at line 316 of file ax_node.cc.

316 {
318 return UnignoredChildIterator(this, nullptr);
319}

◆ UpdateUnignoredCachedValues()

void ui::AXNode::UpdateUnignoredCachedValues ( )

Definition at line 394 of file ax_node.cc.

394 {
395 if (!IsIgnored())
396 UpdateUnignoredCachedValuesRecursive(0);
397}

Member Data Documentation

◆ kInvalidAXID

constexpr AXNode::AXID ui::AXNode::kInvalidAXID = -1
staticconstexpr

Definition at line 41 of file ax_node.h.


The documentation for this class was generated from the following files: