summaryrefslogtreecommitdiffstats
path: root/accessible/mac/RotorRules.h
blob: e7d44adf4d277da7e87210315ab161ebeab56eb4 (plain)
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
/* clang-format off */
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* clang-format on */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#import "mozAccessible.h"
#include "Pivot.h"

using namespace mozilla::a11y;

/**
 * This rule matches all accessibles that satisfy the "boilerplate"
 * pivot conditions and have a corresponding native accessible.
 */
class RotorRule : public PivotRule {
 public:
  explicit RotorRule(Accessible* aDirectDescendantsFrom);
  explicit RotorRule();
  uint16_t Match(Accessible* aAcc) override;

 private:
  Accessible* mDirectDescendantsFrom;
};

/**
 * This rule matches all accessibles of a given role.
 */
class RotorRoleRule : public RotorRule {
 public:
  explicit RotorRoleRule(role aRole, Accessible* aDirectDescendantsFrom);
  explicit RotorRoleRule(role aRole);
  uint16_t Match(Accessible* aAcc) override;

 private:
  role mRole;
};

class RotorMacRoleRule : public RotorRule {
 public:
  explicit RotorMacRoleRule(NSString* aRole);
  explicit RotorMacRoleRule(NSString* aRole,
                            Accessible* aDirectDescendantsFrom);
  ~RotorMacRoleRule();
  virtual uint16_t Match(Accessible* aAcc) override;

 protected:
  NSString* mMacRole;
};

class RotorControlRule final : public RotorRule {
 public:
  explicit RotorControlRule(Accessible* aDirectDescendantsFrom);
  explicit RotorControlRule();

  virtual uint16_t Match(Accessible* aAcc) override;
};

class RotorTextEntryRule final : public RotorRule {
 public:
  explicit RotorTextEntryRule(Accessible* aDirectDescendantsFrom);
  explicit RotorTextEntryRule();

  virtual uint16_t Match(Accessible* aAcc) override;
};

class RotorLinkRule : public RotorRule {
 public:
  explicit RotorLinkRule();
  explicit RotorLinkRule(Accessible* aDirectDescendantsFrom);

  virtual uint16_t Match(Accessible* aAcc) override;
};

class RotorVisitedLinkRule final : public RotorLinkRule {
 public:
  explicit RotorVisitedLinkRule();
  explicit RotorVisitedLinkRule(Accessible* aDirectDescendantsFrom);

  virtual uint16_t Match(Accessible* aAcc) override;
};

class RotorUnvisitedLinkRule final : public RotorLinkRule {
 public:
  explicit RotorUnvisitedLinkRule();
  explicit RotorUnvisitedLinkRule(Accessible* aDirectDescendantsFrom);

  virtual uint16_t Match(Accessible* aAcc) override;
};

/**
 * This rule matches all accessibles that satisfy the "boilerplate"
 * pivot conditions and have a corresponding native accessible.
 */
class RotorNotMacRoleRule : public RotorMacRoleRule {
 public:
  explicit RotorNotMacRoleRule(NSString* aMacRole,
                               Accessible* aDirectDescendantsFrom);
  explicit RotorNotMacRoleRule(NSString* aMacRole);
  uint16_t Match(Accessible* aAcc) override;
};

class RotorStaticTextRule : public RotorRule {
 public:
  explicit RotorStaticTextRule();
  explicit RotorStaticTextRule(Accessible* aDirectDescendantsFrom);

  virtual uint16_t Match(Accessible* aAcc) override;
};

class RotorHeadingLevelRule : public RotorRoleRule {
 public:
  explicit RotorHeadingLevelRule(int32_t aLevel);
  explicit RotorHeadingLevelRule(int32_t aLevel,
                                 Accessible* aDirectDescendantsFrom);

  virtual uint16_t Match(Accessible* aAcc) override;

 private:
  int32_t mLevel;
};

class RotorLiveRegionRule : public RotorRule {
 public:
  explicit RotorLiveRegionRule(Accessible* aDirectDescendantsFrom)
      : RotorRule(aDirectDescendantsFrom) {}
  explicit RotorLiveRegionRule() : RotorRule() {}

  uint16_t Match(Accessible* aAcc) override;
};

/**
 * This rule matches all accessibles with roles::OUTLINEITEM. If
 * outlines are nested, it ignores the nested subtree and returns
 * only items which are descendants of the primary outline.
 */
class OutlineRule : public RotorRule {
 public:
  explicit OutlineRule();
  uint16_t Match(Accessible* aAcc) override;
};