Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef mozilla_a11y_SessionAccessibility_h_
7
#define mozilla_a11y_SessionAccessibility_h_
8
9
#include "GeneratedJNINatives.h"
10
#include "GeneratedJNIWrappers.h"
11
#include "nsAppShell.h"
12
#include "nsThreadUtils.h"
13
#include "nsWindow.h"
14
15
namespace mozilla {
16
namespace a11y {
17
18
class AccessibleWrap;
19
class ProxyAccessible;
20
class RootAccessibleWrap;
21
class BatchData;
22
23
class SessionAccessibility final
24
: public java::SessionAccessibility::NativeProvider::Natives<
25
SessionAccessibility> {
26
public:
27
typedef java::SessionAccessibility::NativeProvider::Natives<
28
SessionAccessibility>
29
Base;
30
31
SessionAccessibility(
32
nsWindow::NativePtr<SessionAccessibility>* aPtr, nsWindow* aWindow,
33
java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
34
: mWindow(aPtr, aWindow), mSessionAccessibility(aSessionAccessibility) {
35
SetAttached(true, nullptr);
36
}
37
38
void OnDetach(already_AddRefed<Runnable> aDisposer) {
39
SetAttached(false, std::move(aDisposer));
40
}
41
42
const java::SessionAccessibility::NativeProvider::Ref&
43
GetJavaAccessibility() {
44
return mSessionAccessibility;
45
}
46
47
static void Init();
48
static SessionAccessibility* GetInstanceFor(ProxyAccessible* aAccessible);
49
static SessionAccessibility* GetInstanceFor(Accessible* aAccessible);
50
51
// Native implementations
52
using Base::AttachNative;
53
using Base::DisposeNative;
54
jni::Object::LocalRef GetNodeInfo(int32_t aID);
55
void SetText(int32_t aID, jni::String::Param aText);
56
void Click(int32_t aID);
57
void Pivot(int32_t aID, int32_t aGranularity, bool aForward, bool aInclusive);
58
void ExploreByTouch(int32_t aID, float aX, float aY);
59
void NavigateText(int32_t aID, int32_t aGranularity, int32_t aStartOffset,
60
int32_t aEndOffset, bool aForward, bool aSelect);
61
void SetSelection(int32_t aID, int32_t aStart, int32_t aEnd);
62
void Cut(int32_t aID);
63
void Copy(int32_t aID);
64
void Paste(int32_t aID);
65
void StartNativeAccessibility();
66
67
// Event methods
68
void SendFocusEvent(AccessibleWrap* aAccessible);
69
void SendScrollingEvent(AccessibleWrap* aAccessible, int32_t aScrollX,
70
int32_t aScrollY, int32_t aMaxScrollX,
71
int32_t aMaxScrollY);
72
MOZ_CAN_RUN_SCRIPT
73
void SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible);
74
void SendHoverEnterEvent(AccessibleWrap* aAccessible);
75
void SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
76
int32_t aCaretOffset);
77
void SendTextTraversedEvent(AccessibleWrap* aAccessible, int32_t aStartOffset,
78
int32_t aEndOffset);
79
void SendTextChangedEvent(AccessibleWrap* aAccessible, const nsString& aStr,
80
int32_t aStart, uint32_t aLen, bool aIsInsert,
81
bool aFromUser);
82
void SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected);
83
void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked);
84
void SendWindowContentChangedEvent();
85
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
86
void SendAnnouncementEvent(AccessibleWrap* aAccessible,
87
const nsString& aAnnouncement, uint16_t aPriority);
88
89
// Cache methods
90
void ReplaceViewportCache(
91
const nsTArray<AccessibleWrap*>& aAccessibles,
92
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
93
94
void ReplaceFocusPathCache(
95
const nsTArray<AccessibleWrap*>& aAccessibles,
96
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
97
98
void UpdateCachedBounds(
99
const nsTArray<AccessibleWrap*>& aAccessibles,
100
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
101
102
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
103
104
private:
105
~SessionAccessibility() {}
106
107
void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
108
RootAccessibleWrap* GetRoot();
109
110
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
111
java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
112
};
113
114
} // namespace a11y
115
} // namespace mozilla
116
117
#endif