File: ax_call_statement_invoker_mac.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 (122 lines) | stat: -rw-r--r-- 4,951 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
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
120
121
122
// Copyright 2022 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_CALL_STATEMENT_INVOKER_MAC_H_
#define UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_CALL_STATEMENT_INVOKER_MAC_H_

#include "base/component_export.h"
#include "base/memory/raw_ptr.h"
#include "ui/accessibility/platform/inspect/ax_tree_indexer_mac.h"

namespace ui {

class AXElementWrapper;
class AXPropertyNode;

// Invokes a script instruction describing a call unit which represents
// a sequence of calls.
class COMPONENT_EXPORT(AX_PLATFORM) AXCallStatementInvoker final {
 public:
  // Generic version, all calls are executed in the context of property nodes.
  // Note: both |indexer| and |storage| must outlive this object.
  AXCallStatementInvoker(const AXTreeIndexerMac* indexer,
                         std::map<std::string, id>* storage);

  // Single target version, all calls are executed in the context of the given
  // target node.
  // Note: |indexer| must outlive this object.
  AXCallStatementInvoker(id node, const AXTreeIndexerMac* indexer);

  // Invokes an attribute matching a property filter.
  AXOptionalNSObject Invoke(const AXPropertyNode& property_node,
                            bool no_object_parse = false) const;

 private:
  // Returns true if the invoker is instantiated to invoke an ax_script
  // instruction, in contrast to processing ax_dump_tree filters.
  bool IsDumpingTree() const { return !!node; }

  // Invokes a property node for a given target.
  AXOptionalNSObject InvokeFor(id target,
                               const AXPropertyNode& property_node) const;

  // Invoke a property node for a given AXCustomContent.
  AXOptionalNSObject InvokeForAXCustomContent(
      id target,
      const AXPropertyNode& property_node) const;

  // Invokes a property node for a given AXElement.
  AXOptionalNSObject InvokeForAXElement(
      const AXElementWrapper& ax_element,
      const AXPropertyNode& property_node) const;

  // Invokes a property node for a given AXTextMarkerRange.
  AXOptionalNSObject InvokeForAXTextMarkerRange(
      id target,
      const AXPropertyNode& property_node) const;

  // Invokes a property node for a given array.
  AXOptionalNSObject InvokeForArray(id target,
                                    const AXPropertyNode& property_node) const;

  // Invokes a property node for a given dictionary.
  AXOptionalNSObject InvokeForDictionary(
      id target,
      const AXPropertyNode& property_node) const;

  // Invokes setAccessibilityFocused method.
  AXOptionalNSObject InvokeSetAccessibilityFocused(
      const AXElementWrapper& ax_element,
      const AXPropertyNode& property_node) const;

  // Returns a parameterized attribute parameter by a property node representing
  // an attribute call.
  AXOptionalNSObject ParamFrom(const AXPropertyNode&) const;

  // Returns a parameterized attribute parameter by an attribute and a property
  // node representing an argument.
  AXOptionalNSObject ParamFrom(const std::string& attribute,
                               const AXPropertyNode& argument) const;

  // Converts a given property node to NSObject. If not convertible, returns
  // nil.
  id PropertyNodeToNSObject(const AXPropertyNode& property_node) const;

  NSNumber* PropertyNodeToInt(const AXPropertyNode&,
                              bool log_failure = true) const;
  NSString* PropertyNodeToString(const AXPropertyNode&,
                                 bool log_failure = true) const;
  NSArray* PropertyNodeToIntArray(const AXPropertyNode&,
                                  bool log_failure = true) const;
  NSArray* PropertyNodeToTextMarkerArray(const AXPropertyNode&,
                                         bool log_failure = true) const;
  NSValue* PropertyNodeToRange(const AXPropertyNode&,
                               bool log_failure = true) const;
  gfx::NativeViewAccessible PropertyNodeToUIElement(
      const AXPropertyNode&,
      bool log_failure = true) const;

  id DictionaryNodeToTextMarker(const AXPropertyNode&,
                                bool log_failure = true) const;
  id PropertyNodeToTextMarker(const AXPropertyNode&,
                              bool log_failure = true) const;
  id PropertyNodeToTextMarkerRange(const AXPropertyNode&,
                                   bool log_failure = true) const;

  gfx::NativeViewAccessible LineIndexToNode(
      const std::u16string line_index) const;

  id __strong node;

  // Map between AXUIElement objects and their DOMIds/accessible tree
  // line numbers. Owned by the caller and outlives this object.
  const raw_ptr<const AXTreeIndexerMac> indexer_;

  // Variables storage. Owned by the caller and outlives this object.
  const raw_ptr<std::map<std::string, id>> storage_;
};

}  // namespace ui

#endif  // UI_ACCESSIBILITY_PLATFORM_INSPECT_AX_CALL_STATEMENT_INVOKER_MAC_H_