Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ui::AXNodePosition Class Reference

#include <ax_node_position.h>

Inheritance diagram for ui::AXNodePosition:
ui::AXPosition< AXNodePosition, AXNode >

Public Member Functions

 AXNodePosition ()
 
 ~AXNodePosition () override
 
 AXNodePosition (const AXNodePosition &other)
 
AXPositionInstance Clone () const override
 
std::u16string GetText () const override
 
bool IsInLineBreak () const override
 
bool IsInTextObject () const override
 
bool IsInWhiteSpace () const override
 
int MaxTextOffset () const override
 
- Public Member Functions inherited from ui::AXPosition< AXNodePosition, AXNode >
virtual ~AXPosition ()=default
 
AXPositionoperator= (const AXPosition &other)
 
virtual AXPositionInstance Clone () const=0
 
SerializedPosition Serialize ()
 
std::string ToString () const
 
AXTreeID tree_id () const
 
AXNode::AXID anchor_id () const
 
AXNodeGetAnchor () const
 
AXPositionKind kind () const
 
int child_index () const
 
int text_offset () const
 
ax::mojom::TextAffinity affinity () const
 
bool IsIgnored () const
 
bool IsNullPosition () const
 
bool IsTreePosition () const
 
bool IsLeafTreePosition () const
 
bool IsTextPosition () const
 
bool IsLeafTextPosition () const
 
bool IsLeaf () const
 
bool IsValid () const
 
bool AtStartOfAnchor () const
 
bool AtEndOfAnchor () const
 
bool AtStartOfWord () const
 
bool AtEndOfWord () const
 
bool AtStartOfLine () const
 
bool AtEndOfLine () const
 
bool AtStartOfParagraph () const
 
bool AtEndOfParagraph () const
 
bool AtStartOfPage () const
 
bool AtEndOfPage () const
 
bool AtStartOfAXTree () const
 
bool AtEndOfAXTree () const
 
AXBoundaryType GetFormatStartBoundaryType () const
 
bool AtStartOfFormat () const
 
AXBoundaryType GetFormatEndBoundaryType () const
 
bool AtEndOfFormat () const
 
bool AtStartOfInlineBlock () const
 
bool AtStartOfDocument () const
 
bool AtEndOfDocument () const
 
bool AtLastNodeInTree () const
 
AXNodeLowestCommonAnchor (const AXPosition &second) const
 
AXPositionInstance LowestCommonAncestor (const AXPosition &second) const
 
AXPositionInstance CreateAncestorPosition (const AXNode *ancestor_anchor, ax::mojom::MoveDirection move_direction=ax::mojom::MoveDirection::kForward) const
 
AXPositionInstance AsValidPosition () const
 
AXPositionInstance AsTreePosition () const
 
AXPositionInstance AsLeafTreePosition () const
 
AXPositionInstance AsTextPosition () const
 
AXPositionInstance AsLeafTextPosition () const
 
AXPositionInstance AsUnignoredPosition (AXPositionAdjustmentBehavior adjustment_behavior) const
 
AXRangeType ExpandToEnclosingTextBoundary (ax::mojom::TextBoundary boundary, AXRangeExpandBehavior expand_behavior) const
 
