4#ifndef QWASMACCESIBILITY_H
5#define QWASMACCESIBILITY_H
7#include <QtCore/qtconfigmacros.h>
8#include <QtGui/qtguiglobal.h>
10#include <QtCore/qhash.h>
11#include <private/qstdweb_p.h>
12#include <qpa/qplatformaccessibility.h>
14#include <emscripten/val.h>
15#include <QLoggingCategory>
18#include <emscripten/bind.h>
20Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
24#if !QT_CONFIG(accessibility)
25class QWasmAccessibility
28 static void addAccessibilityEnableButton(QWindow *window) {}
29 static void onShowWindow(QWindow *) {}
30 static void onRemoveWindow(QWindow *) {}
31 static bool isEnabled() {
34 static void enable() {}
37class QWasmAccessibility :
public QPlatformAccessibility
41 ~QWasmAccessibility();
43 static QWasmAccessibility* get();
45 static void addAccessibilityEnableButton(QWindow *window);
46 static void onShowWindow(QWindow *);
47 static void onRemoveWindow(QWindow *);
48 static bool isEnabled();
52 void addAccessibilityEnableButtonImpl(QWindow *window);
53 void enableAccessibility();
54 void onShowWindowImpl(QWindow *);
55 void onRemoveWindowImpl(QWindow *);
57 emscripten::val getA11yContainer(QWindow *window);
58 emscripten::val getA11yContainer(QAccessibleInterface *iface);
59 emscripten::val getDescribedByContainer(QWindow *window);
60 emscripten::val getDescribedByContainer(QAccessibleInterface *iface);
61 emscripten::val getElementContainer(QWindow *window);
62 emscripten::val getElementContainer(QAccessibleInterface *iface);
63 emscripten::val getDocument(
const emscripten::val &container);
64 emscripten::val getDocument(QAccessibleInterface *iface);
65 QWindow *getWindow(QAccessibleInterface *iface);
66 bool isWindowNode(QAccessibleInterface *iface);
68 emscripten::val createHtmlElement(QAccessibleInterface *iface);
69 void destroyHtmlElement(QAccessibleInterface *iface);
70 emscripten::val getHtmlElement(QAccessibleInterface *iface);
71 void repairLinks(QAccessibleInterface *iface);
72 void linkToParent(QAccessibleInterface *iface);
73 void setHtmlElementVisibility(QAccessibleInterface *iface,
bool visible);
74 void setHtmlElementGeometry(QAccessibleInterface *iface);
75 void setHtmlElementGeometry(emscripten::val element, QRect geometry);
76 void setHtmlElementTextName(QAccessibleInterface *iface);
77 void setHtmlElementTextNameLE(QAccessibleInterface *iface);
78 void setHtmlElementFocus(QAccessibleInterface *iface);
79 void setHtmlElementDisabled(QAccessibleInterface *iface);
81 void handleStaticTextUpdate(QAccessibleEvent *event);
82 void handleButtonUpdate(QAccessibleEvent *event);
83 void handleCheckBoxUpdate(QAccessibleEvent *event);
84 void handleDialogUpdate(QAccessibleEvent *event);
85 void handleMenuUpdate(QAccessibleEvent *event);
86 void handleToolUpdate(QAccessibleEvent *event);
87 void handleLineEditUpdate(QAccessibleEvent *event);
88 void handleRadioButtonUpdate(QAccessibleEvent *event);
89 void handleSpinBoxUpdate(QAccessibleEvent *event);
90 void handlePageTabUpdate(QAccessibleEvent *event);
91 void handleSliderUpdate(QAccessibleEvent *event);
92 void handleScrollBarUpdate(QAccessibleEvent *event);
93 void handlePageTabListUpdate(QAccessibleEvent *event);
94 void handleIdentifierUpdate(QAccessibleInterface *iface);
95 void handleDescriptionChanged(QAccessibleInterface *iface);
97 void handleEventFromHtmlElement(
const emscripten::val event);
99 void populateAccessibilityTree(QAccessibleInterface *iface);
100 void createObject(QAccessibleInterface *iface);
101 void removeObject(QAccessibleInterface *iface);
102 void unlinkParentForChildren(QAccessibleInterface *iface);
103 void relinkParentForChildren(QAccessibleInterface *iface);
105 void notifyAccessibilityUpdate(QAccessibleEvent *event)
override;
106 void setRootObject(QObject *o)
override;
107 void initialize() override;
108 void cleanup() override;
110 void setAttribute(emscripten::val element,
const std::string &attr,
const std::string &val);
111 void setAttribute(emscripten::val element,
const std::string &attr,
const char *val);
112 void setAttribute(emscripten::val element,
const std::string &attr,
bool val);
114 void setProperty(emscripten::val element,
const std::string &attr,
const std::string &val);
115 void setProperty(emscripten::val element,
const std::string &attr,
const char *val);
116 void setProperty(emscripten::val element,
const std::string &attr,
bool val);
118 void addEventListener(emscripten::val element,
const char *eventType);
121 static QWasmAccessibility *s_instance;
122 QObject *m_rootObject =
nullptr;
123 bool m_accessibilityEnabled =
false;
124 std::map<QWindow *, std::tuple<emscripten::val, std::shared_ptr<qstdweb::EventCallback>>> m_enableButtons;
125 QHash<QAccessibleInterface *, emscripten::val> m_elements;
126 int m_eventHandlerIndex;
void QWasmAccessibilityEnable()