Flutter Engine
The Flutter Engine
ax_tree_data.cc
Go to the documentation of this file.
1// Copyright 2015 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#include "ax_tree_data.h"
6
7#include <set>
8
9#include "ax_enum_util.h"
10#include "ax_enums.h"
11#include "base/string_utils.h"
12
13namespace ui {
14
16 : sel_anchor_affinity(ax::mojom::TextAffinity::kDownstream),
17 sel_focus_affinity(ax::mojom::TextAffinity::kDownstream) {}
18
19AXTreeData::AXTreeData(const AXTreeData& other) = default;
20AXTreeData::~AXTreeData() = default;
21
22// Note that this includes an initial space character if nonempty, but
23// that works fine because this is normally printed by AXTree::ToString.
24std::string AXTreeData::ToString() const {
25 std::string result;
26
27 if (tree_id != AXTreeIDUnknown())
28 result += " tree_id=" + tree_id.ToString().substr(0, 8);
30 result += " parent_tree_id=" + parent_tree_id.ToString().substr(0, 8);
32 result += " focused_tree_id=" + focused_tree_id.ToString().substr(0, 8);
33
34 if (!doctype.empty())
35 result += " doctype=" + doctype;
36 if (loaded)
37 result += " loaded=true";
38 if (loading_progress != 0.0f)
39 result += " loading_progress=" + base::NumberToString(loading_progress);
40 if (!mimetype.empty())
41 result += " mimetype=" + mimetype;
42 if (!url.empty())
43 result += " url=" + url;
44 if (!title.empty())
45 result += " title=" + title;
46
48 result += " focus_id=" + base::NumberToString(focus_id);
49
51 result +=
52 (sel_is_backward ? " sel_is_backward=true" : " sel_is_backward=false");
53 result +=
54 " sel_anchor_object_id=" + base::NumberToString(sel_anchor_object_id);
55 result += " sel_anchor_offset=" + base::NumberToString(sel_anchor_offset);
56 result += " sel_anchor_affinity=";
58 }
60 result +=
61 " sel_focus_object_id=" + base::NumberToString(sel_focus_object_id);
62 result += " sel_focus_offset=" + base::NumberToString(sel_focus_offset);
63 result += " sel_focus_affinity=";
65 }
66
67 return result;
68}
69
70bool operator==(const AXTreeData& lhs, const AXTreeData& rhs) {
71 return (lhs.tree_id == rhs.tree_id &&
72 lhs.parent_tree_id == rhs.parent_tree_id &&
74 lhs.doctype == rhs.doctype && lhs.loaded == rhs.loaded &&
76 lhs.mimetype == rhs.mimetype && lhs.title == rhs.title &&
77 lhs.url == rhs.url && lhs.focus_id == rhs.focus_id &&
84}
85
86bool operator!=(const AXTreeData& lhs, const AXTreeData& rhs) {
87 return !(lhs == rhs);
88}
89
90} // namespace ui
static constexpr AXID kInvalidAXID
Definition: ax_node.h:41
std::string ToString() const
Definition: ax_tree_id.cc:53
GAsyncResult * result
std::string NumberToString(int32_t number)
Definition: string_utils.cc:91
bool operator==(const AXEventIntent &a, const AXEventIntent &b)
const char * ToString(ax::mojom::Event event)
Definition: ax_enum_util.cc:9
const AXTreeID & AXTreeIDUnknown()
Definition: ax_tree_id.cc:103
bool operator!=(const AXEventIntent &a, const AXEventIntent &b)
virtual std::string ToString() const
Definition: ax_tree_data.cc:24
std::string url
Definition: ax_tree_data.h:49
bool sel_is_backward
Definition: ax_tree_data.h:61
AXNode::AXID sel_anchor_object_id
Definition: ax_tree_data.h:62
AXTreeID focused_tree_id
Definition: ax_tree_data.h:41
ax::mojom::TextAffinity sel_focus_affinity
Definition: ax_tree_data.h:67
AXNode::AXID sel_focus_object_id
Definition: ax_tree_data.h:65
std::string mimetype
Definition: ax_tree_data.h:47
std::string doctype
Definition: ax_tree_data.h:44
AXNode::AXID focus_id
Definition: ax_tree_data.h:53
int32_t sel_focus_offset
Definition: ax_tree_data.h:66
ax::mojom::TextAffinity sel_anchor_affinity
Definition: ax_tree_data.h:64
AXTreeID parent_tree_id
Definition: ax_tree_data.h:37
std::string title
Definition: ax_tree_data.h:48
AXTreeID tree_id
Definition: ax_tree_data.h:34
float loading_progress
Definition: ax_tree_data.h:46
virtual ~AXTreeData()
int32_t sel_anchor_offset
Definition: ax_tree_data.h:63