AXPositionInstance CreatePositionAtTextBoundary (ax::mojom::TextBoundary boundary, ax::mojom::MoveDirection direction, AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePositionAtStartOfAnchor () const
 
AXPositionInstance CreatePositionAtEndOfAnchor () const
 
AXPositionInstance CreatePositionAtStartOfAXTree () const
 
AXPositionInstance CreatePositionAtEndOfAXTree () const
 
AXPositionInstance CreatePositionAtStartOfDocument () const
 
AXPositionInstance CreatePositionAtEndOfDocument () const
 
AXPositionInstance CreateChildPositionAt (int child_index) const
 
AXPositionInstance CreateParentPosition (ax::mojom::MoveDirection move_direction=ax::mojom::MoveDirection::kForward) const
 
AXPositionInstance CreateNextLeafTreePosition () const
 
AXPositionInstance CreatePreviousLeafTreePosition () const
 
AXPositionInstance CreateNextLeafTextPosition (bool *crossed_line_breaking_object=nullptr) const
 
AXPositionInstance CreatePreviousLeafTextPosition () const
 
AXPositionInstance AsLeafTextPositionBeforeCharacter () const
 
AXPositionInstance AsLeafTextPositionAfterCharacter () const
 
AXPositionInstance CreateNextCharacterPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousCharacterPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextWordStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousWordStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextWordEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousWordEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextLineStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousLineStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextLineEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousLineEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousFormatStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextFormatEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextParagraphStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousParagraphStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextParagraphEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousParagraphEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextPageStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousPageStartPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateNextPageEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreatePreviousPageEndPosition (AXBoundaryBehavior boundary_behavior) const
 
AXPositionInstance CreateBoundaryStartPosition (AXBoundaryBehavior boundary_behavior, ax::mojom::MoveDirection move_direction, BoundaryConditionPredicate at_start_condition, BoundaryConditionPredicate at_end_condition, BoundaryTextOffsetsFunc get_start_offsets={}) const
 
AXPositionInstance CreateBoundaryEndPosition (AXBoundaryBehavior boundary_behavior, ax::mojom::MoveDirection move_direction, BoundaryConditionPredicate at_start_condition, BoundaryConditionPredicate at_end_condition, BoundaryTextOffsetsFunc get_end_offsets={}) const
 
AXPositionInstance CreateNextAnchorPosition () const
 
AXPositionInstance CreatePreviousAnchorPosition () const
 
std::optional< intCompareTo (const AXPosition &other) const
 
std::optional< intSlowCompareTo (const AXPosition &other) const
 
void SnapToMaxTextOffsetIfBeyond ()
 
bool IsEmptyObjectReplacedByCharacter () const
 
bool IsInDescendantOfEmptyObject () const
 
AXNodeGetEmptyObjectAncestorNode () const
 
void swap (AXPosition &other)
 
virtual std::u16string GetText () const=0
 
virtual bool IsInLineBreak () const=0
 
virtual bool IsInTextObject () const=0
 
virtual bool IsInWhiteSpace () const=0
 
virtual int MaxTextOffset () const
 

Static Public Member Functions

static AXPositionInstance CreatePosition (const AXNode &node, int child_index_or_text_offset, ax::mojom::TextAffinity affinity=ax::mojom::TextAffinity::kDownstream)
 
- Static Public Member Functions inherited from ui::AXPosition< AXNodePosition, AXNode >
static AXPositionInstance CreateNullPosition ()
 
static AXPositionInstance CreateTreePosition (AXTreeID tree_id, AXNode::AXID anchor_id, int child_index)
 
static AXPositionInstance CreateTextPosition (AXTreeID tree_id, AXNode::AXID anchor_id, int text_offset, ax::mojom::TextAffinity affinity)
 
static AXPositionInstance Unserialize (const SerializedPosition &serialization)
 

Protected Member Functions

void AnchorChild (int child_index, AXTreeID *tree_id, AXNode::AXID *child_id) const override
 
int AnchorChildCount () const override
 
int AnchorUnignoredChildCount () const override
 
int AnchorIndexInParent () const override
 
int AnchorSiblingCount () const override
 
std::stack< AXNode * > GetAncestorAnchors () const override
 
AXNodeGetLowestUnignoredAncestor () const override
 
void AnchorParent (AXTreeID *tree_id, AXNode::AXID *parent_id) const override
 
AXNodeGetNodeInTree (AXTreeID tree_id, AXNode::AXID node_id) const override
 
AXNode::AXID GetAnchorID (AXNode *node) const override
 
AXTreeID GetTreeID (AXNode *node) const override
 
bool IsEmbeddedObjectInParent () const override
 
bool IsInLineBreakingObject () const override
 
ax::mojom::Role GetAnchorRole () const override
 
ax::mojom::Role GetRole (AXNode *node) const override
 
AXNodeTextStyles GetTextStyles () const override
 
std::vector< int32_t > GetWordStartOffsets () const override
 
std::vector< int32_t > GetWordEndOffsets () const override
 
AXNode::AXID GetNextOnLineID (AXNode::AXID node_id) const override
 
AXNode::AXID GetPreviousOnLineID (AXNode::AXID node_id) const override
 
- Protected Member Functions inherited from ui::AXPosition< AXNodePosition, AXNode >
 AXPosition ()
 
 AXPosition (const AXPosition &other)
 
int AnchorTextOffsetInParent () const
 
void Initialize (AXPositionKind kind, AXTreeID tree_id, int32_t anchor_id, int child_index, int text_offset, ax::mojom::TextAffinity affinity)
 
virtual void AnchorChild (int child_index, AXTreeID *tree_id, int32_t *child_id) const=0
 
virtual int AnchorChildCount () const=0
 
virtual int AnchorUnignoredChildCount () const=0
 
virtual int AnchorIndexInParent () const=0
 
virtual int AnchorSiblingCount () const=0
 
virtual std::stack< AXNode * > GetAncestorAnchors () const=0
 
virtual AXNodeGetLowestUnignoredAncestor () const=0
 
virtual void AnchorParent (AXTreeID *tree_id, int32_t *parent_id) const=0
 
virtual AXNodeGetNodeInTree (AXTreeID tree_id, int32_t node_id) const=0
 
virtual int32_t GetAnchorID (AXNode *node) const=0
 
virtual AXTreeID GetTreeID (AXNode *node) const=0
 
int MaxTextOffsetInParent () const
 
virtual bool IsEmbeddedObjectInParent () const=0
 
virtual bool IsInLineBreakingObject () const=0
 
virtual ax::mojom::Role GetAnchorRole () const=0
 
virtual ax::mojom::Role GetRole (AXNode *node) const=0
 
virtual AXNodeTextStyles GetTextStyles () const=0
 
virtual std::vector< int32_t > GetWordStartOffsets () const=0
 
virtual std::vector< int32_t > GetWordEndOffsets () const=0
 
virtual int32_t GetNextOnLineID (int32_t node_id) const=0
 
virtual int32_t GetPreviousOnLineID (int32_t node_id) const=0
 

Additional Inherited Members

- Public Types inherited from ui::AXPosition< AXNodePosition, AXNode >
using AXPositionInstance = std::unique_ptr< AXPosition< AXNodePosition, AXNode > >
 
using AXRangeType = AXRange< AXPosition< AXNodePosition, AXNode > >
 
typedef bool BoundaryConditionPredicate(const AXPositionInstance &)
 
typedef std::vector< int32_t > BoundaryTextOffsetsFunc(const AXPositionInstance &)
 
- Static Public Attributes inherited from ui::AXPosition< AXNodePosition, AXNode >
static const int BEFORE_TEXT
 
static const int INVALID_INDEX
 
static const int INVALID_OFFSET
 
static constexpr char16_t kEmbeddedCharacter
 

Detailed Description

Definition at line 21 of file ax_node_position.h.

Constructor & Destructor Documentation

◆ AXNodePosition() [1/2]

ui::AXNodePosition::AXNodePosition ( )
default

◆ ~AXNodePosition()

ui::AXNodePosition::~AXNodePosition ( )
overridedefault

◆ AXNodePosition() [2/2]

ui::AXNodePosition::AXNodePosition ( const AXNodePosition other)

Definition at line 54 of file ax_node_position.cc.

55 : AXPosition<AXNodePosition, AXNode>(other) {}

Member Function Documentation

◆ AnchorChild()

void ui::AXNodePosition::AnchorChild ( int  child_index,
AXTreeID tree_id,
AXNode::AXID child_id 
) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 61 of file ax_node_position.cc.

63 {
65 BASE_DCHECK(child_id);
66
67 if (!GetAnchor() || child_index < 0 || child_index >= AnchorChildCount()) {
69 *child_id = AXNode::kInvalidAXID;
70 return;
71 }
72
73 AXNode* child = nullptr;
74 const AXTreeManager* child_tree_manager =
76 if (child_tree_manager) {
77 // The child node exists in a separate tree from its parent.
78 child = child_tree_manager->GetRootAsAXNode();
79 *tree_id = child_tree_manager->GetTreeID();
80 } else {
81 child = GetAnchor()->children()[static_cast<size_t>(child_index)];
82 *tree_id = this->tree_id();
83 }
84
85 BASE_DCHECK(child);
86 *child_id = child->id();
87}
int AnchorChildCount() const override
static constexpr AXID kInvalidAXID
Definition: ax_node.h:41
const std::vector< AXNode * > & children() const
Definition: ax_node.h:113
AXTreeManager * GetManagerForChildTree(const AXNode &parent_node)
static AXTreeManagerMap & GetInstance()
virtual AXNode * GetRootAsAXNode() const =0
const AXTreeID & AXTreeIDUnknown()
Definition: ax_tree_id.cc:103
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ AnchorChildCount()

int ui::AXNodePosition::AnchorChildCount ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 89 of file ax_node_position.cc.

89 {
90 if (!GetAnchor())
91 return 0;
92
93 const AXTreeManager* child_tree_manager =
95 if (child_tree_manager)
96 return 1;
97
98 return static_cast<int>(GetAnchor()->children().size());
99}

◆ AnchorIndexInParent()

int ui::AXNodePosition::AnchorIndexInParent ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 108 of file ax_node_position.cc.

108 {
109 return GetAnchor() ? static_cast<int>(GetAnchor()->index_in_parent())
111}
size_t index_in_parent() const
Definition: ax_node.h:114

◆ AnchorParent()

void ui::AXNodePosition::AnchorParent ( AXTreeID tree_id,
AXNode::AXID parent_id 
) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 150 of file ax_node_position.cc.

151 {
153 BASE_DCHECK(parent_id);
154
156 *parent_id = AXNode::kInvalidAXID;
157
158 if (!GetAnchor())
159 return;
160
161 AXNode* parent =
162 GetParent(GetAnchor() /*child*/, this->tree_id() /*child_tree_id*/,
163 tree_id /*parent_tree_id*/, parent_id /*parent_id*/);
164
165 if (!parent) {
167 *parent_id = AXNode::kInvalidAXID;
168 }
169}

◆ AnchorSiblingCount()

int ui::AXNodePosition::AnchorSiblingCount ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 113 of file ax_node_position.cc.

113 {
114 AXNode* parent = GetAnchor()->GetUnignoredParent();
115 if (parent)
116 return static_cast<int>(parent->GetUnignoredChildCount());
117
118 return 0;
119}
AXNode * GetUnignoredParent() const
Definition: ax_node.cc:58

◆ AnchorUnignoredChildCount()

int ui::AXNodePosition::AnchorUnignoredChildCount ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 101 of file ax_node_position.cc.

101 {
102 if (!GetAnchor())
103 return 0;
104
105 return static_cast<int>(GetAnchor()->GetUnignoredChildCount());
106}
size_t GetUnignoredChildCount() const
Definition: ax_node.cc:37

◆ Clone()

AXNodePosition::AXPositionInstance ui::AXNodePosition::Clone ( ) const
overridevirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 57 of file ax_node_position.cc.

57 {
58 return AXPositionInstance(new AXNodePosition(*this));
59}
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > AXPositionInstance
Definition: ax_position.h:163

◆ CreatePosition()

AXNodePosition::AXPositionInstance ui::AXNodePosition::CreatePosition ( const AXNode node,
int  child_index_or_text_offset,
ax::mojom::TextAffinity  affinity = ax::mojom::TextAffinity::kDownstream 
)
static

Definition at line 34 of file ax_node_position.cc.

37 {
38 if (!node.tree())
39 return CreateNullPosition();
40
41 AXTreeID tree_id = node.tree()->GetAXTreeID();
42 if (node.IsText()) {
43 return CreateTextPosition(tree_id, node.id(), child_index_or_text_offset,
44 affinity);
45 }
46
47 return CreateTreePosition(tree_id, node.id(), child_index_or_text_offset);
48}
static AXPositionInstance CreateNullPosition()
Definition: ax_position.h:183
static AXPositionInstance CreateTreePosition(AXTreeID tree_id, AXNode::AXID anchor_id, int child_index)
Definition: ax_position.h:191
ax::mojom::TextAffinity affinity() const
Definition: ax_position.h:328
static AXPositionInstance CreateTextPosition(AXTreeID tree_id, AXNode::AXID anchor_id, int text_offset, ax::mojom::TextAffinity affinity)
Definition: ax_position.h:201

◆ GetAncestorAnchors()

std::stack< AXNode * > ui::AXNodePosition::GetAncestorAnchors ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 121 of file ax_node_position.cc.

121 {
122 std::stack<AXNode*> anchors;
123 AXNode* current_anchor = GetAnchor();
124
125 AXNode::AXID current_anchor_id = GetAnchor()->id();
126 AXTreeID current_tree_id = tree_id();
127
128 AXNode::AXID parent_anchor_id = AXNode::kInvalidAXID;
129 AXTreeID parent_tree_id = AXTreeIDUnknown();
130
131 while (current_anchor) {
132 anchors.push(current_anchor);
133 current_anchor = GetParent(
134 current_anchor /*child*/, current_tree_id /*child_tree_id*/,
135 &parent_tree_id /*parent_tree_id*/, &parent_anchor_id /*parent_id*/);
136
137 current_anchor_id = parent_anchor_id;
138 current_tree_id = parent_tree_id;
139 }
140 return anchors;
141}
AXID id() const
Definition: ax_node.h:110
int32_t AXID
Definition: ax_node.h:36

◆ GetAnchorID()

AXNode::AXID ui::AXNodePosition::GetAnchorID ( AXNode node) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 182 of file ax_node_position.cc.

182 {
183 return node->id();
184}

◆ GetAnchorRole()

ax::mojom::Role ui::AXNodePosition::GetAnchorRole ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 307 of file ax_node_position.cc.

307 {
308 if (IsNullPosition())
311 return GetRole(GetAnchor());
312}
ax::mojom::Role GetRole(AXNode *node) const override

◆ GetLowestUnignoredAncestor()

AXNode * ui::AXNodePosition::GetLowestUnignoredAncestor ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 143 of file ax_node_position.cc.

143 {
144 if (!GetAnchor())
145 return nullptr;
146
147 return GetAnchor()->GetUnignoredParent();
148}

◆ GetNextOnLineID()

AXNode::AXID ui::AXNodePosition::GetNextOnLineID ( AXNode::AXID  node_id) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 363 of file ax_node_position.cc.

363 {
364 if (IsNullPosition())
366 AXNode* node = GetNodeInTree(tree_id(), node_id);
367 int next_on_line_id;
368 if (!node || !node->data().GetIntAttribute(
369 ax::mojom::IntAttribute::kNextOnLineId, &next_on_line_id)) {
371 }
372 return static_cast<AXNode::AXID>(next_on_line_id);
373}
AXNode * GetNodeInTree(AXTreeID tree_id, AXNode::AXID node_id) const override

◆ GetNodeInTree()

AXNode * ui::AXNodePosition::GetNodeInTree ( AXTreeID  tree_id,
AXNode::AXID  node_id 
) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 171 of file ax_node_position.cc.

172 {
173 if (node_id == AXNode::kInvalidAXID)
174 return nullptr;
175
177 if (manager)
178 return manager->GetNodeFromTree(tree_id, node_id);
179 return nullptr;
180}
AXTreeManager * GetManager(AXTreeID tree_id)
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

◆ GetPreviousOnLineID()

AXNode::AXID ui::AXNodePosition::GetPreviousOnLineID ( AXNode::AXID  node_id) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 375 of file ax_node_position.cc.

375 {
376 if (IsNullPosition())
378 AXNode* node = GetNodeInTree(tree_id(), node_id);
379 int previous_on_line_id;
380 if (!node ||
381 !node->data().GetIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
382 &previous_on_line_id)) {
384 }
385 return static_cast<AXNode::AXID>(previous_on_line_id);
386}

