File: ax_tree_source_views.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (79 lines) | stat: -rw-r--r-- 2,828 bytes parent folder | download | duplicates (7)
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
// Copyright 2018 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_VIEWS_ACCESSIBILITY_AX_TREE_SOURCE_VIEWS_H_
#define UI_VIEWS_ACCESSIBILITY_AX_TREE_SOURCE_VIEWS_H_

#include <string>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "ui/accessibility/ax_tree_id.h"
#include "ui/accessibility/ax_tree_source.h"
#include "ui/views/views_export.h"

namespace ui {
struct AXActionData;
struct AXNodeData;
struct AXTreeData;
}  // namespace ui

namespace views {

class AXAuraObjCache;
class AXAuraObjWrapper;

// This class exposes the views hierarchy as an accessibility tree permitting
// use with other accessibility classes. The root can be an existing object in
// the Widget/View hierarchy or a new node (for example to create the "desktop"
// node for the extension API call chrome.automation.getDesktop()).
class VIEWS_EXPORT AXTreeSourceViews
    : public ui::
          AXTreeSource<AXAuraObjWrapper*, ui::AXTreeData*, ui::AXNodeData> {
 public:
  AXTreeSourceViews(ui::AXNodeID root_id,
                    const ui::AXTreeID& tree_id,
                    AXAuraObjCache* cache);
  AXTreeSourceViews(const AXTreeSourceViews&) = delete;
  AXTreeSourceViews& operator=(const AXTreeSourceViews&) = delete;
  ~AXTreeSourceViews() override;

  // Invokes an action on an Aura object.
  void HandleAccessibleAction(const ui::AXActionData& action);

  // AXTreeSource:
  bool GetTreeData(ui::AXTreeData* data) const override;
  AXAuraObjWrapper* GetRoot() const override;
  AXAuraObjWrapper* GetFromId(int32_t id) const override;
  int32_t GetId(AXAuraObjWrapper* node) const override;
  void CacheChildrenIfNeeded(AXAuraObjWrapper*) override;
  size_t GetChildCount(AXAuraObjWrapper* node) const override;
  void ClearChildCache(AXAuraObjWrapper*) override;
  AXAuraObjWrapper* ChildAt(AXAuraObjWrapper* node, size_t) const override;
  AXAuraObjWrapper* GetParent(AXAuraObjWrapper* node) const override;
  bool IsIgnored(AXAuraObjWrapper* node) const override;
  bool IsEqual(AXAuraObjWrapper* node1, AXAuraObjWrapper* node2) const override;
  AXAuraObjWrapper* GetNull() const override;
  std::string GetDebugString(AXAuraObjWrapper* node) const override;
  void SerializeNode(AXAuraObjWrapper* node,
                     ui::AXNodeData* out_data) const override;

  // Useful for debugging.
  std::string ToString(views::AXAuraObjWrapper* root, std::string prefix);

  const ui::AXTreeID tree_id() const { return tree_id_; }

 private:
  // The ID of the top-level object to use for the AX tree.
  const ui::AXNodeID root_id_;

  // ID to use for the AX tree.
  const ui::AXTreeID tree_id_;

  const raw_ptr<views::AXAuraObjCache> cache_;
};

}  // namespace views

#endif  // UI_VIEWS_ACCESSIBILITY_AX_TREE_SOURCE_VIEWS_H_