Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ax_node_position.h
Go to the documentation of this file.
1// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_ACCESSIBILITY_AX_NODE_POSITION_H_
6#define UI_ACCESSIBILITY_AX_NODE_POSITION_H_
7
8#include <cstdint>
9#include <vector>
10
11#include "ax_enums.h"
12#include "ax_export.h"
13#include "ax_node.h"
14#include "ax_position.h"
15#include "ax_tree_id.h"
16
17namespace ui {
18
19// AXNodePosition includes implementations of AXPosition methods which require
20// knowledge of the AXPosition AXNodeType (which is unknown by AXPosition).
21class AX_EXPORT AXNodePosition : public AXPosition<AXNodePosition, AXNode> {
22 public:
23 // Creates either a text or a tree position, depending on the type of the node
24 // provided.
25 static AXPositionInstance CreatePosition(
26 const AXNode& node,
27 int child_index_or_text_offset,
29
31 ~AXNodePosition() override;
32 AXNodePosition(const AXNodePosition& other);
33
34 AXPositionInstance Clone() const override;
35
36 std::u16string GetText() const override;
37 bool IsInLineBreak() const override;
38 bool IsInTextObject() const override;
39 bool IsInWhiteSpace() const override;
40 int MaxTextOffset() const override;
41
42 protected:
43 void AnchorChild(int child_index,
44 AXTreeID* tree_id,
45 AXNode::AXID* child_id) const override;
46 int AnchorChildCount() const override;
47 int AnchorUnignoredChildCount() const override;
48 int AnchorIndexInParent() const override;
49 int AnchorSiblingCount() const override;
50 std::stack<AXNode*> GetAncestorAnchors() const override;
51 AXNode* GetLowestUnignoredAncestor() const override;
52 void AnchorParent(AXTreeID* tree_id, AXNode::AXID* parent_id) const override;
53 AXNode* GetNodeInTree(AXTreeID tree_id, AXNode::AXID node_id) const override;
54 AXNode::AXID GetAnchorID(AXNode* node) const override;
55 AXTreeID GetTreeID(AXNode* node) const override;
56
57 bool IsEmbeddedObjectInParent() const override;
58 bool IsInLineBreakingObject() const override;
59 ax::mojom::Role GetAnchorRole() const override;
60 ax::mojom::Role GetRole(AXNode* node) const override;
61 AXNodeTextStyles GetTextStyles() const override;
62 std::vector<int32_t> GetWordStartOffsets() const override;
63 std::vector<int32_t> GetWordEndOffsets() const override;
64 AXNode::AXID GetNextOnLineID(AXNode::AXID node_id) const override;
65 AXNode::AXID GetPreviousOnLineID(AXNode::AXID node_id) const override;
66
67 private:
68 // Returns the parent node of the provided child. Returns the parent
69 // node's tree id and node id through the provided output parameters,
70 // |parent_tree_id| and |parent_id|.
71 static AXNode* GetParent(AXNode* child,
72 AXTreeID child_tree_id,
73 AXTreeID* parent_tree_id,
74 AXNode::AXID* parent_id);
75};
76
77} // namespace ui
78
79#endif // UI_ACCESSIBILITY_AX_NODE_POSITION_H_
#define AX_EXPORT
Definition ax_export.h:29
~AXNodePosition() override
int32_t AXID
Definition ax_node.h:36
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > AXPositionInstance