◆ GetRole()

ax::mojom::Role ui::AXNodePosition::GetRole ( AXNode node) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 314 of file ax_node_position.cc.

314 {
315 return node->data().role;
316}

◆ GetText()

std::u16string ui::AXNodePosition::GetText ( ) const
overridevirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 190 of file ax_node_position.cc.

190 {
191 if (IsNullPosition())
192 return {};
193
194 std::u16string text;
197 return text;
198 }
199
200 const AXNode* anchor = GetAnchor();
201 BASE_DCHECK(anchor);
202 // TODO(nektar): Replace with PlatformChildCount when AXNodePosition and
203 // BrowserAccessibilityPosition are merged into one class.
204 if (!AnchorChildCount()) {
205 // Special case: Allows us to get text even in non-web content, e.g. in the
206 // browser's UI.
207 text =
208 anchor->data().GetString16Attribute(ax::mojom::StringAttribute::kValue);
209 if (!text.empty())
210 return text;
211 }
212
213 if (anchor->IsText()) {
214 return anchor->data().GetString16Attribute(
216 }
217
218 for (int i = 0; i < AnchorChildCount(); ++i) {
219 text += CreateChildPositionAt(i)->GetText();
220 }
221
222 return text;
223}
static constexpr char16_t kEmbeddedCharacter
Definition: ax_position.h:181
AXPositionInstance CreateChildPositionAt(int child_index) const
Definition: ax_position.h:1820
std::u16string text

