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
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QWASMACCESIBILITY_H
#define QWASMACCESIBILITY_H
#include <QtCore/qtconfigmacros.h>
#include <QtGui/qtguiglobal.h>
#include <QtCore/qhash.h>
#include <private/qstdweb_p.h>
#include <qpa/qplatformaccessibility.h>
#include <emscripten/val.h>
#include <QLoggingCategory>
#include <map>
#include <emscripten/bind.h>
Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
#if !QT_CONFIG(accessibility)
class QWasmAccessibility
{
public:
static void addAccessibilityEnableButton(QWindow *window) {}
static void onShowWindow(QWindow *) {}
static void onRemoveWindow(QWindow *) {}
static bool isEnabled() {
return false;
}
};
#else
class QWasmAccessibility : public QPlatformAccessibility
{
public:
QWasmAccessibility();
~QWasmAccessibility();
static QWasmAccessibility* get();
static void addAccessibilityEnableButton(QWindow *window);
static void onShowWindow(QWindow *);
static void onRemoveWindow(QWindow *);
static bool isEnabled();
private:
void addAccessibilityEnableButtonImpl(QWindow *window);
void enableAccessibility();
void onShowWindowImpl(QWindow *);
void onRemoveWindowImpl(QWindow *);
emscripten::val getA11yContainer(QWindow *window);
emscripten::val getA11yContainer(QAccessibleInterface *iface);
emscripten::val getDescribedByContainer(QWindow *window);
emscripten::val getDescribedByContainer(QAccessibleInterface *iface);
emscripten::val getElementContainer(QWindow *window);
emscripten::val getElementContainer(QAccessibleInterface *iface);
emscripten::val getDocument(const emscripten::val &container);
emscripten::val getDocument(QAccessibleInterface *iface);
QWindow *getWindow(QAccessibleInterface *iface);
bool isWindowNode(QAccessibleInterface *iface);
emscripten::val createHtmlElement(QAccessibleInterface *iface);
void destroyHtmlElement(QAccessibleInterface *iface);
emscripten::val getHtmlElement(QAccessibleInterface *iface);
void linkToParent(QAccessibleInterface *iface);
void setHtmlElementVisibility(QAccessibleInterface *iface, bool visible);
void setHtmlElementGeometry(QAccessibleInterface *iface);
void setHtmlElementGeometry(emscripten::val element, QRect geometry);
void setHtmlElementTextName(QAccessibleInterface *iface);
void setHtmlElementTextNameLE(QAccessibleInterface *iface);
void setHtmlElementFocus(QAccessibleInterface *iface);
void setHtmlElementDisabled(QAccessibleInterface *iface);
void handleStaticTextUpdate(QAccessibleEvent *event);
void handleButtonUpdate(QAccessibleEvent *event);
void handleCheckBoxUpdate(QAccessibleEvent *event);
void handleDialogUpdate(QAccessibleEvent *event);
void handleMenuUpdate(QAccessibleEvent *event);
void handleToolUpdate(QAccessibleEvent *event);
void handleLineEditUpdate(QAccessibleEvent *event);
void handleRadioButtonUpdate(QAccessibleEvent *event);
void handleSpinBoxUpdate(QAccessibleEvent *event);
void handlePageTabUpdate(QAccessibleEvent *event);
void handleSliderUpdate(QAccessibleEvent *event);
void handleScrollBarUpdate(QAccessibleEvent *event);
void handlePageTabListUpdate(QAccessibleEvent *event);
void handleIdentifierUpdate(QAccessibleInterface *iface);
void handleDescriptionChanged(QAccessibleInterface *iface);
void handleEventFromHtmlElement(const emscripten::val event);
void populateAccessibilityTree(QAccessibleInterface *iface);
void createObject(QAccessibleInterface *iface);
void removeObject(QAccessibleInterface *iface);
void unlinkParentForChildren(QAccessibleInterface *iface);
void relinkParentForChildren(QAccessibleInterface *iface);
void notifyAccessibilityUpdate(QAccessibleEvent *event) override;
void setRootObject(QObject *o) override;
void initialize() override;
void cleanup() override;
void setAttribute(emscripten::val element, const std::string &attr, const std::string &val);
void setAttribute(emscripten::val element, const std::string &attr, const char *val);
void setAttribute(emscripten::val element, const std::string &attr, bool val);
void setProperty(emscripten::val element, const std::string &attr, const std::string &val);
void setProperty(emscripten::val element, const std::string &attr, const char *val);
void setProperty(emscripten::val element, const std::string &attr, bool val);
void addEventListener(emscripten::val element, const char *eventType);
private:
static QWasmAccessibility *s_instance;
QObject *m_rootObject = nullptr;
bool m_accessibilityEnabled = false;
std::map<QWindow *, std::tuple<emscripten::val, std::shared_ptr<qstdweb::EventCallback>>> m_enableButtons;
QHash<QAccessibleInterface *, emscripten::val> m_elements;
int m_eventHandlerIndex;
};
#endif // QT_CONFIG(accessibility)
#endif
|