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 StartNativeAccessibility();
58
59
// Event methods
60
void SendFocusEvent(AccessibleWrap* aAccessible);
61
void SendScrollingEvent(AccessibleWrap* aAccessible, int32_t aScrollX,
62
int32_t aScrollY, int32_t aMaxScrollX,
63
int32_t aMaxScrollY);
64
MOZ_CAN_RUN_SCRIPT
65
void SendAccessibilityFocusedEvent(AccessibleWrap* aAccessible);
66
void SendHoverEnterEvent(AccessibleWrap* aAccessible);
67
void SendTextSelectionChangedEvent(AccessibleWrap* aAccessible,
68
int32_t aCaretOffset);
69
void SendTextTraversedEvent(AccessibleWrap* aAccessible, int32_t aStartOffset,
70
int32_t aEndOffset);
71
void SendTextChangedEvent(AccessibleWrap* aAccessible, const nsString& aStr,
72
int32_t aStart, uint32_t aLen, bool aIsInsert,
73
bool aFromUser);
74
void SendSelectedEvent(AccessibleWrap* aAccessible, bool aSelected);
75
void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked);
76
void SendWindowContentChangedEvent();
77
void SendWindowStateChangedEvent(AccessibleWrap* aAccessible);
78
void SendAnnouncementEvent(AccessibleWrap* aAccessible,
79
const nsString& aAnnouncement, uint16_t aPriority);
80
81
// Cache methods
82
void ReplaceViewportCache(
83
const nsTArray<AccessibleWrap*>& aAccessibles,
84
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
85
86
void ReplaceFocusPathCache(
87
const nsTArray<AccessibleWrap*>& aAccessibles,
88
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
89
90
void UpdateCachedBounds(
91
const nsTArray<AccessibleWrap*>& aAccessibles,
92
const nsTArray<BatchData>& aData = nsTArray<BatchData>());
93
94
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SessionAccessibility)
95
96
private:
97
~SessionAccessibility() {}
98
99
void SetAttached(bool aAttached, already_AddRefed<Runnable> aRunnable);
100
RootAccessibleWrap* GetRoot();
101
102
nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
103
java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
104
};
105
106
} // namespace a11y
107
} // namespace mozilla
108
109
#endif