◆ GetTextStyles()

AXNodeTextStyles ui::AXNodePosition::GetTextStyles ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 318 of file ax_node_position.cc.

318 {
319 // Check either the current anchor or its parent for text styles.
320 AXNodeTextStyles current_anchor_text_styles =
322 : AXNodeTextStyles();
323 if (current_anchor_text_styles.IsUnset()) {
325 if (!parent->IsNullPosition())
326 return parent->GetAnchor()->data().GetTextStyles();
327 }
328 return current_anchor_text_styles;
329}
const AXNodeData & data() const
Definition: ax_node.h:112
AXPositionInstance CreateParentPosition(ax::mojom::MoveDirection move_direction=ax::mojom::MoveDirection::kForward) const
Definition: ax_position.h:1874
AXNodeTextStyles GetTextStyles() const

◆ GetTreeID()

AXTreeID ui::AXNodePosition::GetTreeID ( AXNode node) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 186 of file ax_node_position.cc.

186 {
187 return node->tree()->GetAXTreeID();
188}

◆ GetWordEndOffsets()

std::vector< int32_t > ui::AXNodePosition::GetWordEndOffsets ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 345 of file ax_node_position.cc.

345 {
346 if (IsNullPosition())
347 return std::vector<int32_t>();
349
350 // Embedded object replacement characters are not represented in |kWordEnds|
351 // attribute. Since the whole text exposed inside of an embedded object is of
352 // length 1 (the embedded object replacement character), the word end offset
353 // is positioned at 1. Because we want to treat the embedded object
354 // replacement characters as ordinary characters, it wouldn't be consistent to
355 // assume they have no length and return 0 instead of 1.
357 return {1};
358
361}
const std::vector< int32_t > & GetIntListAttribute(ax::mojom::IntListAttribute attribute) const

