File: ax_tree_data.h

package info (click to toggle)
chromium 141.0.7390.107-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,246,132 kB
  • sloc: cpp: 35,264,965; ansic: 7,169,920; javascript: 4,250,185; python: 1,460,635; asm: 950,788; xml: 751,751; pascal: 187,972; sh: 89,459; perl: 88,691; objc: 79,953; sql: 53,924; cs: 44,622; fortran: 24,137; makefile: 22,313; tcl: 15,277; php: 14,018; yacc: 8,995; ruby: 7,553; awk: 3,720; lisp: 3,096; lex: 1,330; ada: 727; jsp: 228; sed: 36
file content (93 lines) | stat: -rw-r--r-- 3,363 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_ACCESSIBILITY_AX_TREE_DATA_H_
#define UI_ACCESSIBILITY_AX_TREE_DATA_H_

#include <stdint.h>

#include <optional>
#include <string>
#include <vector>

#include "ui/accessibility/ax_base_export.h"
#include "ui/accessibility/ax_constants.mojom.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_id_forward.h"
#include "ui/accessibility/ax_tree_id.h"

namespace ui {

// The data associated with an accessibility tree that's global to the
// tree and not associated with any particular node in the tree.
struct AX_BASE_EXPORT AXTreeData final {
  AXTreeData();
  AXTreeData(const AXTreeData& other);
  AXTreeData(AXTreeData&& other) noexcept;
  AXTreeData& operator=(const AXTreeData& other);
  AXTreeData& operator=(AXTreeData&& other) noexcept;

  ~AXTreeData();

  // Return a string representation of this data, for debugging.
  std::string ToString() const;

  // This is a simple serializable struct. All member variables should be
  // public and copyable.

  // The globally unique ID of this accessibility tree.
  AXTreeID tree_id;

  // The ID of the accessibility tree that this tree is contained in, if any.
  AXTreeID parent_tree_id;

  // The ID of the accessibility tree that has focus. This is typically set
  // on the root frame in a frame tree.
  AXTreeID focused_tree_id;

  // Attributes specific to trees that are web frames.
  std::string doctype;
  bool loaded = false;
  float loading_progress = 0.0f;
  std::string mimetype;
  std::string title;
  std::string url;

  // The node with keyboard focus within this tree, if any, or
  // kInvalidAXNodeID if no node in this tree has focus.
  AXNodeID focus_id = kInvalidAXNodeID;

  // The current text selection within this tree, if any, expressed as the
  // node ID and character offset of the anchor (selection start) and focus
  // (selection end). If the offset could correspond to a position on two
  // different lines, sel_upstream_affinity means the cursor is on the first
  // line, otherwise it's on the second line.
  // Most use cases will want to use OwnerTree::GetUnignoredSelection.
  bool sel_is_backward = false;
  AXNodeID sel_anchor_object_id = kInvalidAXNodeID;
  // kNoSelectionOffset indicates there is no selection.
  int32_t sel_anchor_offset = ax::mojom::kNoSelectionOffset;
  ax::mojom::TextAffinity sel_anchor_affinity;
  AXNodeID sel_focus_object_id = kInvalidAXNodeID;
  int32_t sel_focus_offset = ax::mojom::kNoSelectionOffset;
  ax::mojom::TextAffinity sel_focus_affinity;

  // The node that's used as the root scroller. On some platforms
  // like Android we need to ignore accessibility scroll offsets for
  // that node and get them from the viewport instead.
  AXNodeID root_scroller_id = kInvalidAXNodeID;

  // Metadata from an HTML HEAD, such as <meta> tags. Stored here
  // unparsed because the only applications that need these just want
  // raw strings. Only included if the kHTMLMetadata AXMode is enabled.
  std::optional<std::vector<std::string>> metadata;
};

AX_BASE_EXPORT bool operator==(const AXTreeData& lhs, const AXTreeData& rhs);

AX_BASE_EXPORT const AXTreeData& AXTreeDataUnknown();

}  // namespace ui

#endif  // UI_ACCESSIBILITY_AX_TREE_DATA_H_