File: ax_tree_formatter_uia_win.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 (119 lines) | stat: -rw-r--r-- 5,107 bytes parent folder | download | duplicates (8)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2019 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_PLATFORM_INSPECT_AX_TREE_FORMATTER_UIA_WIN_H_
#define UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_TREE_FORMATTER_UIA_WIN_H_

#include <ole2.h>

#include <stdint.h>
#include <wrl/client.h>

#include <map>
#include <string>
#include <vector>

#include "base/component_export.h"
#include "base/win/scoped_variant.h"
#include "ui/accessibility/platform/inspect/ax_tree_formatter_base.h"

#include <uiautomation.h>

namespace ui {

class COMPONENT_EXPORT(AX_PLATFORM) AXTreeFormatterUia
    : public AXTreeFormatterBase {
 public:
  AXTreeFormatterUia();
  ~AXTreeFormatterUia() override;

  // AccessibilityTreeFormatterBase:
  base::Value::Dict BuildTree(AXPlatformNodeDelegate* start) const override;
  base::Value::Dict BuildTreeForSelector(
      const AXTreeSelector& selector) const override;
  base::Value::Dict BuildNode(AXPlatformNodeDelegate* node) const override;

 protected:
  void AddDefaultFilters(
      std::vector<AXPropertyFilter>* property_filters) override;

 private:
  static const long properties_[];
  static const long patterns_[];
  static const long pattern_properties_[];
  void RecursiveBuildTree(IUIAutomationElement* node,
                          int root_x,
                          int root_y,
                          base::Value::Dict* dict) const;
  void BuildCacheRequests();
  void BuildCustomPropertiesMap();
  void AddProperties(IUIAutomationElement* node,
                     int root_x,
                     int root_y,
                     base::Value::Dict* dict) const;
  void AddAnnotationProperties(IUIAutomationElement* node,
                               base::Value::Dict* dict) const;
  void AddExpandCollapseProperties(IUIAutomationElement* node,
                                   base::Value::Dict* dict) const;
  void AddGridProperties(IUIAutomationElement* node,
                         base::Value::Dict* dict) const;
  void AddGridItemProperties(IUIAutomationElement* node,
                             base::Value::Dict* dict) const;
  void AddRangeValueProperties(IUIAutomationElement* node,
                               base::Value::Dict* dict) const;
  void AddScrollProperties(IUIAutomationElement* node,
                           base::Value::Dict* dict) const;
  void AddSelectionProperties(IUIAutomationElement* node,
                              base::Value::Dict* dict) const;
  void AddSelectionItemProperties(IUIAutomationElement* node,
                                  base::Value::Dict* dict) const;
  void AddTableProperties(IUIAutomationElement* node,
                          base::Value::Dict* dict) const;
  void AddToggleProperties(IUIAutomationElement* node,
                           base::Value::Dict* dict) const;
  void AddValueProperties(IUIAutomationElement* node,
                          base::Value::Dict* dict) const;
  void AddWindowProperties(IUIAutomationElement* node,
                           base::Value::Dict* dict) const;
  void AddCustomProperties(IUIAutomationElement* node,
                           base::Value::Dict* dict) const;
  std::string GetPropertyName(long property_id) const;
  void WriteProperty(long propertyId,
                     const base::win::ScopedVariant& var,
                     base::Value::Dict* dict,
                     int root_x = 0,
                     int root_y = 0) const;
  // UIA enums have type I4, print formatted string for these when possible
  void WriteI4Property(long propertyId,
                       long lval,
                       base::Value::Dict* dict) const;
  void WriteUnknownProperty(long propertyId,
                            IUnknown* unk,
                            base::Value::Dict* dict) const;
  void WriteRectangleProperty(long propertyId,
                              const VARIANT& value,
                              int root_x,
                              int root_y,
                              base::Value::Dict* dict) const;
  void WriteElementArray(long propertyId,
                         IUIAutomationElementArray* array,
                         base::Value::Dict* dict) const;
  std::u16string GetNodeName(IUIAutomationElement* node) const;
  std::string ProcessTreeForOutput(
      const base::Value::Dict& node) const override;
  void ProcessPropertyForOutput(const std::string& property_name,
                                const base::Value::Dict& dict,
                                std::string& line) const;
  void ProcessValueForOutput(const std::string& name,
                             const base::Value& value,
                             std::string& line) const;
  std::map<long, std::string>& GetCustomPropertiesMap() const;

  Microsoft::WRL::ComPtr<IUIAutomation> uia_;
  Microsoft::WRL::ComPtr<IUIAutomationCacheRequest> element_cache_request_;
  Microsoft::WRL::ComPtr<IUIAutomationCacheRequest> children_cache_request_;
};

}  // namespace ui

#endif  // UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_TREE_FORMATTER_UIA_WIN_H_