◆ GetWordStartOffsets()

std::vector< int32_t > ui::AXNodePosition::GetWordStartOffsets ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 331 of file ax_node_position.cc.

331 {
332 if (IsNullPosition())
333 return std::vector<int32_t>();
335
336 // Embedded object replacement characters are not represented in |kWordStarts|
337 // attribute.
339 return {0};
340
343}

◆ IsEmbeddedObjectInParent()

bool ui::AXNodePosition::IsEmbeddedObjectInParent ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 284 of file ax_node_position.cc.

284 {
287 return false;
289 // We don't need to expose an "embedded object character" for textual
290 // nodes and nodes that are invisible to platform APIs. Textual nodes are
291 // represented by their actual text.
292 return !IsNullPosition() && !GetAnchor()->IsText() &&
294 }
295}
bool IsText() const
Definition: ax_node.cc:356
bool IsChildOfLeaf() const
Definition: ax_node.cc:1078
AXEmbeddedObjectBehavior g_ax_embedded_object_behavior

◆ IsInLineBreak()

bool ui::AXNodePosition::IsInLineBreak ( ) const
overridevirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 225 of file ax_node_position.cc.

225 {
226 if (IsNullPosition())
227 return false;
229 return GetAnchor()->IsLineBreak();
230}
bool IsLineBreak() const
Definition: ax_node.cc:366

