File: ax_event_intent_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 (157 lines) | stat: -rw-r--r-- 5,356 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Copyright 2020 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_AX_EVENT_INTENT_MAC_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_EVENT_INTENT_MAC_H_

#include "base/component_export.h"
#include "ui/accessibility/ax_enums.mojom-forward.h"

namespace ui {

struct AXEventIntent;

// Describes the type of the AXTextStateChangeIntent, as defined by Mac's
// accessibility framework.
//
// Broadly, there are two types of intents that may be attached to accessibility
// events: an editing intent or a selection intent.
//
// The enumeration values are taken from the WebKit source code, but they are
// modified slightly to comply with Chromium's C++ Style Guide. Please do not
// renumber.
enum class AXTextStateChangeType {
  kUnknown = 0,
  kEdit = 1,
  kSelectionMove = 2,
  kSelectionExtend = 3,
  kSelectionBoundary = 4
};

// Describes the type of the editing intent, as defined by Mac's accessibility
// framework.
//
// The enumeration values are taken from the WebKit source code, but they are
// modified slightly to comply with Chromium's C++ Style Guide. Please do not
// renumber.
enum class AXTextEditType {
  kUnknown = 0,
  kDelete = 1,
  kInsert = 2,
  kTyping = 3,
  kDictation = 4,
  kCut = 5,
  kPaste = 6,
  kAttributesChange = 7  // Change font, style, alignment, color, etc.
};

// Describes the directionality of a selection intent, as defined by Mac's
// accessibility framework.
//
// The enumeration values are taken from the WebKit source code, but they are
// modified slightly to comply with Chromium's C++ Style Guide. Please do not
// renumber.
enum class AXTextSelectionDirection {
  kUnknown = 0,
  kBeginning = 1,
  kEnd = 2,
  kPrevious = 3,
  kNext = 4,
  kDiscontiguous = 5
};

// Describes the amount by which the selection has moved or has been extended
// by, as defined by Mac's accessibility framework.
//
// The enumeration values are taken from the WebKit source code, but they are
// modified slightly to comply with Chromium's C++ Style Guide. Please do not
// renumber.
enum class AXTextSelectionGranularity {
  kUnknown = 0,
  kCharacter = 1,
  kWord = 2,
  kLine = 3,
  kSentence = 4,
  kParagraph = 5,
  kPage = 6,
  kDocument = 7,

  // All granularity represents the action of selecting the whole document as a
  // single action. Extending selection by some other granularity until it
  // encompasses the whole document should not result in a all granularity
  // notification.
  kAll = 8
};

// Describes a selection operation in an AXTextStateChangeIntent.
struct AXTextSelection final {
  // Constructs a description of a selection operation, translating the given
  // direction and granularity from Chromium's internal representation to what
  // the Mac accessibility framework expects.
  static AXTextSelection FromDirectionAndGranularity(
      ax::mojom::TextBoundary text_boundary,
      ax::mojom::MoveDirection move_direction);

  // Constructs a description of a selection operation that has no extra
  // information, such as when the selection is set using the mouse and so its
  // granularity would be hard to ascertain.
  AXTextSelection();

  // Constructs a description of a selection operation for which extra
  // information can be provided.
  AXTextSelection(AXTextSelectionDirection direction,
                  AXTextSelectionGranularity granularity,
                  bool focus_change);

  AXTextSelection(const AXTextSelection& selection);

  ~AXTextSelection();

  AXTextSelection& operator=(const AXTextSelection& selection);

  AXTextSelectionDirection direction = AXTextSelectionDirection::kUnknown;
  AXTextSelectionGranularity granularity = AXTextSelectionGranularity::kUnknown;
  bool focus_change = false;
};

// The equivalent of an accessibility event intent (AXEventIntent), as
// defined by Mac's accessibility framework.
struct COMPONENT_EXPORT(AX_PLATFORM) AXTextStateChangeIntent final {
  // Constructs an intent that is used when the selection is set to a different
  // iframe or control, and focus has move to that element.
  static AXTextStateChangeIntent DefaultFocusTextStateChangeIntent();

  // Constructs an intent that is used when the selection has moved to another
  // location within the same control, (i.e. browser focus hasn't moved), or
  // when the selection has been cleared.
  static AXTextStateChangeIntent DefaultSelectionChangeIntent();

  // Constructs an empty intent.
  AXTextStateChangeIntent();

  // Constructs a selection intent.
  AXTextStateChangeIntent(AXTextStateChangeType type,
                          AXTextSelection selection);

  // Constructs an editing intent.
  explicit AXTextStateChangeIntent(AXTextEditType edit);

  AXTextStateChangeIntent(const AXTextStateChangeIntent& intent);

  ~AXTextStateChangeIntent();

  AXTextStateChangeIntent& operator=(const AXTextStateChangeIntent& intent);

  AXTextStateChangeType type = AXTextStateChangeType::kUnknown;
  AXTextEditType edit = AXTextEditType::kUnknown;
  AXTextSelection selection;
};

// Converts from Chromium's AXEventIntent to Mac's AXTextStateChangeIntent.
COMPONENT_EXPORT(AX_PLATFORM)
AXTextStateChangeIntent FromEventIntent(const AXEventIntent& event_intent);

}  // namespace ui

#endif  // UI_ACCESSIBILITY_PLATFORM_AX_EVENT_INTENT_MAC_H_