Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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_
bool operator!=(const sk_sp< T > &a, const sk_sp< U > &b)
Definition SkRefCnt.h:355
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition SkRefCnt.h:341
#define AX_BASE_EXPORT
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
static bool operator<(const SkPlainTextEditor::Editor::TextPosition &u, const SkPlainTextEditor::Editor::TextPosition &v)
Definition editor.h:140
bool operator==(const FlutterPoint &a, const FlutterPoint &b)
const char * ToString(ax::mojom::Event event)
const AXTreeID & AXTreeIDUnknown()
std::ostream & operator<<(std::ostream &os, AXEventGenerator::Event event)