◆ IsInLineBreakingObject()

bool ui::AXNodePosition::IsInLineBreakingObject ( ) const
overrideprotectedvirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 297 of file ax_node_position.cc.

297 {
298 if (IsNullPosition())
299 return false;
301 return (GetAnchor()->data().GetBoolAttribute(
303 !GetAnchor()->IsInListMarker()) ||
305}
ax::mojom::Role role
Definition: ax_node_data.h:277
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ IsInTextObject()

bool ui::AXNodePosition::IsInTextObject ( ) const
overridevirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 232 of file ax_node_position.cc.

232 {
233 if (IsNullPosition())
234 return false;
236 return GetAnchor()->IsText();
237}

◆ IsInWhiteSpace()

bool ui::AXNodePosition::IsInWhiteSpace ( ) const
overridevirtual

Implements ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 239 of file ax_node_position.cc.

239 {
240 if (IsNullPosition())
241 return false;
243 return GetAnchor()->IsLineBreak() ||
245}
std::u16string GetText() const override
constexpr char16_t kWhitespaceUTF16
Definition: string_utils.h:14
bool ContainsOnlyChars(std::u16string str, char16_t ch)

◆ MaxTextOffset()

int ui::AXNodePosition::MaxTextOffset ( ) const
overridevirtual

Reimplemented from ui::AXPosition< AXNodePosition, AXNode >.

Definition at line 252 of file ax_node_position.cc.

252 {
253 if (IsNullPosition())
254 return INVALID_OFFSET;
255
257 return 1;
258
259 const AXNode* anchor = GetAnchor();
260 BASE_DCHECK(anchor);
261 // TODO(nektar): Replace with PlatformChildCount when AXNodePosition and
262 // BrowserAccessibilityPosition will make one.
263 if (!AnchorChildCount()) {
264 std::u16string value =
265 anchor->data().GetString16Attribute(ax::mojom::StringAttribute::kValue);
266 if (!value.empty())
267 return value.length();
268 }
269
270 if (anchor->IsText()) {
271 return anchor->data()
272 .GetString16Attribute(ax::mojom::StringAttribute::kName)
273 .length();
274 }
275
276 int text_length = 0;
277 for (int i = 0; i < AnchorChildCount(); ++i) {
278 text_length += CreateChildPositionAt(i)->MaxTextOffset();
279 }
280
281 return text_length;
282}
uint8_t value

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