5#ifndef QWASMACCESIBILITY_H
6#define QWASMACCESIBILITY_H
8#include <QtCore/qtconfigmacros.h>
9#include <QtGui/qtguiglobal.h>
11#include <QtCore/qhash.h>
12#include <private/qstdweb_p.h>
13#include <qpa/qplatformaccessibility.h>
15#include <emscripten/val.h>
16#include <QLoggingCategory>
19#include <emscripten/bind.h>
21Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
25#if !QT_CONFIG(accessibility)
26class QWasmAccessibility
29 static void addAccessibilityEnableButton(QWindow *window) {}
30 static void onShowWindow(QWindow *) {}
31 static void onRemoveWindow(QWindow *) {}
32 static bool isEnabled() {
35 static void enable() {}
38class QWasmAccessibility :
public QPlatformAccessibility
42 ~QWasmAccessibility();
44 static void addAccessibilityEnableButton(QWindow *window);
45 static void onShowWindow(QWindow *);
46 static void onRemoveWindow(QWindow *);
47 static bool isEnabled();
51 static QWasmAccessibility *instance();
53 void addEnableButton(QWindow *window);
54 void enableAccessibility();
55 void removeWindow(QWindow *window);
57 emscripten::val getDescribedByContainer(QWindow *window);
58 emscripten::val getDescribedByContainer(QAccessibleInterface *iface);
59 emscripten::val getElementContainer(QWindow *window);
60 emscripten::val getElementContainer(QAccessibleInterface *iface);
61 emscripten::val getDocument(
const emscripten::val &container);
62 QWindow *getWindow(QAccessibleInterface *iface);
63 bool isWindowNode(QAccessibleInterface *iface);
65 emscripten::val createHtmlElement(QAccessibleInterface *iface);
66 void destroyHtmlElement(QAccessibleInterface *iface);
67 emscripten::val getHtmlElement(QAccessibleInterface *iface);
68 void repairLinks(QAccessibleInterface *iface);
69 void linkToParent(QAccessibleInterface *iface);
70 void setHtmlElementVisibility(QAccessibleInterface *iface,
bool visible);
71 void setHtmlElementGeometry(QAccessibleInterface *iface);
72 void setHtmlElementGeometry(emscripten::val element, QRect geometry);
73 void setHtmlElementFocus(QAccessibleInterface *iface);
74 void setHtmlElementDisabled(QAccessibleInterface *iface);
75 void setHtmlElementOrientation(emscripten::val element, QAccessibleInterface *iface);
77 void handleListItemUpdate(QAccessibleEvent *event);
78 void handleStaticTextUpdate(QAccessibleEvent *event);
79 void handleButtonUpdate(QAccessibleEvent *event);
80 void handleCheckBoxUpdate(QAccessibleEvent *event);
81 void handleGroupBoxUpdate(QAccessibleEvent *event);
82 void handleSwitchUpdate(QAccessibleEvent *event);
83 void handleDialogUpdate(QAccessibleEvent *event);
84 void handleMenuUpdate(QAccessibleEvent *event);
85 void handleToolUpdate(QAccessibleEvent *event);
86 void handleLineEditUpdate(QAccessibleEvent *event);
87 void handleRadioButtonUpdate(QAccessibleEvent *event);
88 void handleDialUpdate(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);
96 void handleAnnouncement(QAccessibleInterface *iface,
97 QAccessibleAnnouncementEvent *announcementEvent);
98 void handleProgressBarUpdate(QAccessibleEvent *event);
100 void handleEventFromHtmlElement(
const emscripten::val event);
102 void populateAccessibilityTree(QAccessibleInterface *iface);
103 void createObject(QAccessibleInterface *iface);
104 void removeObject(QAccessible::Id id);
105 void unlinkParentForChildren(QAccessibleInterface *iface);
106 void relinkParentForChildren(QAccessibleInterface *iface);
108 void notifyAccessibilityUpdate(QAccessibleEvent *event)
override;
109 bool handleUpdateByEventType(QAccessibleEvent *event);
110 void handleUpdateByInterfaceRole(QAccessibleEvent *event);
112 void setAttribute(emscripten::val element,
const std::string &attr,
const std::string &val);
113 void setAttribute(emscripten::val element,
const std::string &attr,
const char *val);
114 void setAttribute(emscripten::val element,
const std::string &attr,
bool val);
116 void setProperty(emscripten::val element,
const std::string &attr,
const std::string &val);
117 void setProperty(emscripten::val element,
const std::string &attr,
const char *val);
118 void setProperty(emscripten::val element,
const std::string &attr,
bool val);
120 void setNamedAttribute(QAccessibleInterface *iface,
const std::string &attribute, QAccessible::Text text);
121 void setNamedProperty(QAccessibleInterface *iface,
const std::string &property, QAccessible::Text text);
123 void addEventListener(QAccessibleInterface *, emscripten::val element,
const char *eventType);
124 void sendEvent(QAccessibleInterface *iface, QAccessible::Event eventType);
127 std::map<QWindow *, std::tuple<emscripten::val, std::shared_ptr<qstdweb::EventCallback>>> m_enableButtons;
128 QHash<QAccessible::Id, emscripten::val> m_elements;
129 int m_eventHandlerIndex;
void QWasmAccessibilityEnable()