Flutter Engine
The Flutter Engine
ax_tree_id.h
Go to the documentation of this file.
1// Copyright 2018 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_TREE_ID_H_
6#define UI_ACCESSIBILITY_AX_TREE_ID_H_
7
8#include <string>
9
10#include "ax_base_export.h"
11#include "ax_enums.h"
12#include "base/no_destructor.h"
13#include "base/simple_token.h"
14
15namespace ui {
16
17// A unique ID representing an accessibility tree.
19 public:
20 // Create an Unknown AXTreeID.
21 AXTreeID();
22
23 // Copy constructor.
24 AXTreeID(const AXTreeID& other);
25
26 // Create a new unique AXTreeID.
27 static AXTreeID CreateNewAXTreeID();
28
29 // Unserialize an AXTreeID from a string. This is used so that tree IDs
30 // can be stored compactly as a string attribute in an AXNodeData, and
31 // so that AXTreeIDs can be passed to JavaScript bindings in the
32 // automation API.
33 static AXTreeID FromString(const std::string& string);
34
35 // Convenience method to unserialize an AXTreeID from an SimpleToken.
36 static AXTreeID FromToken(const base::SimpleToken& token);
37
38 AXTreeID& operator=(const AXTreeID& other);
39
40 std::string ToString() const;
41
42 ax::mojom::AXTreeIDType type() const { return type_; }
43 const std::optional<base::SimpleToken>& token() const { return token_; }
44
45 bool operator==(const AXTreeID& rhs) const;
46 bool operator!=(const AXTreeID& rhs) const;
47 bool operator<(const AXTreeID& rhs) const;
48 bool operator<=(const AXTreeID& rhs) const;
49 bool operator>(const AXTreeID& rhs) const;
50 bool operator>=(const AXTreeID& rhs) const;
51
52 private:
54 explicit AXTreeID(const std::string& string);
55
56 friend class base::NoDestructor<AXTreeID>;
57 friend void swap(AXTreeID& first, AXTreeID& second);
58
60 std::optional<base::SimpleToken> token_ = std::nullopt;
61};
62
63// For use in std::unordered_map.
65 size_t operator()(const ui::AXTreeID& tree_id) const;
66};
67
68AX_BASE_EXPORT std::ostream& operator<<(std::ostream& stream,
69 const AXTreeID& value);
70
71// The value to use when an AXTreeID is unknown.
73
74} // namespace ui
75
76#endif // UI_ACCESSIBILITY_AX_TREE_ID_H_
#define AX_BASE_EXPORT
GLenum type
AXTreeID(const AXTreeID &other)
AXTreeID & operator=(const AXTreeID &other)
const std::optional< base::SimpleToken > & token() const
Definition: ax_tree_id.h:43
ax::mojom::AXTreeIDType type() const
Definition: ax_tree_id.h:42
uint8_t value
bool operator==(const AXEventIntent &a, const AXEventIntent &b)
bool operator>=(const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
Definition: ax_position.h:4015
const char * ToString(ax::mojom::Event event)
Definition: ax_enum_util.cc:9
const AXTreeID & AXTreeIDUnknown()
Definition: ax_tree_id.cc:103
void swap(AXPosition< AXPositionType, AXNodeType > &first, AXPosition< AXPositionType, AXNodeType > &second)
Definition: ax_position.h:4022
std::ostream & operator<<(std::ostream &os, AXEventGenerator::Event event)
bool operator!=(const AXEventIntent &a, const AXEventIntent &b)
bool operator<=(const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
Definition: ax_position.h:4001
bool operator>(const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
Definition: ax_position.h:4008
bool operator<(const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
Definition: ax_position.h:3994