From 9c1fc644ba3bea5af0ca06811f79a06620f68c55 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 2 Dec 2026 23:15:21 -0500 Subject: [PATCH] Add browser accessibility for Chromium windows Chromium-based Windows applications under Wine (Electron, CEF) exposed only what the legacy MSAA path could announce, one event at a time. The helper now starts a publisher for each Chromium window: a PE worker reads the page through MSAA and IAccessible2 inside the prefix, and a native ATK publisher presents it on the accessibility bus as toolkit Chromium, matching native Linux Chromium, so the reader's own browser support handles browse mode, structural navigation, forms, tables and live regions. Once a window is published, legacy announcements for it stop, so nothing is spoken twice; if the publisher fails, the window returns to the legacy path and the helper retries with backoff. Publishers follow the helper's lifetime. The publisher marks itself with WINE_ACCESS_BROWSER_PUBLISHER=1 and gives each frame a wine-access-x11-window attribute so readers can verify window ownership. Password text, values and boundaries never leave the worker. Design, mapping rules and verification are in docs/browser.md; the IAccessible2 IDL is vendored in third_party/ia2. Checked: xvfb-run ctest (all 10, including the new browser-publisher-snapshot comparison with native Chromium 158 and Electron 42), menu_integration.py with the menu and edit fixtures, the Orca extension unit tests, and tests/browser/live_checks.sh against Electron 45: worker protocol, helper lifecycle (publish, no legacy announcements while typing, restart, no orphans), and live tree, text boundaries and AT-SPI event sequence matching native Chromium. A live test with Cthulhu on Electron 45 read the fixture page correctly. Remaining live checks: Orca with the extension, Firefox, WebView2, 32-bit browsers, iframes, and window switching under other window managers. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- CMakeLists.txt | 57 +- README.md | 12 +- browser_bridge.cpp | 247 ++ browser_bridge.h | 44 + browser_publisher.c | 2544 +++++++++++++++++ browser_worker.cpp | 1260 ++++++++ .../ArchLinux/wine-access-git/PKGBUILD | 2 +- docs/browser.md | 119 + main.cpp | 20 +- tests/README.md | 49 + tests/browser/atspi_dump.py | 200 ++ tests/browser/compare_dumps.py | 118 + tests/browser/compare_events.py | 58 + tests/browser/data/electron45-snapshot.json | 1 + .../data/native-chromium158-document.txt | 629 ++++ .../data/native-electron42-application.txt | 504 ++++ tests/browser/fixture-app/fixture.html | 45 + tests/browser/fixture-app/main.js | 29 + tests/browser/fixture-app/package.json | 5 + tests/browser/helper_integration.py | 193 ++ tests/browser/live_checks.sh | 61 + tests/browser/live_driver.py | 218 ++ tests/browser/live_session.sh | 106 + tests/browser/private_session.sh | 53 + tests/browser/publisher_snapshot_test.sh | 62 + tests/browser/worker_driver.py | 201 ++ third_party/ia2/Accessible2.idl | 696 +++++ third_party/ia2/Accessible2_2.idl | 123 + third_party/ia2/Accessible2_3.idl | 50 + third_party/ia2/AccessibleAction.idl | 220 ++ third_party/ia2/AccessibleApplication.idl | 121 + third_party/ia2/AccessibleComponent.idl | 124 + third_party/ia2/AccessibleDocument.idl | 78 + third_party/ia2/AccessibleEditableText.idl | 262 ++ third_party/ia2/AccessibleEventID.idl | 235 ++ third_party/ia2/AccessibleHyperlink.idl | 187 ++ third_party/ia2/AccessibleHypertext.idl | 123 + third_party/ia2/AccessibleHypertext2.idl | 87 + third_party/ia2/AccessibleImage.idl | 111 + third_party/ia2/AccessibleRelation.idl | 245 ++ third_party/ia2/AccessibleRole.idl | 348 +++ third_party/ia2/AccessibleStates.idl | 209 ++ third_party/ia2/AccessibleTable.idl | 551 ++++ third_party/ia2/AccessibleTable2.idl | 377 +++ third_party/ia2/AccessibleTableCell.idl | 194 ++ third_party/ia2/AccessibleText.idl | 701 +++++ third_party/ia2/AccessibleText2.idl | 98 + .../ia2/AccessibleTextSelectionContainer.idl | 139 + third_party/ia2/AccessibleValue.idl | 136 + third_party/ia2/IA2CommonTypes.idl | 191 ++ third_party/ia2/README.md | 13 + 52 files changed, 12448 insertions(+), 10 deletions(-) create mode 100644 browser_bridge.cpp create mode 100644 browser_bridge.h create mode 100644 browser_publisher.c create mode 100644 browser_worker.cpp create mode 100644 docs/browser.md create mode 100755 tests/browser/atspi_dump.py create mode 100755 tests/browser/compare_dumps.py create mode 100755 tests/browser/compare_events.py create mode 100644 tests/browser/data/electron45-snapshot.json create mode 100644 tests/browser/data/native-chromium158-document.txt create mode 100644 tests/browser/data/native-electron42-application.txt create mode 100644 tests/browser/fixture-app/fixture.html create mode 100644 tests/browser/fixture-app/main.js create mode 100644 tests/browser/fixture-app/package.json create mode 100755 tests/browser/helper_integration.py create mode 100755 tests/browser/live_checks.sh create mode 100755 tests/browser/live_driver.py create mode 100755 tests/browser/live_session.sh create mode 100755 tests/browser/private_session.sh create mode 100755 tests/browser/publisher_snapshot_test.sh create mode 100755 tests/browser/worker_driver.py create mode 100644 third_party/ia2/Accessible2.idl create mode 100644 third_party/ia2/Accessible2_2.idl create mode 100644 third_party/ia2/Accessible2_3.idl create mode 100644 third_party/ia2/AccessibleAction.idl create mode 100644 third_party/ia2/AccessibleApplication.idl create mode 100644 third_party/ia2/AccessibleComponent.idl create mode 100644 third_party/ia2/AccessibleDocument.idl create mode 100644 third_party/ia2/AccessibleEditableText.idl create mode 100644 third_party/ia2/AccessibleEventID.idl create mode 100644 third_party/ia2/AccessibleHyperlink.idl create mode 100644 third_party/ia2/AccessibleHypertext.idl create mode 100644 third_party/ia2/AccessibleHypertext2.idl create mode 100644 third_party/ia2/AccessibleImage.idl create mode 100644 third_party/ia2/AccessibleRelation.idl create mode 100644 third_party/ia2/AccessibleRole.idl create mode 100644 third_party/ia2/AccessibleStates.idl create mode 100644 third_party/ia2/AccessibleTable.idl create mode 100644 third_party/ia2/AccessibleTable2.idl create mode 100644 third_party/ia2/AccessibleTableCell.idl create mode 100644 third_party/ia2/AccessibleText.idl create mode 100644 third_party/ia2/AccessibleText2.idl create mode 100644 third_party/ia2/AccessibleTextSelectionContainer.idl create mode 100644 third_party/ia2/AccessibleValue.idl create mode 100644 third_party/ia2/IA2CommonTypes.idl create mode 100644 third_party/ia2/README.md diff --git a/AGENTS.md b/AGENTS.md index e119368..922210d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## Project Structure & Module Organization -This standalone Winelib helper forwards Wine accessibility events and NVDA/Tolk requests to Cthulhu’s session D-Bus service. Root sources include `main.cpp` (RPC, MSAA, event forwarding), `list_view.cpp`, and native hooks in `menu_hook.c` and `edit_hook.c`. Shared contracts live in headers and `nvdaController.idl`; generated RPC files belong under `build/generated/`. `tests/` holds C/C++ fixtures and the Python integration runner. Arch packaging lives in `distro-packages/ArchLinux/wine-access-git/`. +This standalone Winelib helper forwards Wine accessibility events and NVDA/Tolk requests to Cthulhu’s session D-Bus service. Root sources include `main.cpp` (RPC, MSAA, event forwarding), `list_view.cpp`, and native hooks in `menu_hook.c` and `edit_hook.c`. Browser support is `browser_bridge.cpp` (helper side), `browser_worker.cpp` (PE IA2 worker) and `browser_publisher.c` (native ATK publisher), with IAccessible2 IDL in `third_party/ia2/` and design and verification in `docs/browser.md`. Shared contracts live in headers and `nvdaController.idl`; generated RPC files belong under `build/generated/`. `tests/` holds C/C++ fixtures and the Python integration runner; `tests/browser/` holds the browser comparison data and tools. Arch packaging lives in `distro-packages/ArchLinux/wine-access-git/`. ## Before Starting a Fix or Feature diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ef71c9..a2c457f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,11 @@ pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb) find_program(WIDL_EXECUTABLE widl REQUIRED) find_program(MINGW_C_COMPILER x86_64-w64-mingw32-gcc REQUIRED) find_program(MINGW32_C_COMPILER i686-w64-mingw32-gcc REQUIRED) +find_program(MINGW_CXX_COMPILER x86_64-w64-mingw32-g++ REQUIRED) +# The browser publisher is a native Linux program: build it with the host +# compiler, not winegcc. +find_program(HOST_C_COMPILER NAMES cc gcc REQUIRED) +pkg_check_modules(BROWSER_PUBLISHER REQUIRED atk atk-bridge-2.0 json-glib-1.0 glib-2.0 x11) # A PE hook DLL can be loaded into ordinary Wine applications without any # GLib dependencies. Keep it alongside the Winelib helper. @@ -41,6 +46,46 @@ add_custom_command(OUTPUT "${menu_hook32}" "${menu_host32}" VERBATIM) add_custom_target(wine-access-menu32 ALL DEPENDS "${menu_hook32}" "${menu_host32}") +# Browser bridge (see docs/browser.md): a PE worker that reads a Chromium +# window through MSAA/IAccessible2 inside the prefix, and a native publisher +# that presents it on the accessibility bus. IAccessible2 headers are +# generated from the vendored IDL. +set(ia2_idl_dir "${CMAKE_CURRENT_SOURCE_DIR}/third_party/ia2") +set(ia2_generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated/ia2") +file(MAKE_DIRECTORY "${ia2_generated_dir}") +file(GLOB ia2_idl_files CONFIGURE_DEPENDS "${ia2_idl_dir}/*.idl") +set(ia2_headers) +set(ia2_guids) +foreach(idl IN LISTS ia2_idl_files) + get_filename_component(idl_name "${idl}" NAME_WE) + set(header "${ia2_generated_dir}/${idl_name}.h") + set(guids "${ia2_generated_dir}/${idl_name}_i.c") + add_custom_command(OUTPUT "${header}" "${guids}" + COMMAND "${WIDL_EXECUTABLE}" --win64 -I "${ia2_idl_dir}" -h -o "${header}" "${idl}" + COMMAND "${WIDL_EXECUTABLE}" --win64 -I "${ia2_idl_dir}" -u -o "${guids}" "${idl}" + DEPENDS ${ia2_idl_files} + VERBATIM) + list(APPEND ia2_headers "${header}") + list(APPEND ia2_guids "${guids}") +endforeach() +set(browser_worker "${CMAKE_CURRENT_BINARY_DIR}/wine-access-browser-worker.exe") +add_custom_command(OUTPUT "${browser_worker}" + COMMAND "${MINGW_CXX_COMPILER}" -std=c++20 -O2 -g -Wall -Wextra -municode -static + -I "${ia2_generated_dir}" -o "${browser_worker}" + "${CMAKE_CURRENT_SOURCE_DIR}/browser_worker.cpp" ${ia2_guids} + -loleacc -lole32 -loleaut32 -luuid + DEPENDS browser_worker.cpp ${ia2_headers} ${ia2_guids} + VERBATIM) +add_custom_target(wine-access-browser-worker ALL DEPENDS "${browser_worker}") +set(browser_publisher "${CMAKE_CURRENT_BINARY_DIR}/wine-access-browser-publisher") +add_custom_command(OUTPUT "${browser_publisher}" + COMMAND "${HOST_C_COMPILER}" -std=c11 -O2 -g -Wall -Wextra ${BROWSER_PUBLISHER_CFLAGS} + -o "${browser_publisher}" "${CMAKE_CURRENT_SOURCE_DIR}/browser_publisher.c" + ${BROWSER_PUBLISHER_LDFLAGS} + DEPENDS browser_publisher.c + VERBATIM) +add_custom_target(wine-access-browser-publisher ALL DEPENDS "${browser_publisher}") + set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") set(generated_header "${generated_dir}/nvdaController.h") set(generated_server "${generated_dir}/nvdaController_s.c") @@ -60,8 +105,9 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/nvdaController.idl" VERBATIM) -add_executable(wine-access reader_events.cpp msaa_events.cpp bootstrapper_controls.cpp main.cpp foreground_focus.cpp list_view.cpp native_items.cpp review_capture.cpp review_x11.cpp review_service.cpp "${generated_server}") -add_dependencies(wine-access wine-access-menu wine-access-menu32 wine-access-version) +add_executable(wine-access reader_events.cpp msaa_events.cpp bootstrapper_controls.cpp main.cpp browser_bridge.cpp foreground_focus.cpp list_view.cpp native_items.cpp review_capture.cpp review_x11.cpp review_service.cpp "${generated_server}") +add_dependencies(wine-access wine-access-menu wine-access-menu32 wine-access-version + wine-access-browser-worker wine-access-browser-publisher) target_compile_features(wine-access PRIVATE cxx_std_20) target_include_directories(wine-access PRIVATE "${generated_dir}") target_link_libraries(wine-access PRIVATE @@ -148,6 +194,11 @@ if(BUILD_TESTING) add_dependencies(review-capture-test wine-access-menu wine-access-menu32) add_wine_test(hook-safety 100 python3 "${CMAKE_CURRENT_SOURCE_DIR}/tests/hook_safety_test.py" "${CMAKE_CURRENT_BINARY_DIR}") + # Publishes a recorded Electron snapshot (no Wine needed) on a private + # accessibility bus and compares it with native Chromium's tree. + add_test(NAME browser-publisher-snapshot COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/tests/browser/publisher_snapshot_test.sh" "${browser_publisher}") + set_tests_properties(browser-publisher-snapshot PROPERTIES TIMEOUT 240 RUN_SERIAL TRUE) endif() # Winegcc emits a launcher and a Winelib sidecar. CMake's normal target @@ -155,10 +206,12 @@ endif() # artifacts explicitly and keep them together for Wine to resolve. install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/wine-access.exe" + "${browser_publisher}" DESTINATION "${WINE_ACCESS_INSTALL_DIR}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/wine-access.exe.so" "${menu_hook}" "${menu_hook32}" "${menu_host32}" + "${browser_worker}" DESTINATION "${WINE_ACCESS_INSTALL_DIR}") diff --git a/README.md b/README.md index 1b5dd86..336082b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,11 @@ It provides these capabilities: - NVDA Controller 1, 2, and 3 plus Tolk compatibility for applications using `nvdaControllerClient32.dll`, `nvdaControllerClient64.dll`, or `Tolk.dll`; - a UIA notification bridge for applications whose announcements Wine discards, - including Prism's UIA speech backend. + including Prism's UIA speech backend; +- browser accessibility for Chromium-based windows (Electron, CEF): each page is + published on the accessibility bus like native Linux Chromium, so the + reader's own browser support handles browse mode, structural navigation, + forms, tables and live regions. See [docs/browser.md](docs/browser.md). The compatibility window is hidden and non-activating. It is expected to be invisible; the important endpoint is the local Wine RPC server registered by @@ -72,8 +76,10 @@ Building requires an x86_64 Linux host with: - `pkg-config` and the GLib/GIO development files; - XCB development files for Wine-associated X11 window geometry; - Wine development tools: `winegcc`, `wineg++`, and `widl`; -- `x86_64-w64-mingw32-gcc` and `i686-w64-mingw32-gcc` to build native menu hooks - (`mingw-w64-gcc` on Arch Linux). +- `x86_64-w64-mingw32-gcc`, `x86_64-w64-mingw32-g++` and `i686-w64-mingw32-gcc` + to build native hooks and the browser worker (`mingw-w64-gcc` on Arch Linux); +- ATK, atk-bridge, json-glib and Xlib development files for the browser + publisher (`at-spi2-core`, `json-glib` and `libx11` on Arch Linux). The D-Bus helper is a 64-bit Winelib executable. A small 32-bit Windows companion supplies menu and standard Edit hooks for 32-bit applications, without requiring diff --git a/browser_bridge.cpp b/browser_bridge.cpp new file mode 100644 index 0000000..9e000dc --- /dev/null +++ b/browser_bridge.cpp @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#include "browser_bridge.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace { + +constexpr int MaxFailures = 3; +constexpr ULONGLONG BaseRetryMs = 2000; + +std::string to_utf8(const wchar_t *text) { + if (!text || !*text) return {}; + const int size = WideCharToMultiByte(CP_UTF8, 0, text, -1, nullptr, 0, nullptr, nullptr); + if (size <= 1) return {}; + std::string result(size - 1, '\0'); + WideCharToMultiByte(CP_UTF8, 0, text, -1, result.data(), size, nullptr, nullptr); + return result; +} + +bool has_class(HWND window, const wchar_t *expected) { + wchar_t name[64] = {}; + return GetClassNameW(window, name, 64) > 0 && lstrcmpW(name, expected) == 0; +} + +BOOL CALLBACK find_render_widget(HWND window, LPARAM found) { + if (!has_class(window, L"Chrome_RenderWidgetHostHWND")) return TRUE; + *reinterpret_cast(found) = true; + return FALSE; +} + +// A Chromium top-level window that hosts web content. Popups and windows +// without a renderer (menus, tooltips) stay on the legacy path. +bool is_chromium_content_window(HWND root) { + if (!root || !IsWindowVisible(root) || !has_class(root, L"Chrome_WidgetWin_1")) return false; + bool found = false; + EnumChildWindows(root, find_render_widget, reinterpret_cast(&found)); + return found; +} + +// Unix path of a file next to this helper (Winelib converts the Windows path). +std::string sibling_unix_path(const char *name) { + wchar_t module[4096] = {}; + const DWORD length = GetModuleFileNameW(nullptr, module, std::size(module)); + if (length == 0 || length >= std::size(module)) return {}; + using UnixPath = char *(CDECL *)(LPCWSTR); + auto unixPath = std::bit_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "wine_get_unix_file_name")); + if (!unixPath) return {}; + char *converted = unixPath(module); + if (!converted) return {}; + std::string path = converted; + HeapFree(GetProcessHeap(), 0, converted); + const auto separator = path.rfind('/'); + if (separator == std::string::npos) return {}; + return path.substr(0, separator + 1) + name; +} + +// The Wine loader of this prefix: readers pass WINELOADER; otherwise derive it +// from this process's preloader, so the worker joins the same wineserver. +std::string wine_loader() { + if (const char *configured = getenv("WINELOADER"); configured && *configured) return configured; + char self[4096] = {}; + const ssize_t length = readlink("/proc/self/exe", self, sizeof(self) - 1); + if (length <= 0) return {}; + std::string path(self, static_cast(length)); + const std::string suffix = "-preloader"; + if (path.size() > suffix.size() && path.compare(path.size() - suffix.size(), suffix.size(), suffix) == 0) + path.erase(path.size() - suffix.size()); + return access(path.c_str(), X_OK) == 0 ? path : std::string(); +} + +// Lowercase image name without ".exe", like native application names. +std::string application_name(HWND window) { + DWORD process = 0; + GetWindowThreadProcessId(window, &process); + HANDLE handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process); + wchar_t image[MAX_PATH] = {}; + DWORD size = MAX_PATH; + const bool known = handle && QueryFullProcessImageNameW(handle, 0, image, &size); + if (handle) CloseHandle(handle); + if (!known) return "browser"; + const wchar_t *base = image; + for (const wchar_t *cursor = image; *cursor; ++cursor) + if (*cursor == L'\\' || *cursor == L'/') base = cursor + 1; + std::string name = to_utf8(base); + for (char &c : name) c = static_cast(g_ascii_tolower(c)); + if (name.size() > 4 && name.compare(name.size() - 4, 4, ".exe") == 0) name.erase(name.size() - 4); + return name.empty() ? "browser" : name; +} + +// Runs in the publisher between fork and exec. Readers stop the helper with a +// signal, which ends a Wine process without running its shutdown code, so the +// publisher must follow its parent on its own. The parent's PID is passed +// because it may already have gone before the death signal was armed. +void follow_parent(gpointer parentPid) { + prctl(PR_SET_PDEATHSIG, SIGTERM); + if (getppid() != static_cast(GPOINTER_TO_INT(parentPid))) _exit(0); +} + +} // namespace + +BrowserBridge::~BrowserBridge() { stop(); } + +bool BrowserBridge::start() { + publisherPath_ = sibling_unix_path("wine-access-browser-publisher"); + workerPath_ = sibling_unix_path("wine-access-browser-worker.exe"); + loader_ = wine_loader(); + running_ = !publisherPath_.empty() && access(publisherPath_.c_str(), X_OK) == 0 && !workerPath_.empty() && + access(workerPath_.c_str(), R_OK) == 0 && !loader_.empty(); + if (!running_) + std::fprintf(stderr, "wine-access: browser bridge unavailable (publisher %s, worker %s, Wine loader %s)\n", + publisherPath_.empty() ? "unknown" : publisherPath_.c_str(), + workerPath_.empty() ? "unknown" : workerPath_.c_str(), loader_.empty() ? "unknown" : loader_.c_str()); + return running_; +} + +void BrowserBridge::window_event(HWND window, DWORD event) { + if (!running_) return; + if (event == EVENT_SYSTEM_FOREGROUND || event == EVENT_OBJECT_SHOW || event == EVENT_OBJECT_FOCUS) + consider(window); +} + +void BrowserBridge::consider(HWND window) { + HWND root = window ? GetAncestor(window, GA_ROOT) : nullptr; + if (!root || publishers_.count(root) || !is_chromium_content_window(root)) return; + Attempts &attempts = attempts_[root]; + if (attempts.failures >= MaxFailures || GetTickCount64() < attempts.retryAfter) return; + if (!launch(root)) { + ++attempts.failures; + attempts.retryAfter = GetTickCount64() + (BaseRetryMs << attempts.failures); + } +} + +bool BrowserBridge::launch(HWND window) { + const std::string name = application_name(window); + const std::string handle = std::to_string(static_cast(reinterpret_cast(window))); + std::vector argv = { + const_cast(publisherPath_.c_str()), const_cast("--app-name"), const_cast(name.c_str()), + const_cast("--worker"), const_cast(loader_.c_str()), + const_cast(workerPath_.c_str()), const_cast("--hwnd"), + const_cast(handle.c_str()), nullptr}; + GPid pid = 0; + int output = -1; + GError *error = nullptr; + // stderr is inherited, so publisher and worker diagnostics reach the + // reader's helper log. + if (!g_spawn_async_with_pipes(nullptr, argv.data(), nullptr, G_SPAWN_DO_NOT_REAP_CHILD, follow_parent, + GINT_TO_POINTER(getpid()), &pid, nullptr, &output, nullptr, &error)) { + std::fprintf(stderr, "wine-access: browser publisher for %s did not start: %s\n", name.c_str(), + error ? error->message : "unknown error"); + if (error) g_error_free(error); + return false; + } + g_unix_set_fd_nonblocking(output, TRUE, nullptr); + Publisher publisher; + publisher.pid = pid; + publisher.output = output; + publishers_[window] = publisher; + std::fprintf(stderr, "wine-access: browser publisher started for %s (pid %d)\n", name.c_str(), pid); + return true; +} + +void BrowserBridge::read_output(Publisher &publisher) { + char chunk[256]; + for (;;) { + const ssize_t count = read(publisher.output, chunk, sizeof(chunk)); + if (count <= 0) break; + publisher.buffered.append(chunk, static_cast(count)); + if (publisher.buffered.size() > 4096) publisher.buffered.erase(0, publisher.buffered.size() - 64); + } + if (!publisher.published && publisher.buffered.find("published\n") != std::string::npos) { + publisher.published = true; + std::fprintf(stderr, "wine-access: browser publisher %d published; legacy announcements retired for its window\n", + publisher.pid); + } +} + +void BrowserBridge::poll() { + if (!running_) return; + for (auto entry = publishers_.begin(); entry != publishers_.end();) { + Publisher &publisher = entry->second; + read_output(publisher); + int status = 0; + const pid_t result = waitpid(publisher.pid, &status, WNOHANG); + if (result == 0 || (result < 0 && errno == EINTR)) { + ++entry; + continue; + } + close(publisher.output); + const HWND window = entry->first; + const bool windowAlive = IsWindow(window); + const int code = result > 0 && WIFEXITED(status) ? WEXITSTATUS(status) : -1; + std::fprintf(stderr, "wine-access: browser publisher %d exited (%s %d)%s\n", publisher.pid, + result > 0 && WIFSIGNALED(status) ? "signal" : "status", + result > 0 && WIFSIGNALED(status) ? WTERMSIG(status) : code, + windowAlive ? "; its window returns to legacy announcements" : ""); + if (windowAlive) { + // A publisher should outlive its window; anything else is a failure. + Attempts &attempts = attempts_[window]; + ++attempts.failures; + attempts.retryAfter = GetTickCount64() + (BaseRetryMs << attempts.failures); + if (attempts.failures >= MaxFailures) + std::fprintf(stderr, "wine-access: browser bridge gave up on this window after %d failures\n", + attempts.failures); + } + entry = publishers_.erase(entry); + } + for (auto entry = attempts_.begin(); entry != attempts_.end();) + entry = IsWindow(entry->first) ? std::next(entry) : attempts_.erase(entry); + consider(GetForegroundWindow()); +} + +bool BrowserBridge::owns(HWND window) const { + if (!window) return false; + const auto found = publishers_.find(GetAncestor(window, GA_ROOT)); + return found != publishers_.end() && found->second.published; +} + +void BrowserBridge::stop() { + if (publishers_.empty()) return; + // Publishers close their worker's input as they exit; the worker follows. + for (auto &entry : publishers_) kill(entry.second.pid, SIGTERM); + const ULONGLONG deadline = GetTickCount64() + 2000; + for (auto &entry : publishers_) { + int status = 0; + while (waitpid(entry.second.pid, &status, WNOHANG) == 0) { + if (GetTickCount64() >= deadline) { + kill(entry.second.pid, SIGKILL); + waitpid(entry.second.pid, &status, 0); + break; + } + Sleep(20); + } + close(entry.second.output); + } + publishers_.clear(); +} diff --git a/browser_bridge.h b/browser_bridge.h new file mode 100644 index 0000000..bd0be35 --- /dev/null +++ b/browser_bridge.h @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +#pragma once +#include +#include +#include + +// Starts one wine-access-browser-publisher per Chromium window (Electron, CEF, +// Chrome) and tracks which windows it has published, so legacy announcements +// for those windows can stop. A window stays on the legacy path until its +// publisher reports "published", and returns to it if the publisher exits. +class BrowserBridge { +public: + ~BrowserBridge(); + // Locates the publisher and worker next to the helper and the prefix's Wine + // loader. Returns false when the bridge cannot run; legacy reading continues. + bool start(); + // Call for WinEvents; looks for Chromium windows that need a publisher. + void window_event(HWND window, DWORD event); + // Call regularly: reads publisher readiness, reaps exits, retries failures, + // and checks the foreground window. + void poll(); + // True once the window's publisher has published its tree. + bool owns(HWND window) const; + void stop(); + +private: + struct Publisher { + int pid = 0; + int output = -1; // publisher stdout: "published" once ready + bool published = false; + std::string buffered; + }; + struct Attempts { + int failures = 0; + ULONGLONG retryAfter = 0; + }; + void consider(HWND window); + bool launch(HWND window); + void read_output(Publisher &publisher); + std::map publishers_; + std::map attempts_; + std::string publisherPath_, workerPath_, loader_; + bool running_ = false; +}; diff --git a/browser_publisher.c b/browser_publisher.c new file mode 100644 index 0000000..24adac3 --- /dev/null +++ b/browser_publisher.c @@ -0,0 +1,2544 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// Prototype AT-SPI publisher for Wine Access browser support (milestone 1). +// +// Wine Access browser publisher. +// +// Publishes a Windows Chromium window's accessibility tree on the +// accessibility bus through ATK and atk-bridge, matching what native Linux +// Chromium publishes, so readers use their own browser support. The design, +// mapping rules and verification are in docs/browser.md. +// +// Live mode (started by the wine-access helper): --worker COMMAND... spawns +// wine-access-browser-worker.exe through the prefix's Wine loader and keeps +// the tree current from its messages, forwarding actions, focus, caret, +// selection and scrolling. Once published it prints "published" on stdout so +// the helper can retire legacy announcements for that window. +// Snapshot mode (tests): publishes a recorded wine-access-browser-snapshot-1 +// file, static. +// +// Usage: wine-access-browser-publisher (SNAPSHOT.json | --worker COMMAND...) +// [--app-name NAME] [--active] [--announce] [--quit-after SECONDS] +// --worker must be the last option: everything after it is the command. +// WINE_ACCESS_BROWSER_TRACE=1 logs every worker message to stderr. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// MSAA roles and states used by the mapping (values from oleacc.h). +enum { + MsaaRoleMenuBar = 2, MsaaRoleAlert = 8, MsaaRoleWindow = 9, MsaaRoleClient = 10, MsaaRoleMenuPopup = 11, + MsaaRoleMenuItem = 12, MsaaRoleToolTip = 13, MsaaRoleDocument = 15, MsaaRolePane = 16, MsaaRoleDialog = 18, + MsaaRoleGrouping = 20, MsaaRoleSeparator = 21, MsaaRoleToolBar = 22, MsaaRoleStatusBar = 23, MsaaRoleTable = 24, + MsaaRoleColumnHeader = 25, MsaaRoleRowHeader = 26, MsaaRoleRow = 28, MsaaRoleCell = 29, MsaaRoleLink = 30, + MsaaRoleList = 33, MsaaRoleListItem = 34, MsaaRoleOutline = 35, MsaaRoleOutlineItem = 36, MsaaRolePageTab = 37, + MsaaRoleGraphic = 40, MsaaRoleStaticText = 41, MsaaRoleText = 42, MsaaRolePushButton = 43, + MsaaRoleCheckButton = 44, MsaaRoleRadioButton = 45, MsaaRoleComboBox = 46, MsaaRoleProgressBar = 48, + MsaaRoleSlider = 51, MsaaRoleSpinButton = 52, MsaaRoleButtonMenu = 57, MsaaRolePageTabList = 60, +}; +enum { + MsaaStateUnavailable = 0x1, MsaaStateSelected = 0x2, MsaaStateFocused = 0x4, MsaaStatePressed = 0x8, + MsaaStateChecked = 0x10, MsaaStateReadOnly = 0x40, MsaaStateExpanded = 0x200, MsaaStateCollapsed = 0x400, + MsaaStateBusy = 0x800, MsaaStateInvisible = 0x8000, MsaaStateOffscreen = 0x10000, MsaaStateFocusable = 0x100000, + MsaaStateSelectable = 0x200000, MsaaStateMultiSelectable = 0x1000000, MsaaStateProtected = 0x20000000, +}; +// IA2 roles and states (AccessibleRole.idl, AccessibleStates.idl). +enum { + Ia2RoleCanvas = 0x401, Ia2RoleCaption = 0x402, Ia2RoleEmbeddedObject = 0x40a, Ia2RoleFooter = 0x40e, + Ia2RoleForm = 0x410, Ia2RoleHeader = 0x413, Ia2RoleHeading = 0x414, Ia2RoleInternalFrame = 0x418, + Ia2RoleLabel = 0x419, Ia2RoleNote = 0x41b, Ia2RolePage = 0x41d, Ia2RoleParagraph = 0x41e, Ia2RoleSection = 0x424, + Ia2RoleToggleButton = 0x42a, Ia2RoleComplementary = 0x42c, Ia2RoleLandmark = 0x42d, Ia2RoleBlockQuote = 0x431, + Ia2RoleMark = 0x432, +}; +enum { + Ia2StateDefunct = 0x4, Ia2StateEditable = 0x8, Ia2StateInvalidEntry = 0x40, Ia2StateModal = 0x100, + Ia2StateMultiLine = 0x200, Ia2StateRequired = 0x800, Ia2StateSelectableText = 0x1000, + Ia2StateSingleLine = 0x2000, Ia2StateSupportsAutocompletion = 0x8000, Ia2StateCheckable = 0x40000, +}; + +typedef struct { + long start; // character offsets in the parent's text + long end; + long id; // IA2 uniqueID of the embedded child +} WaLink; + +typedef struct { + char *type; + GArray *targets; // long uniqueIDs +} WaRelation; + +typedef struct WaNode WaNode; +struct WaNode { + long id; + long msaaRole; + long msaaStates; + long ia2Role; + long ia2States; + char *name; + char *description; + char *value; + char *defaultAction; // MSAA default action, used when IA2 Action is absent + gboolean hasLocation; + int x, y, width, height; + GPtrArray *attributeKeys; // parallel arrays, provider order + GPtrArray *attributeValues; + gboolean hasText; + gunichar *characters; + long characterCount; + long caret; // character offset, -1 when none + GArray *boundaries[4]; // per UTF-16 offset: pairs of longs (start, end) from IA2, or NULL + GArray *links; // WaLink + GPtrArray *relations; // WaRelation * + GPtrArray *actions; // char * + gboolean isTable; + long rows, columns; + gboolean isCell; + long row, column, rowSpan, columnSpan; + GArray *columnHeaders; // long uniqueIDs + GArray *rowHeaders; + WaNode *parent; + GPtrArray *children; // WaNode * + AtkRole atkRole; + gboolean isFrame; + gboolean isApplication; + AtkObject *accessible; + AtkHyperlink *hyperlink; + // Live mode only. + gboolean defunct; + long selectionStart, selectionEnd; // characters, -1 when none + GHashTable *boundaryCache[4]; // UTF-16 offset -> packed segment from the worker + gboolean liveExtentsValid; + GArray *characterExtents; // 4 ints per UTF-16 offset, screen coordinates; NULL when unknown +}; + +static GHashTable *nodesById; // long id -> WaNode * +static WaNode *applicationNode; +static WaNode *frameNode; +static gboolean frameActive; +static const char *applicationName = "electron"; +static long syntheticIds = -1000000000L; +static long focusedId; +static gboolean liveMode; +static unsigned long long x11Window; // browser's top-level X11 window, from the worker +static const int requestTimeoutMs = 300; // synchronous worker requests from ATK callbacks + +static gboolean worker_request_async(const char *op, long id, const char *extraFields); +static JsonObject *worker_request_sync_timeout(const char *op, long id, const char *extraFields, int timeoutMs); +static JsonObject *worker_request_sync(const char *op, long id, const char *extraFields); + +// ---------------------------------------------------------------- loading + +static char *dup_member_string(JsonObject *object, const char *member) { + if (!json_object_has_member(object, member)) return NULL; + JsonNode *node = json_object_get_member(object, member); + if (JSON_NODE_HOLDS_NULL(node)) return NULL; + return g_strdup(json_node_get_string(node)); +} + +static long member_long(JsonObject *object, const char *member, long fallback) { + return json_object_has_member(object, member) ? (long)json_object_get_int_member(object, member) : fallback; +} + +static GArray *id_array(JsonArray *array) { + GArray *result = g_array_new(FALSE, FALSE, sizeof(long)); + for (guint i = 0; array && i < json_array_get_length(array); i++) { + long id = (long)json_array_get_int_element(array, i); + g_array_append_val(result, id); + } + return result; +} + +// IA2 object attributes: "key:value;" pairs, with \ escaping : ; = , and \. +static void parse_attributes(WaNode *node, const char *text) { + node->attributeKeys = g_ptr_array_new_with_free_func(g_free); + node->attributeValues = g_ptr_array_new_with_free_func(g_free); + if (!text) return; + GString *key = g_string_new(NULL); + GString *value = g_string_new(NULL); + gboolean inValue = FALSE; + for (const char *cursor = text; *cursor; cursor++) { + char c = *cursor; + if (c == '\\' && cursor[1]) { + cursor++; + g_string_append_c(inValue ? value : key, *cursor); + } else if (c == ':' && !inValue) { + inValue = TRUE; + } else if (c == ';') { + if (key->len) { + g_ptr_array_add(node->attributeKeys, g_strdup(key->str)); + g_ptr_array_add(node->attributeValues, g_strdup(value->str)); + } + g_string_truncate(key, 0); + g_string_truncate(value, 0); + inValue = FALSE; + } else { + g_string_append_c(inValue ? value : key, c); + } + } + if (key->len) { + g_ptr_array_add(node->attributeKeys, g_strdup(key->str)); + g_ptr_array_add(node->attributeValues, g_strdup(value->str)); + } + g_string_free(key, TRUE); + g_string_free(value, TRUE); +} + +static const char *attribute(WaNode *node, const char *key) { + for (guint i = 0; node->attributeKeys && i < node->attributeKeys->len; i++) + if (strcmp(g_ptr_array_index(node->attributeKeys, i), key) == 0) return g_ptr_array_index(node->attributeValues, i); + return NULL; +} + +// Map a UTF-16 offset (Windows/IA2) to a character offset (AT-SPI). Returns +// -1 for an offset inside a surrogate pair or past the end. +static long utf16_to_character(const WaNode *node, long utf16Offset) { + long position = 0; + for (long i = 0; i <= node->characterCount; i++) { + if (position == utf16Offset) return i; + if (position > utf16Offset || i == node->characterCount) break; + position += node->characters[i] > 0xFFFF ? 2 : 1; + } + return -1; +} + +// Map a UTF-16 boundary to a character boundary, rounding an offset that falls +// inside a surrogate pair down (for a start) or up (for an end). Chromium's own +// word boundaries can end mid-pair next to an emoji; native ATK then reports +// end -1, which is a malformed range, so the publisher rounds instead. +static long utf16_boundary_to_character(const WaNode *node, long utf16Offset, gboolean roundUp) { + long position = 0; + for (long i = 0; i <= node->characterCount; i++) { + if (position == utf16Offset) return i; + if (i == node->characterCount) break; + long next = position + (node->characters[i] > 0xFFFF ? 2 : 1); + if (utf16Offset > position && utf16Offset < next) return roundUp ? i + 1 : i; + position = next; + } + return -1; +} + +static long character_to_utf16(const WaNode *node, long characterOffset) { + if (characterOffset < 0 || characterOffset > node->characterCount) return -1; + long position = 0; + for (long i = 0; i < characterOffset; i++) position += node->characters[i] > 0xFFFF ? 2 : 1; + return position; +} + +static long utf16_length(const WaNode *node) { + long length = 0; + for (long i = 0; i < node->characterCount; i++) length += node->characters[i] > 0xFFFF ? 2 : 1; + return length; +} + +// Properties only: identity, tree links and live state are not touched. +static void fill_node(WaNode *node, JsonObject *object) { + node->msaaRole = member_long(object, "msaaRole", 0); + node->msaaStates = member_long(object, "msaaStates", 0); + node->ia2Role = member_long(object, "ia2Role", node->msaaRole); + node->ia2States = member_long(object, "ia2States", 0); + node->name = dup_member_string(object, "name"); + node->description = dup_member_string(object, "description"); + gboolean isProtected = (node->msaaStates & MsaaStateProtected) != 0; + // The probe never records protected values; refuse them here as well. + node->value = isProtected ? NULL : dup_member_string(object, "value"); + node->defaultAction = dup_member_string(object, "defaultAction"); + if (json_object_has_member(object, "location")) { + JsonArray *location = json_object_get_array_member(object, "location"); + node->hasLocation = json_array_get_length(location) == 4; + if (node->hasLocation) { + node->x = (int)json_array_get_int_element(location, 0); + node->y = (int)json_array_get_int_element(location, 1); + node->width = (int)json_array_get_int_element(location, 2); + node->height = (int)json_array_get_int_element(location, 3); + } + } + char *attributes = dup_member_string(object, "attributes"); + parse_attributes(node, attributes); + g_free(attributes); + + node->caret = -1; + long textLength = member_long(object, "textLength", -1); + if (textLength >= 0) { + node->hasText = TRUE; + if (isProtected) { + // Native Chromium presents password text as bullets; publish only the + // length, never the content. + node->characterCount = textLength; + node->characters = g_new(gunichar, textLength + 1); + for (long i = 0; i < textLength; i++) node->characters[i] = 0x2022; + } else { + char *text = dup_member_string(object, "text"); + glong count = 0; + node->characters = g_utf8_to_ucs4(text ? text : "", -1, NULL, &count, NULL); + node->characterCount = count; + if (utf16_length(node) != textLength) + g_warning("node %ld: text is %ld UTF-16 units, provider reported %ld", node->id, utf16_length(node), textLength); + g_free(text); + long caret = member_long(object, "caret", -1); + if (caret >= 0) node->caret = utf16_to_character(node, caret); + // Layout-based boundaries recorded from IA2 get_textAtOffset, in UTF-16 + // offsets, one segment per offset including the end of the text. + static const char *boundaryNames[4] = {"word", "sentence", "line", "paragraph"}; + if (json_object_has_member(object, "boundaries")) { + JsonObject *boundaries = json_object_get_object_member(object, "boundaries"); + for (int b = 0; b < 4; b++) { + if (!json_object_has_member(boundaries, boundaryNames[b])) continue; + JsonArray *segments = json_object_get_array_member(boundaries, boundaryNames[b]); + if ((long)json_array_get_length(segments) != textLength + 1) { + g_warning("node %ld: %s boundaries cover %u offsets, expected %ld; ignored", node->id, boundaryNames[b], + json_array_get_length(segments), textLength + 1); + continue; + } + node->boundaries[b] = g_array_new(FALSE, FALSE, sizeof(long)); + for (guint i = 0; i < json_array_get_length(segments); i++) { + JsonArray *segment = json_array_get_array_element(segments, i); + long pair[2] = {(long)json_array_get_int_element(segment, 0), (long)json_array_get_int_element(segment, 1)}; + g_array_append_vals(node->boundaries[b], pair, 2); + } + } + } + } + } + + node->links = g_array_new(FALSE, FALSE, sizeof(WaLink)); + if (json_object_has_member(object, "hyperlinks")) { + JsonArray *links = json_object_get_array_member(object, "hyperlinks"); + for (guint i = 0; i < json_array_get_length(links); i++) { + JsonNode *element = json_array_get_element(links, i); + if (JSON_NODE_HOLDS_NULL(element)) continue; + JsonArray *entry = json_node_get_array(element); + WaLink link = { + .start = utf16_to_character(node, (long)json_array_get_int_element(entry, 0)), + .end = utf16_to_character(node, (long)json_array_get_int_element(entry, 1)), + .id = (long)json_array_get_int_element(entry, 2), + }; + if (link.start < 0 || link.end < 0) { + g_warning("node %ld: hyperlink %u has an offset outside the text; dropped", node->id, i); + continue; + } + g_array_append_val(node->links, link); + } + } + + node->relations = g_ptr_array_new(); + if (json_object_has_member(object, "relations")) { + JsonArray *relations = json_object_get_array_member(object, "relations"); + for (guint i = 0; i < json_array_get_length(relations); i++) { + JsonObject *entry = json_array_get_object_element(relations, i); + WaRelation *relation = g_new0(WaRelation, 1); + relation->type = dup_member_string(entry, "type"); + relation->targets = id_array(json_object_get_array_member(entry, "targets")); + g_ptr_array_add(node->relations, relation); + } + } + + node->actions = g_ptr_array_new_with_free_func(g_free); + if (json_object_has_member(object, "actions")) { + JsonArray *actions = json_object_get_array_member(object, "actions"); + for (guint i = 0; i < json_array_get_length(actions); i++) { + JsonNode *element = json_array_get_element(actions, i); + g_ptr_array_add(node->actions, g_strdup(JSON_NODE_HOLDS_NULL(element) ? "" : json_node_get_string(element))); + } + } + + if (json_object_has_member(object, "table")) { + JsonObject *table = json_object_get_object_member(object, "table"); + node->isTable = TRUE; + node->rows = member_long(table, "rows", 0); + node->columns = member_long(table, "columns", 0); + } + if (json_object_has_member(object, "cell")) { + JsonObject *cell = json_object_get_object_member(object, "cell"); + node->isCell = TRUE; + node->row = member_long(cell, "row", 0); + node->column = member_long(cell, "column", 0); + node->rowSpan = member_long(cell, "rowSpan", 1); + node->columnSpan = member_long(cell, "columnSpan", 1); + node->columnHeaders = id_array(json_object_has_member(cell, "columnHeaders") + ? json_object_get_array_member(cell, "columnHeaders") : NULL); + node->rowHeaders = id_array(json_object_has_member(cell, "rowHeaders") + ? json_object_get_array_member(cell, "rowHeaders") : NULL); + } + +} + +static WaNode *new_node(JsonObject *object) { + WaNode *node = g_new0(WaNode, 1); + node->id = member_long(object, "id", 0); + if (node->id == 0) node->id = syntheticIds--; + node->selectionStart = node->selectionEnd = -1; + fill_node(node, object); + return node; +} + +static void free_node_properties(WaNode *node) { + g_clear_pointer(&node->name, g_free); + g_clear_pointer(&node->description, g_free); + g_clear_pointer(&node->value, g_free); + g_clear_pointer(&node->defaultAction, g_free); + g_clear_pointer(&node->attributeKeys, g_ptr_array_unref); + g_clear_pointer(&node->attributeValues, g_ptr_array_unref); + g_clear_pointer(&node->characters, g_free); + for (int b = 0; b < 4; b++) g_clear_pointer(&node->boundaries[b], g_array_unref); + g_clear_pointer(&node->links, g_array_unref); + if (node->relations) { + for (guint i = 0; i < node->relations->len; i++) { + WaRelation *relation = g_ptr_array_index(node->relations, i); + g_free(relation->type); + g_array_unref(relation->targets); + g_free(relation); + } + g_clear_pointer(&node->relations, g_ptr_array_unref); + } + g_clear_pointer(&node->actions, g_ptr_array_unref); + g_clear_pointer(&node->columnHeaders, g_array_unref); + g_clear_pointer(&node->rowHeaders, g_array_unref); +} + +static WaNode *node_for_id(long id); + +static WaNode *load_node(JsonObject *object, WaNode *parent) { + WaNode *node = new_node(object); + node->parent = parent; + WaNode *previous = node_for_id(node->id); + if (previous && !previous->defunct) g_warning("duplicate uniqueID %ld", node->id); + g_hash_table_insert(nodesById, &node->id, node); + + node->children = g_ptr_array_new(); + JsonArray *children = json_object_get_array_member(object, "children"); + for (guint i = 0; children && i < json_array_get_length(children); i++) + g_ptr_array_add(node->children, load_node(json_array_get_object_element(children, i), node)); + return node; +} + +static WaNode *node_for_id(long id) { + return g_hash_table_lookup(nodesById, &id); +} + +// "click ancestor" -> "clickAncestor", matching native action names. +static char *camel_case(const char *text) { + GString *result = g_string_new(NULL); + gboolean upperNext = FALSE; + for (const char *cursor = text; *cursor; cursor++) { + if (*cursor == ' ') { + upperNext = result->len > 0; + continue; + } + g_string_append_c(result, upperNext ? g_ascii_toupper(*cursor) : g_ascii_tolower(*cursor)); + upperNext = FALSE; + } + return g_string_free(result, FALSE); +} + +// Objects outside any web document belong to Chromium's views layer (browser +// UI). Windows omits their IA2 actions and adds internal "view_N" ids; native +// Linux Chromium gives them the MSAA default action plus showContextMenu and +// no internal id. Never applied inside web content. +static void adapt_views_node(WaNode *node) { + if (node->actions->len == 0 && !node->isApplication) { + g_ptr_array_add(node->actions, node->defaultAction ? camel_case(node->defaultAction) : g_strdup("doDefault")); + g_ptr_array_add(node->actions, g_strdup("showContextMenu")); + } + for (guint i = 0; i < node->attributeKeys->len; i++) { + const char *value = g_ptr_array_index(node->attributeValues, i); + if (strcmp(g_ptr_array_index(node->attributeKeys, i), "id") == 0 && g_str_has_prefix(value, "view_")) { + g_ptr_array_remove_index(node->attributeKeys, i); + g_ptr_array_remove_index(node->attributeValues, i); + break; + } + } +} + +static void adapt_views_layer(WaNode *node) { + if (node->msaaRole == MsaaRoleDocument) return; + adapt_views_node(node); + for (guint i = 0; i < node->children->len; i++) adapt_views_layer(g_ptr_array_index(node->children, i)); +} + +static gboolean inside_document(WaNode *node) { + for (WaNode *current = node; current; current = current->parent) + if (current->msaaRole == MsaaRoleDocument) return TRUE; + return FALSE; +} + +// Chromium's views layer (browser UI above the web document) answers +// IAccessibleHypertext::get_nHyperlinks with an error, yet its text is one +// embedded-object character per child, and native Chromium exposes those as +// links. Rebuild them only when that shape is exact. +static void synthesize_view_links_node(WaNode *node) { + if (node->links->len == 0 && node->hasText && node->characterCount > 0 && + node->characterCount == (long)node->children->len) { + gboolean allEmbedded = TRUE; + for (long i = 0; i < node->characterCount; i++) + if (node->characters[i] != 0xFFFC) allEmbedded = FALSE; + if (allEmbedded) { + for (guint i = 0; i < node->children->len; i++) { + WaNode *child = g_ptr_array_index(node->children, i); + WaLink link = {.start = i, .end = i + 1, .id = child->id}; + g_array_append_val(node->links, link); + } + } + } +} + +static void synthesize_view_links(WaNode *node) { + synthesize_view_links_node(node); + for (guint i = 0; i < node->children->len; i++) synthesize_view_links(g_ptr_array_index(node->children, i)); +} + +// ---------------------------------------------------------------- mapping + +// Roles follow native Linux Chromium for the same page. Pairings confirmed by +// the fixture comparison are marked "verified"; the rest come from Chromium's +// documented mappings and still need a fixture case. +static AtkRole map_role(WaNode *node) { + const char *xmlRoles = attribute(node, "xml-roles"); + switch (node->ia2Role) { + case Ia2RoleHeading: return ATK_ROLE_HEADING; // verified + case Ia2RoleParagraph: return ATK_ROLE_PARAGRAPH; // verified + case Ia2RoleLabel: return ATK_ROLE_LABEL; // verified + case Ia2RoleCaption: return ATK_ROLE_CAPTION; // verified + case Ia2RoleLandmark: return ATK_ROLE_LANDMARK; // verified (main) + case Ia2RoleSection: // verified (div, form) + return xmlRoles && strcmp(xmlRoles, "form") == 0 ? ATK_ROLE_FORM : ATK_ROLE_SECTION; + case Ia2RoleForm: return ATK_ROLE_FORM; + case Ia2RoleFooter: return ATK_ROLE_FOOTER; + case Ia2RoleHeader: return ATK_ROLE_HEADER; + case Ia2RoleBlockQuote: return ATK_ROLE_BLOCK_QUOTE; + case Ia2RoleMark: return ATK_ROLE_MARK; + case Ia2RoleComplementary: return ATK_ROLE_LANDMARK; + case Ia2RoleEmbeddedObject: return ATK_ROLE_EMBEDDED; + case Ia2RoleInternalFrame: return ATK_ROLE_INTERNAL_FRAME; + case Ia2RoleToggleButton: return ATK_ROLE_TOGGLE_BUTTON; + case Ia2RoleCanvas: return ATK_ROLE_CANVAS; + case Ia2RolePage: return ATK_ROLE_PAGE; + case Ia2RoleNote: return ATK_ROLE_COMMENT; + default: break; + } + switch (node->msaaRole) { + case MsaaRoleDocument: return ATK_ROLE_DOCUMENT_WEB; // verified + case MsaaRolePane: // verified (views) + case MsaaRoleClient: return ATK_ROLE_PANEL; // verified (WebView) + case MsaaRoleMenuBar: return ATK_ROLE_MENU_BAR; // verified + case MsaaRoleButtonMenu: return ATK_ROLE_PUSH_BUTTON; // verified (SubmenuButton) + case MsaaRolePushButton: return ATK_ROLE_PUSH_BUTTON; // verified + case MsaaRoleCheckButton: return ATK_ROLE_CHECK_BOX; // verified + case MsaaRoleLink: return ATK_ROLE_LINK; // verified + case MsaaRoleStaticText: return ATK_ROLE_STATIC; // verified + case MsaaRoleText: // verified + return (node->msaaStates & MsaaStateProtected) ? ATK_ROLE_PASSWORD_TEXT : ATK_ROLE_ENTRY; + case MsaaRoleList: return ATK_ROLE_LIST; // verified + case MsaaRoleListItem: return ATK_ROLE_LIST_ITEM; // verified + case MsaaRoleTable: return ATK_ROLE_TABLE; // verified + case MsaaRoleRow: return ATK_ROLE_TABLE_ROW; // verified + case MsaaRoleColumnHeader: return ATK_ROLE_COLUMN_HEADER; // verified + case MsaaRoleRowHeader: return ATK_ROLE_ROW_HEADER; // verified + case MsaaRoleCell: return ATK_ROLE_TABLE_CELL; // verified + case MsaaRoleRadioButton: return ATK_ROLE_RADIO_BUTTON; + case MsaaRoleComboBox: return ATK_ROLE_COMBO_BOX; + case MsaaRoleMenuPopup: return ATK_ROLE_MENU; + case MsaaRoleMenuItem: return ATK_ROLE_MENU_ITEM; + case MsaaRoleGraphic: return ATK_ROLE_IMAGE; + case MsaaRoleSeparator: return ATK_ROLE_SEPARATOR; + case MsaaRoleToolBar: return ATK_ROLE_TOOL_BAR; + case MsaaRoleStatusBar: return ATK_ROLE_STATUSBAR; + case MsaaRoleDialog: return ATK_ROLE_DIALOG; + case MsaaRoleAlert: return ATK_ROLE_ALERT; + case MsaaRoleToolTip: return ATK_ROLE_TOOL_TIP; + case MsaaRoleWindow: return ATK_ROLE_WINDOW; + case MsaaRoleOutline: return ATK_ROLE_TREE; + case MsaaRoleOutlineItem: return ATK_ROLE_TREE_ITEM; + case MsaaRolePageTab: return ATK_ROLE_PAGE_TAB; + case MsaaRolePageTabList: return ATK_ROLE_PAGE_TAB_LIST; + case MsaaRoleProgressBar: return ATK_ROLE_PROGRESS_BAR; + case MsaaRoleSlider: return ATK_ROLE_SLIDER; + case MsaaRoleSpinButton: return ATK_ROLE_SPIN_BUTTON; + case MsaaRoleGrouping: return ATK_ROLE_PANEL; + default: break; + } + g_warning("node %ld: no AT-SPI role for MSAA role %ld / IA2 role 0x%lx", node->id, node->msaaRole, node->ia2Role); + return ATK_ROLE_UNKNOWN; +} + +static gboolean is_text_field(AtkRole role) { + return role == ATK_ROLE_ENTRY || role == ATK_ROLE_PASSWORD_TEXT; +} + +// Text leaves (DOM text nodes) are static text without an element tag. +// Verified for text nodes and the ::marker pseudo-element;
still needs a +// fixture case. +static gboolean is_text_leaf(WaNode *node) { + return node->msaaRole == MsaaRoleStaticText && !attribute(node, "tag"); +} + +// ---------------------------------------------------------------- GObject types + +enum { + IfaceComponent = 1 << 0, IfaceAction = 1 << 1, IfaceText = 1 << 2, IfaceHypertext = 1 << 3, + IfaceHyperlinkImpl = 1 << 4, IfaceTable = 1 << 5, IfaceTableCell = 1 << 6, IfaceDocument = 1 << 7, + IfaceSelection = 1 << 8, IfaceWindow = 1 << 9, +}; + +typedef struct { + AtkObject parent; + WaNode *node; +} WaAccessible; + +typedef struct { + AtkObjectClass parentClass; +} WaAccessibleClass; + +static WaNode *node_of(gpointer object) { + return ((WaAccessible *)object)->node; +} + +static const gchar *wa_get_name(AtkObject *object) { + WaNode *node = node_of(object); + return node->name ? node->name : ""; +} + +static const gchar *wa_get_description(AtkObject *object) { + WaNode *node = node_of(object); + return node->description ? node->description : ""; +} + +static gint wa_get_n_children(AtkObject *object) { + return (gint)node_of(object)->children->len; +} + +static AtkObject *wa_ref_child(AtkObject *object, gint index) { + WaNode *node = node_of(object); + if (index < 0 || (guint)index >= node->children->len) return NULL; + WaNode *child = g_ptr_array_index(node->children, index); + return g_object_ref(child->accessible); +} + +static gint wa_get_index_in_parent(AtkObject *object) { + WaNode *node = node_of(object); + if (!node->parent) return -1; + for (guint i = 0; i < node->parent->children->len; i++) + if (g_ptr_array_index(node->parent->children, i) == node) return (gint)i; + return -1; +} + +static AtkStateSet *wa_ref_state_set(AtkObject *object) { + WaNode *node = node_of(object); + AtkStateSet *states = atk_state_set_new(); + if (node->defunct) { + atk_state_set_add_state(states, ATK_STATE_DEFUNCT); + return states; + } + long msaa = node->msaaStates, ia2 = node->ia2States; + if (!(msaa & MsaaStateUnavailable)) { + atk_state_set_add_state(states, ATK_STATE_ENABLED); + atk_state_set_add_state(states, ATK_STATE_SENSITIVE); + } + if (!(msaa & MsaaStateInvisible)) atk_state_set_add_state(states, ATK_STATE_VISIBLE); + if (!(msaa & (MsaaStateInvisible | MsaaStateOffscreen))) atk_state_set_add_state(states, ATK_STATE_SHOWING); + if (msaa & MsaaStateFocusable) atk_state_set_add_state(states, ATK_STATE_FOCUSABLE); + // Windows Chromium can report focus on both a views object and the web + // document; AT-SPI needs exactly one, the end of the window's accFocus chain. + if (node->id == focusedId) atk_state_set_add_state(states, ATK_STATE_FOCUSED); + if (msaa & MsaaStateChecked) atk_state_set_add_state(states, ATK_STATE_CHECKED); + if (msaa & MsaaStatePressed) atk_state_set_add_state(states, ATK_STATE_PRESSED); + if (msaa & MsaaStateSelected) atk_state_set_add_state(states, ATK_STATE_SELECTED); + if (msaa & MsaaStateSelectable) atk_state_set_add_state(states, ATK_STATE_SELECTABLE); + if (msaa & MsaaStateExpanded) atk_state_set_add_state(states, ATK_STATE_EXPANDED); + if (msaa & MsaaStateCollapsed) atk_state_set_add_state(states, ATK_STATE_COLLAPSED); + if (msaa & MsaaStateBusy) atk_state_set_add_state(states, ATK_STATE_BUSY); + if (msaa & MsaaStateMultiSelectable) atk_state_set_add_state(states, ATK_STATE_MULTISELECTABLE); + // Windows Chromium marks every non-editable document and list read-only; + // native Linux Chromium only reports it for read-only form fields. + if ((msaa & MsaaStateReadOnly) && is_text_field(node->atkRole)) atk_state_set_add_state(states, ATK_STATE_READ_ONLY); + if (ia2 & Ia2StateEditable) atk_state_set_add_state(states, ATK_STATE_EDITABLE); + if (ia2 & Ia2StateMultiLine) atk_state_set_add_state(states, ATK_STATE_MULTI_LINE); + if (ia2 & Ia2StateSingleLine) atk_state_set_add_state(states, ATK_STATE_SINGLE_LINE); + if (ia2 & Ia2StateSelectableText) atk_state_set_add_state(states, ATK_STATE_SELECTABLE_TEXT); + if (ia2 & Ia2StateRequired) atk_state_set_add_state(states, ATK_STATE_REQUIRED); + if (ia2 & Ia2StateInvalidEntry) atk_state_set_add_state(states, ATK_STATE_INVALID_ENTRY); + if (ia2 & Ia2StateCheckable) atk_state_set_add_state(states, ATK_STATE_CHECKABLE); + if (ia2 & Ia2StateModal) atk_state_set_add_state(states, ATK_STATE_MODAL); + if (ia2 & Ia2StateSupportsAutocompletion) atk_state_set_add_state(states, ATK_STATE_SUPPORTS_AUTOCOMPLETION); + if (ia2 & Ia2StateDefunct) atk_state_set_add_state(states, ATK_STATE_DEFUNCT); + const char *hasPopup = attribute(node, "haspopup"); + if (hasPopup && strcmp(hasPopup, "false") != 0) atk_state_set_add_state(states, ATK_STATE_HAS_POPUP); + if (node->isFrame && frameActive) atk_state_set_add_state(states, ATK_STATE_ACTIVE); + if (node->isApplication) atk_state_set_add_state(states, ATK_STATE_FOCUSABLE); + return states; +} + +static AtkAttributeSet *wa_get_attributes(AtkObject *object) { + WaNode *node = node_of(object); + AtkAttributeSet *set = NULL; + for (guint i = 0; node->attributeKeys && i < node->attributeKeys->len; i++) { + AtkAttribute *entry = g_new(AtkAttribute, 1); + entry->name = g_strdup(g_ptr_array_index(node->attributeKeys, i)); + entry->value = g_strdup(g_ptr_array_index(node->attributeValues, i)); + set = g_slist_append(set, entry); + } + // Lets the reader tie this frame to the browser's X11 window (see the + // Cthulhu ownership rule in browser.md). + if (node->isFrame && x11Window) { + AtkAttribute *entry = g_new(AtkAttribute, 1); + entry->name = g_strdup("wine-access-x11-window"); + entry->value = g_strdup_printf("%llu", x11Window); + set = g_slist_append(set, entry); + } + return set; +} + +static AtkRelationType map_relation(const char *type) { + static const struct { const char *ia2; AtkRelationType atk; } table[] = { + {"labelledBy", ATK_RELATION_LABELLED_BY}, {"labelFor", ATK_RELATION_LABEL_FOR}, + {"describedBy", ATK_RELATION_DESCRIBED_BY}, {"descriptionFor", ATK_RELATION_DESCRIPTION_FOR}, + {"controllerFor", ATK_RELATION_CONTROLLER_FOR}, {"controlledBy", ATK_RELATION_CONTROLLED_BY}, + {"flowsTo", ATK_RELATION_FLOWS_TO}, {"flowsFrom", ATK_RELATION_FLOWS_FROM}, + {"memberOf", ATK_RELATION_MEMBER_OF}, {"nodeChildOf", ATK_RELATION_NODE_CHILD_OF}, + {"nodeParentOf", ATK_RELATION_NODE_PARENT_OF}, {"embeds", ATK_RELATION_EMBEDS}, + {"embeddedBy", ATK_RELATION_EMBEDDED_BY}, {"popupFor", ATK_RELATION_POPUP_FOR}, + {"subwindowOf", ATK_RELATION_SUBWINDOW_OF}, {"details", ATK_RELATION_DETAILS}, + {"detailsFor", ATK_RELATION_DETAILS_FOR}, {"error", ATK_RELATION_ERROR_MESSAGE}, + {"errorFor", ATK_RELATION_ERROR_FOR}, + }; + for (size_t i = 0; type && i < G_N_ELEMENTS(table); i++) + if (strcmp(type, table[i].ia2) == 0) return table[i].atk; + return ATK_RELATION_NULL; +} + +static void add_relation(AtkRelationSet *set, AtkRelationType type, WaNode *target) { + if (target && target->accessible) atk_relation_set_add_relation_by_type(set, type, target->accessible); +} + +static AtkRelationSet *wa_ref_relation_set(AtkObject *object) { + WaNode *node = node_of(object); + AtkRelationSet *set = atk_relation_set_new(); + for (guint i = 0; i < node->relations->len; i++) { + WaRelation *relation = g_ptr_array_index(node->relations, i); + AtkRelationType type = map_relation(relation->type); + if (type == ATK_RELATION_NULL) { + g_warning("node %ld: unmapped relation %s", node->id, relation->type ? relation->type : "(null)"); + continue; + } + for (guint j = 0; j < relation->targets->len; j++) + add_relation(set, type, node_for_id(g_array_index(relation->targets, long, j))); + } + // Native Chromium relates the frame and the top document, which IA2 does + // not report across that boundary. + if (node->isFrame) { + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init(&iter, nodesById); + while (g_hash_table_iter_next(&iter, &key, &value)) { + WaNode *candidate = value; + if (candidate->atkRole == ATK_ROLE_DOCUMENT_WEB) add_relation(set, ATK_RELATION_EMBEDS, candidate); + } + } + if (node->atkRole == ATK_ROLE_DOCUMENT_WEB) add_relation(set, ATK_RELATION_EMBEDDED_BY, frameNode); + return set; +} + +static gpointer accessibleParentClass; + +// Defunct nodes are owned by their accessible from then on: free them when the +// last reference (ours or atk-bridge's) goes away. +static void wa_accessible_finalize(GObject *object) { + WaNode *node = node_of(object); + if (node && node->defunct) { + free_node_properties(node); + g_clear_pointer(&node->children, g_ptr_array_unref); + for (int b = 0; b < 4; b++) g_clear_pointer(&node->boundaryCache[b], g_hash_table_unref); + g_clear_pointer(&node->characterExtents, g_array_unref); + g_free(node); + } + G_OBJECT_CLASS(accessibleParentClass)->finalize(object); +} + +static void wa_accessible_class_init(gpointer klass, gpointer data) { + (void)data; + if (!accessibleParentClass) accessibleParentClass = g_type_class_peek_parent(klass); + G_OBJECT_CLASS(klass)->finalize = wa_accessible_finalize; + AtkObjectClass *objectClass = ATK_OBJECT_CLASS(klass); + objectClass->get_name = wa_get_name; + objectClass->get_description = wa_get_description; + objectClass->get_n_children = wa_get_n_children; + objectClass->ref_child = wa_ref_child; + objectClass->get_index_in_parent = wa_get_index_in_parent; + objectClass->ref_state_set = wa_ref_state_set; + objectClass->get_attributes = wa_get_attributes; + objectClass->ref_relation_set = wa_ref_relation_set; +} + +// ---- AtkComponent + +// The frame's extents must be the browser's X11 window geometry: readers +// compare them with the window manager's view of the foreground window, and +// Wine's client area can differ from it. +static Display *xDisplay; +static gboolean xDisplayTried; + +static int ignore_x_error(Display *display, XErrorEvent *event) { + (void)display; + (void)event; + return 0; // the window may vanish at any time; fall back to Windows geometry +} + +static gboolean x11_window_extents(int *x, int *y, int *width, int *height) { + if (!x11Window) return FALSE; + if (!xDisplayTried) { + xDisplayTried = TRUE; + xDisplay = XOpenDisplay(NULL); + if (xDisplay) XSetErrorHandler(ignore_x_error); + } + if (!xDisplay) return FALSE; + XWindowAttributes attributes; + Window child; + if (!XGetWindowAttributes(xDisplay, (Window)x11Window, &attributes)) return FALSE; + if (!XTranslateCoordinates(xDisplay, (Window)x11Window, attributes.root, 0, 0, x, y, &child)) return FALSE; + *width = attributes.width; + *height = attributes.height; + return *width > 0 && *height > 0; +} + +// Positions change with scrolling and layout; in live mode fetch them on +// demand and keep them until the worker reports a layout change. +static void refresh_live_extents(WaNode *node) { + if (!liveMode || node->defunct || node->isApplication || node->liveExtentsValid) return; + if (node->isFrame && x11_window_extents(&node->x, &node->y, &node->width, &node->height)) { + node->hasLocation = TRUE; + node->liveExtentsValid = TRUE; + return; + } + JsonObject *reply = worker_request_sync("extents", node->id, NULL); + if (!reply) return; + if (json_object_get_boolean_member_with_default(reply, "ok", FALSE) && json_object_has_member(reply, "extents")) { + JsonArray *extents = json_object_get_array_member(reply, "extents"); + if (json_array_get_length(extents) == 4) { + node->x = (int)json_array_get_int_element(extents, 0); + node->y = (int)json_array_get_int_element(extents, 1); + node->width = (int)json_array_get_int_element(extents, 2); + node->height = (int)json_array_get_int_element(extents, 3); + node->hasLocation = TRUE; + node->liveExtentsValid = TRUE; + } + } + json_object_unref(reply); +} + +static void wa_get_extents(AtkComponent *component, gint *x, gint *y, gint *width, gint *height, + AtkCoordType coordType) { + WaNode *node = node_of(component); + refresh_live_extents(node); + if (coordType != ATK_XY_SCREEN && frameNode) refresh_live_extents(frameNode); + if (coordType == ATK_XY_PARENT && node->parent) refresh_live_extents(node->parent); + if (!node->hasLocation) { + *x = *y = *width = *height = -1; + return; + } + *x = node->x; + *y = node->y; + *width = node->width; + *height = node->height; + if (coordType == ATK_XY_WINDOW && frameNode && frameNode->hasLocation) { + *x -= frameNode->x; + *y -= frameNode->y; + } else if (coordType == ATK_XY_PARENT && node->parent && node->parent->hasLocation) { + *x -= node->parent->x; + *y -= node->parent->y; + } +} + +static gboolean wa_component_grab_focus(AtkComponent *component) { + WaNode *node = node_of(component); + if (liveMode && !node->defunct) return worker_request_async("focus", node->id, NULL); + g_message("grab_focus requested for node %ld (snapshot mode)", node->id); + return FALSE; +} + +// ATK and IA2 scroll types have the same values and order. +static gboolean wa_component_scroll_to(AtkComponent *component, AtkScrollType type) { + WaNode *node = node_of(component); + if (!liveMode || node->defunct) return FALSE; + char fields[48]; + snprintf(fields, sizeof(fields), ",\"scrollType\":%d", (int)type); + return worker_request_async("scrollTo", node->id, fields); +} + +static void wa_component_init(gpointer ifacePointer, gpointer data) { + AtkComponentIface *iface = ifacePointer; + (void)data; + iface->get_extents = wa_get_extents; + iface->grab_focus = wa_component_grab_focus; + iface->scroll_to = wa_component_scroll_to; +} + +// ---- AtkAction + +static gint wa_get_n_actions(AtkAction *action) { + return (gint)node_of(action)->actions->len; +} + +static const gchar *wa_action_get_name(AtkAction *action, gint index) { + WaNode *node = node_of(action); + return index >= 0 && (guint)index < node->actions->len ? g_ptr_array_index(node->actions, index) : NULL; +} + +// Actions run asynchronously, as in native Chromium: report acceptance now and +// let the resulting events describe the outcome. +static gboolean wa_do_action(AtkAction *action, gint index) { + WaNode *node = node_of(action); + if (index < 0 || (guint)index >= node->actions->len) return FALSE; + if (liveMode && !node->defunct) { + char fields[32]; + snprintf(fields, sizeof(fields), ",\"index\":%d", index); + return worker_request_async("action", node->id, fields); + } + g_message("do_action %d (%s) requested for node %ld (snapshot mode)", index, wa_action_get_name(action, index), + node->id); + return FALSE; +} + +static void wa_action_init(gpointer ifacePointer, gpointer data) { + AtkActionIface *iface = ifacePointer; + (void)data; + iface->get_n_actions = wa_get_n_actions; + iface->get_name = wa_action_get_name; + iface->get_localized_name = wa_action_get_name; + iface->do_action = wa_do_action; +} + +// ---- AtkText + +static gchar *slice(WaNode *node, long start, long end) { + if (end < 0 || end > node->characterCount) end = node->characterCount; + if (start < 0) start = 0; + if (start > end) start = end; + return g_ucs4_to_utf8(node->characters + start, end - start, NULL, NULL, NULL); +} + +static gchar *wa_get_text(AtkText *text, gint start, gint end) { + return slice(node_of(text), start, end); +} + +static gint wa_get_character_count(AtkText *text) { + return (gint)node_of(text)->characterCount; +} + +static gint wa_get_caret_offset(AtkText *text) { + WaNode *node = node_of(text); + return (gint)MIN(node->caret, node->characterCount); +} + +static gunichar wa_get_character_at_offset(AtkText *text, gint offset) { + WaNode *node = node_of(text); + return offset >= 0 && offset < node->characterCount ? node->characters[offset] : 0; +} + +static gboolean is_space(gunichar c) { + return g_unichar_isspace(c); +} + +// Ask the worker for one IA2 boundary segment, cached per granularity until the +// text changes (and, for lines, until layout changes). Offsets are UTF-16. +static const long ia2BoundaryTypes[4] = {1, 2, 4, 3}; // word, sentence, line, paragraph + +static gboolean live_boundary(WaNode *node, long utf16Offset, int index, long *start16, long *end16) { + if (!liveMode || node->defunct || (node->msaaStates & MsaaStateProtected)) return FALSE; + if (!node->boundaryCache[index]) node->boundaryCache[index] = g_hash_table_new(g_direct_hash, g_direct_equal); + gpointer packed; + if (g_hash_table_lookup_extended(node->boundaryCache[index], GSIZE_TO_POINTER(utf16Offset), NULL, &packed)) { + guint64 value = GPOINTER_TO_SIZE(packed); + *start16 = (long)(gint32)(guint32)(value >> 32) - 1; + *end16 = (long)(gint32)(guint32)(value & 0xffffffffu) - 1; + return TRUE; + } + char fields[80]; + snprintf(fields, sizeof(fields), ",\"offset\":%ld,\"granularity\":%ld", utf16Offset, ia2BoundaryTypes[index]); + JsonObject *reply = worker_request_sync("boundary", node->id, fields); + if (!reply) return FALSE; + gboolean ok = json_object_get_boolean_member_with_default(reply, "ok", FALSE); + if (ok) { + *start16 = (long)json_object_get_int_member_with_default(reply, "start", -1); + *end16 = (long)json_object_get_int_member_with_default(reply, "end", -1); + guint64 value = ((guint64)(guint32)(*start16 + 1) << 32) | (guint32)(*end16 + 1); + g_hash_table_insert(node->boundaryCache[index], GSIZE_TO_POINTER(utf16Offset), GSIZE_TO_POINTER(value)); + } + json_object_unref(reply); + return ok; +} + +static int boundary_index(AtkTextGranularity granularity) { + switch (granularity) { + case ATK_TEXT_GRANULARITY_WORD: return 0; + case ATK_TEXT_GRANULARITY_SENTENCE: return 1; + case ATK_TEXT_GRANULARITY_LINE: return 2; + case ATK_TEXT_GRANULARITY_PARAGRAPH: return 3; + default: return -1; + } +} + +// Word, sentence, line and paragraph boundaries come from the browser's own +// layout through IA2 when recorded; the fallback below is only a +// newline-based approximation for objects without that data. +static gchar *wa_get_string_at_offset(AtkText *text, gint offset, AtkTextGranularity granularity, + gint *startOffset, gint *endOffset) { + WaNode *node = node_of(text); + long count = node->characterCount; + int index = boundary_index(granularity); + // At or past the end of the text native ATK reports no segment for any + // granularity; IA2 may fail there or still report the last line. + if (index >= 0 && (offset < 0 || offset >= count)) { + *startOffset = *endOffset = -1; + return NULL; + } + long utf16Offset = character_to_utf16(node, offset); + long start16 = -1, end16 = -1; + gboolean haveSegment = FALSE; + if (index >= 0 && node->boundaries[index]) { + GArray *segments = node->boundaries[index]; + if (utf16Offset < 0 || (guint)(utf16Offset * 2 + 1) >= segments->len) { + *startOffset = *endOffset = -1; + return NULL; + } + start16 = g_array_index(segments, long, utf16Offset * 2); + end16 = g_array_index(segments, long, utf16Offset * 2 + 1); + haveSegment = TRUE; + } else if (index >= 0 && utf16Offset >= 0 && liveMode && !(node->msaaStates & MsaaStateProtected)) { + haveSegment = live_boundary(node, utf16Offset, index, &start16, &end16); + if (!haveSegment) + g_warning("node %ld: no layout boundary from the browser at offset %d; using an approximation", node->id, + offset); + } + if (haveSegment) { + long start = start16 < 0 ? -1 : utf16_boundary_to_character(node, start16, FALSE); + long end = end16 < 0 ? -1 : utf16_boundary_to_character(node, end16, TRUE); + // At the end of the text native ATK reports no segment for any + // granularity; IA2 still reports the last line there. + if (start < 0 || end < 0 || offset >= count) { + *startOffset = *endOffset = -1; + return NULL; + } + *startOffset = (gint)start; + *endOffset = (gint)end; + return slice(node, start, end); + } + if (offset < 0 || offset > count) { + *startOffset = *endOffset = -1; + return NULL; + } + long start = offset, end = offset; + switch (granularity) { + case ATK_TEXT_GRANULARITY_CHAR: + end = offset < count ? offset + 1 : offset; + break; + case ATK_TEXT_GRANULARITY_WORD: + while (start > 0 && !(is_space(node->characters[start - 1]) && !is_space(node->characters[start]))) start--; + while (end < count && !is_space(node->characters[end])) end++; + while (end < count && is_space(node->characters[end])) end++; + break; + case ATK_TEXT_GRANULARITY_SENTENCE: + while (start > 0 && !(node->characters[start - 1] == '.' || node->characters[start - 1] == '\n')) start--; + while (end < count && node->characters[end] != '.' && node->characters[end] != '\n') end++; + while (end < count && (node->characters[end] == '.' || is_space(node->characters[end]))) end++; + break; + case ATK_TEXT_GRANULARITY_LINE: + case ATK_TEXT_GRANULARITY_PARAGRAPH: + while (start > 0 && node->characters[start - 1] != '\n') start--; + while (end < count && node->characters[end] != '\n') end++; + if (end < count) end++; + break; + default: + *startOffset = *endOffset = -1; + return NULL; + } + *startOffset = (gint)start; + *endOffset = (gint)end; + return slice(node, start, end); +} + +static gboolean forward_text_range(WaNode *node, const char *op, gint start, gint end, int scrollType) { + long start16 = character_to_utf16(node, start), end16 = character_to_utf16(node, end); + if (!liveMode || node->defunct || start16 < 0 || end16 < 0) return FALSE; + char fields[96]; + if (scrollType >= 0) + snprintf(fields, sizeof(fields), ",\"start\":%ld,\"end\":%ld,\"scrollType\":%d", start16, end16, scrollType); + else + snprintf(fields, sizeof(fields), ",\"start\":%ld,\"end\":%ld", start16, end16); + return worker_request_async(op, node->id, fields); +} + +static gboolean wa_set_caret_offset(AtkText *text, gint offset) { + WaNode *node = node_of(text); + long offset16 = character_to_utf16(node, offset); + if (liveMode && !node->defunct && offset16 >= 0) { + char fields[40]; + snprintf(fields, sizeof(fields), ",\"offset\":%ld", offset16); + return worker_request_async("setCaret", node->id, fields); + } + g_message("set_caret_offset %d requested for node %ld (snapshot mode)", offset, node->id); + return FALSE; +} + +static gint wa_get_n_selections(AtkText *text) { + WaNode *node = node_of(text); + return node->selectionStart >= 0 && node->selectionEnd > node->selectionStart ? 1 : 0; +} + +static gchar *wa_get_selection(AtkText *text, gint selectionNumber, gint *startOffset, gint *endOffset) { + WaNode *node = node_of(text); + if (selectionNumber != 0 || wa_get_n_selections(text) == 0) { + *startOffset = *endOffset = 0; + return NULL; + } + *startOffset = (gint)node->selectionStart; + *endOffset = (gint)node->selectionEnd; + return slice(node, node->selectionStart, node->selectionEnd); +} + +static gboolean wa_add_selection(AtkText *text, gint start, gint end) { + return forward_text_range(node_of(text), "setSelection", start, end, -1); +} + +static gboolean wa_set_selection(AtkText *text, gint selectionNumber, gint start, gint end) { + return selectionNumber == 0 && forward_text_range(node_of(text), "setSelection", start, end, -1); +} + +static gboolean wa_remove_selection(AtkText *text, gint selectionNumber) { + WaNode *node = node_of(text); + long caret = MAX(node->caret, 0); + return selectionNumber == 0 && forward_text_range(node, "setSelection", (gint)caret, (gint)caret, -1); +} + +static gboolean wa_scroll_substring_to(AtkText *text, gint start, gint end, AtkScrollType type) { + return forward_text_range(node_of(text), "scrollSubstring", start, end, (int)type); +} + +static AtkAttributeSet *wa_get_run_attributes(AtkText *text, gint offset, gint *startOffset, gint *endOffset) { + WaNode *node = node_of(text); + (void)offset; + *startOffset = 0; + *endOffset = (gint)node->characterCount; + return NULL; +} + +// All of an object's character rectangles in one worker request, cached +// until its text or the layout changes. Returns FALSE when unavailable. +static gboolean ensure_character_extents(WaNode *node) { + if (node->characterExtents) return TRUE; + if (!liveMode || node->defunct || !node->hasText || node->characterCount == 0 || utf16_length(node) > 4096) + return FALSE; + // One IA2 call per character in the worker: allow time in proportion. + int timeoutMs = (int)MIN(3000, requestTimeoutMs + utf16_length(node) * 2); + JsonObject *reply = worker_request_sync_timeout("characterExtentsAll", node->id, NULL, timeoutMs); + gboolean ok = reply && json_object_get_boolean_member_with_default(reply, "ok", FALSE) && + json_object_has_member(reply, "extents"); + if (ok) { + JsonArray *rectangles = json_object_get_array_member(reply, "extents"); + guint count = json_array_get_length(rectangles); + ok = (long)count == utf16_length(node); + if (ok) { + node->characterExtents = g_array_sized_new(FALSE, FALSE, sizeof(int), count * 4); + for (guint i = 0; i < count; i++) { + JsonArray *rectangle = json_array_get_array_element(rectangles, i); + for (guint j = 0; j < 4; j++) { + int value = (int)json_array_get_int_element(rectangle, j); + g_array_append_val(node->characterExtents, value); + } + } + } + } + if (reply) json_object_unref(reply); + return ok; +} + +// Screen rectangle of one character, from the cache. +static gboolean cached_character_rectangle(WaNode *node, gint offset, int *rectangle) { + long offset16 = character_to_utf16(node, offset); + if (offset16 < 0 || offset >= node->characterCount || !ensure_character_extents(node)) return FALSE; + for (int j = 0; j < 4; j++) rectangle[j] = g_array_index(node->characterExtents, int, offset16 * 4 + j); + return TRUE; +} + +static void to_coordinate_type(WaNode *node, gint *x, gint *y, AtkCoordType coordType) { + if (coordType == ATK_XY_SCREEN) return; + WaNode *origin = coordType == ATK_XY_PARENT ? node->parent : frameNode; + if (!origin) return; + refresh_live_extents(origin); + *x -= origin->x; + *y -= origin->y; +} + +// Native Chromium answers range extents itself; ATK's default would ask for +// every character separately, which here means one worker round trip each. +static void wa_get_range_extents(AtkText *text, gint start, gint end, AtkCoordType coordType, + AtkTextRectangle *rectangle) { + WaNode *node = node_of(text); + rectangle->x = rectangle->y = rectangle->width = rectangle->height = 0; + if (end < 0 || end > node->characterCount) end = (gint)node->characterCount; + int left = G_MAXINT, top = G_MAXINT, right = G_MININT, bottom = G_MININT; + for (gint offset = MAX(start, 0); offset < end; offset++) { + int character[4]; + if (!cached_character_rectangle(node, offset, character)) break; + if (character[2] <= 0 && character[3] <= 0) continue; + left = MIN(left, character[0]); + top = MIN(top, character[1]); + right = MAX(right, character[0] + character[2]); + bottom = MAX(bottom, character[1] + character[3]); + } + if (left > right || top > bottom) return; + rectangle->x = left; + rectangle->y = top; + rectangle->width = right - left; + rectangle->height = bottom - top; + to_coordinate_type(node, &rectangle->x, &rectangle->y, coordType); +} + +static void wa_get_character_extents(AtkText *text, gint offset, gint *x, gint *y, gint *width, gint *height, + AtkCoordType coordType) { + WaNode *node = node_of(text); + int character[4]; + if (cached_character_rectangle(node, offset, character)) { + *x = character[0]; + *y = character[1]; + *width = character[2]; + *height = character[3]; + to_coordinate_type(node, x, y, coordType); + return; + } + long offset16 = character_to_utf16(node, offset); + if (liveMode && !node->defunct && offset16 >= 0) { + char fields[40]; + snprintf(fields, sizeof(fields), ",\"offset\":%ld", offset16); + JsonObject *reply = worker_request_sync("characterExtents", node->id, fields); + gboolean ok = reply && json_object_get_boolean_member_with_default(reply, "ok", FALSE) && + json_object_has_member(reply, "extents"); + if (ok) { + JsonArray *extents = json_object_get_array_member(reply, "extents"); + *x = (gint)json_array_get_int_element(extents, 0); + *y = (gint)json_array_get_int_element(extents, 1); + *width = (gint)json_array_get_int_element(extents, 2); + *height = (gint)json_array_get_int_element(extents, 3); + if (coordType != ATK_XY_SCREEN && frameNode) { + refresh_live_extents(frameNode); + *x -= frameNode->x; + *y -= frameNode->y; + } + } + if (reply) json_object_unref(reply); + if (ok) return; + } + wa_get_extents(ATK_COMPONENT(text), x, y, width, height, coordType); +} + +static void wa_text_init(gpointer ifacePointer, gpointer data) { + AtkTextIface *iface = ifacePointer; + (void)data; + iface->get_text = wa_get_text; + iface->get_character_count = wa_get_character_count; + iface->get_caret_offset = wa_get_caret_offset; + iface->set_caret_offset = wa_set_caret_offset; + iface->get_character_at_offset = wa_get_character_at_offset; + iface->get_string_at_offset = wa_get_string_at_offset; + iface->get_n_selections = wa_get_n_selections; + iface->get_selection = wa_get_selection; + iface->add_selection = wa_add_selection; + iface->set_selection = wa_set_selection; + iface->remove_selection = wa_remove_selection; + iface->scroll_substring_to = wa_scroll_substring_to; + iface->get_run_attributes = wa_get_run_attributes; + iface->get_character_extents = wa_get_character_extents; + iface->get_range_extents = wa_get_range_extents; +} + +// ---- AtkHyperlink (one per embedded child) and AtkHypertext + +// Holds a reference to its target accessible so a hyperlink that atk-bridge +// still exports never points at freed memory. The node drops its reference to +// the hyperlink when it becomes defunct, breaking the cycle. +typedef struct { + AtkHyperlink parent; + AtkObject *accessible; +} WaHyperlink; + +typedef struct { + AtkHyperlinkClass parentClass; +} WaHyperlinkClass; + +G_DEFINE_TYPE(WaHyperlink, wa_hyperlink, ATK_TYPE_HYPERLINK) + +static WaNode *hyperlink_node(AtkHyperlink *hyperlink) { + return node_of(((WaHyperlink *)hyperlink)->accessible); +} + +static const WaLink *link_entry(WaNode *node) { + if (!node->parent) return NULL; + for (guint i = 0; i < node->parent->links->len; i++) { + const WaLink *link = &g_array_index(node->parent->links, WaLink, i); + if (link->id == node->id) return link; + } + return NULL; +} + +static gint wa_hyperlink_get_start_index(AtkHyperlink *hyperlink) { + const WaLink *link = link_entry(hyperlink_node(hyperlink)); + return link ? (gint)link->start : -1; +} + +static gint wa_hyperlink_get_end_index(AtkHyperlink *hyperlink) { + const WaLink *link = link_entry(hyperlink_node(hyperlink)); + return link ? (gint)link->end : -1; +} + +static AtkObject *wa_hyperlink_get_object(AtkHyperlink *hyperlink, gint index) { + return index == 0 ? ((WaHyperlink *)hyperlink)->accessible : NULL; +} + +static gchar *wa_hyperlink_get_uri(AtkHyperlink *hyperlink, gint index) { + WaNode *node = hyperlink_node(hyperlink); + return index == 0 && node->atkRole == ATK_ROLE_LINK && node->value ? g_strdup(node->value) : NULL; +} + +static gint wa_hyperlink_get_n_anchors(AtkHyperlink *hyperlink) { + (void)hyperlink; + return 1; +} + +static gboolean wa_hyperlink_is_valid(AtkHyperlink *hyperlink) { + return !hyperlink_node(hyperlink)->defunct; +} + +static void wa_hyperlink_finalize(GObject *object) { + g_clear_object(&((WaHyperlink *)object)->accessible); + G_OBJECT_CLASS(wa_hyperlink_parent_class)->finalize(object); +} + +static void wa_hyperlink_class_init(WaHyperlinkClass *klass) { + G_OBJECT_CLASS(klass)->finalize = wa_hyperlink_finalize; + AtkHyperlinkClass *hyperlinkClass = ATK_HYPERLINK_CLASS(klass); + hyperlinkClass->get_start_index = wa_hyperlink_get_start_index; + hyperlinkClass->get_end_index = wa_hyperlink_get_end_index; + hyperlinkClass->get_object = wa_hyperlink_get_object; + hyperlinkClass->get_uri = wa_hyperlink_get_uri; + hyperlinkClass->get_n_anchors = wa_hyperlink_get_n_anchors; + hyperlinkClass->is_valid = wa_hyperlink_is_valid; +} + +static void wa_hyperlink_init(WaHyperlink *hyperlink) { + (void)hyperlink; +} + +static AtkHyperlink *wa_get_hyperlink(AtkHyperlinkImpl *impl) { + WaNode *node = node_of(impl); + if (!node->hyperlink) { + WaHyperlink *hyperlink = g_object_new(wa_hyperlink_get_type(), NULL); + hyperlink->accessible = g_object_ref(node->accessible); + node->hyperlink = ATK_HYPERLINK(hyperlink); + } + return g_object_ref(node->hyperlink); +} + +static void wa_hyperlink_impl_init(gpointer ifacePointer, gpointer data) { + AtkHyperlinkImplIface *iface = ifacePointer; + (void)data; + iface->get_hyperlink = wa_get_hyperlink; +} + +static gint wa_get_n_links(AtkHypertext *hypertext) { + return (gint)node_of(hypertext)->links->len; +} + +static AtkHyperlink *wa_get_link(AtkHypertext *hypertext, gint index) { + WaNode *node = node_of(hypertext); + if (index < 0 || (guint)index >= node->links->len) return NULL; + WaNode *child = node_for_id(g_array_index(node->links, WaLink, index).id); + if (!child || !ATK_IS_HYPERLINK_IMPL(child->accessible)) return NULL; + AtkHyperlink *hyperlink = atk_hyperlink_impl_get_hyperlink(ATK_HYPERLINK_IMPL(child->accessible)); + g_object_unref(hyperlink); // the child keeps its own reference; get_link is transfer none + return hyperlink; +} + +static gint wa_get_link_index(AtkHypertext *hypertext, gint characterOffset) { + WaNode *node = node_of(hypertext); + for (guint i = 0; i < node->links->len; i++) { + const WaLink *link = &g_array_index(node->links, WaLink, i); + if (characterOffset >= link->start && characterOffset < link->end) return (gint)i; + } + return -1; +} + +static void wa_hypertext_init(gpointer ifacePointer, gpointer data) { + AtkHypertextIface *iface = ifacePointer; + (void)data; + iface->get_n_links = wa_get_n_links; + iface->get_link = wa_get_link; + iface->get_link_index = wa_get_link_index; +} + +// ---- AtkTable and AtkTableCell + +static WaNode *find_cell(WaNode *node, long row, long column) { + if (node->isCell && row >= node->row && row < node->row + node->rowSpan && column >= node->column && + column < node->column + node->columnSpan) + return node; + for (guint i = 0; i < node->children->len; i++) { + WaNode *child = g_ptr_array_index(node->children, i); + if (child->isTable) continue; // do not descend into nested tables + WaNode *found = find_cell(child, row, column); + if (found) return found; + } + return NULL; +} + +static AtkObject *wa_table_ref_at(AtkTable *table, gint row, gint column) { + WaNode *cell = find_cell(node_of(table), row, column); + return cell ? g_object_ref(cell->accessible) : NULL; +} + +static gint wa_table_get_n_rows(AtkTable *table) { + return (gint)node_of(table)->rows; +} + +static gint wa_table_get_n_columns(AtkTable *table) { + return (gint)node_of(table)->columns; +} + +static AtkObject *wa_table_get_caption(AtkTable *table) { + WaNode *node = node_of(table); + for (guint i = 0; i < node->children->len; i++) { + WaNode *child = g_ptr_array_index(node->children, i); + if (child->atkRole == ATK_ROLE_CAPTION) return child->accessible; + } + return NULL; +} + +static void wa_table_init(gpointer ifacePointer, gpointer data) { + AtkTableIface *iface = ifacePointer; + (void)data; + iface->ref_at = wa_table_ref_at; + iface->get_n_rows = wa_table_get_n_rows; + iface->get_n_columns = wa_table_get_n_columns; + iface->get_caption = wa_table_get_caption; +} + +// Native Chromium reports no header cells for a header cell; IA2 lists the +// header cell itself or its column header. Verified with th scope=col/row. +static GPtrArray *header_cells(WaNode *node, GArray *ids) { + GPtrArray *result = g_ptr_array_new_with_free_func(g_object_unref); + if (node->atkRole == ATK_ROLE_COLUMN_HEADER || node->atkRole == ATK_ROLE_ROW_HEADER) return result; + for (guint i = 0; ids && i < ids->len; i++) { + WaNode *header = node_for_id(g_array_index(ids, long, i)); + if (header && header != node && header->accessible) g_ptr_array_add(result, g_object_ref(header->accessible)); + } + return result; +} + +static GPtrArray *wa_cell_get_column_header_cells(AtkTableCell *cell) { + WaNode *node = node_of(cell); + return header_cells(node, node->columnHeaders); +} + +static GPtrArray *wa_cell_get_row_header_cells(AtkTableCell *cell) { + WaNode *node = node_of(cell); + return header_cells(node, node->rowHeaders); +} + +static gint wa_cell_get_column_span(AtkTableCell *cell) { + return (gint)node_of(cell)->columnSpan; +} + +static gint wa_cell_get_row_span(AtkTableCell *cell) { + return (gint)node_of(cell)->rowSpan; +} + +static gboolean wa_cell_get_position(AtkTableCell *cell, gint *row, gint *column) { + WaNode *node = node_of(cell); + *row = (gint)node->row; + *column = (gint)node->column; + return TRUE; +} + +static gboolean wa_cell_get_row_column_span(AtkTableCell *cell, gint *row, gint *column, gint *rowSpan, + gint *columnSpan) { + WaNode *node = node_of(cell); + *row = (gint)node->row; + *column = (gint)node->column; + *rowSpan = (gint)node->rowSpan; + *columnSpan = (gint)node->columnSpan; + return TRUE; +} + +static AtkObject *wa_cell_get_table(AtkTableCell *cell) { + for (WaNode *node = node_of(cell)->parent; node; node = node->parent) + if (node->isTable) return g_object_ref(node->accessible); + return NULL; +} + +static void wa_table_cell_init(gpointer ifacePointer, gpointer data) { + AtkTableCellIface *iface = ifacePointer; + (void)data; + iface->get_column_header_cells = wa_cell_get_column_header_cells; + iface->get_row_header_cells = wa_cell_get_row_header_cells; + iface->get_column_span = wa_cell_get_column_span; + iface->get_row_span = wa_cell_get_row_span; + iface->get_position = wa_cell_get_position; + iface->get_row_column_span = wa_cell_get_row_column_span; + iface->get_table = wa_cell_get_table; +} + +// ---- AtkSelection (selection containers; changes need the backend) + +static WaNode *selected_child(WaNode *node, gint index) { + gint seen = 0; + for (guint i = 0; i < node->children->len; i++) { + WaNode *child = g_ptr_array_index(node->children, i); + if ((child->msaaStates & MsaaStateSelected) && seen++ == index) return child; + } + return NULL; +} + +static gint wa_get_selection_count(AtkSelection *selection) { + WaNode *node = node_of(selection); + gint count = 0; + for (guint i = 0; i < node->children->len; i++) + if (((WaNode *)g_ptr_array_index(node->children, i))->msaaStates & MsaaStateSelected) count++; + return count; +} + +static AtkObject *wa_ref_selection(AtkSelection *selection, gint index) { + WaNode *child = selected_child(node_of(selection), index); + return child ? g_object_ref(child->accessible) : NULL; +} + +static gboolean wa_is_child_selected(AtkSelection *selection, gint index) { + WaNode *node = node_of(selection); + if (index < 0 || (guint)index >= node->children->len) return FALSE; + return (((WaNode *)g_ptr_array_index(node->children, index))->msaaStates & MsaaStateSelected) != 0; +} + +static gboolean wa_selection_change(AtkSelection *selection, gint index) { + g_message("selection change at %d requested for node %ld (no backend in prototype)", index, + node_of(selection)->id); + return FALSE; +} + +static gboolean wa_selection_clear(AtkSelection *selection) { + return wa_selection_change(selection, -1); +} + +static void wa_selection_init(gpointer ifacePointer, gpointer data) { + AtkSelectionIface *iface = ifacePointer; + (void)data; + iface->get_selection_count = wa_get_selection_count; + iface->ref_selection = wa_ref_selection; + iface->is_child_selected = wa_is_child_selected; + iface->add_selection = wa_selection_change; + iface->remove_selection = wa_selection_change; + iface->clear_selection = wa_selection_clear; + iface->select_all_selection = wa_selection_clear; +} + +// ---- AtkWindow: no methods; its activate/deactivate signals become the +// window:activate and window:deactivate events readers use. + +static void wa_window_init(gpointer ifacePointer, gpointer data) { + (void)ifacePointer; + (void)data; +} + +// ---- AtkDocument + +static const gchar *wa_document_get_locale(AtkDocument *document) { + (void)document; + return ""; +} + +static void wa_document_init(gpointer ifacePointer, gpointer data) { + AtkDocumentIface *iface = ifacePointer; + (void)data; + iface->get_document_locale = wa_document_get_locale; +} + +// One GType per interface combination, registered on first use. +static GType type_for_mask(guint mask) { + static GHashTable *types; + if (!types) types = g_hash_table_new(g_direct_hash, g_direct_equal); + gpointer cached = g_hash_table_lookup(types, GUINT_TO_POINTER(mask + 1)); + if (cached) return (GType)GPOINTER_TO_SIZE(cached); + GTypeInfo info = { + .class_size = sizeof(WaAccessibleClass), + .class_init = wa_accessible_class_init, + .instance_size = sizeof(WaAccessible), + }; + char typeName[64]; + snprintf(typeName, sizeof(typeName), "WaAccessible%u", mask); + GType type = g_type_register_static(ATK_TYPE_OBJECT, typeName, &info, 0); + static const struct { + guint flag; + GType (*type)(void); + GInterfaceInitFunc init; + } interfaces[] = { + {IfaceComponent, atk_component_get_type, wa_component_init}, + {IfaceAction, atk_action_get_type, wa_action_init}, + {IfaceText, atk_text_get_type, wa_text_init}, + {IfaceHypertext, atk_hypertext_get_type, wa_hypertext_init}, + {IfaceHyperlinkImpl, atk_hyperlink_impl_get_type, wa_hyperlink_impl_init}, + {IfaceTable, atk_table_get_type, wa_table_init}, + {IfaceTableCell, atk_table_cell_get_type, wa_table_cell_init}, + {IfaceDocument, atk_document_get_type, wa_document_init}, + {IfaceSelection, atk_selection_get_type, wa_selection_init}, + {IfaceWindow, atk_window_get_type, wa_window_init}, + }; + for (size_t i = 0; i < G_N_ELEMENTS(interfaces); i++) { + if (!(mask & interfaces[i].flag)) continue; + GInterfaceInfo interfaceInfo = {.interface_init = interfaces[i].init}; + g_type_add_interface_static(type, interfaces[i].type(), &interfaceInfo); + } + g_hash_table_insert(types, GUINT_TO_POINTER(mask + 1), GSIZE_TO_POINTER(type)); + return type; +} + +// Interface sets follow native Chromium: every object has Action, Component, +// Document and Text; text fields lack Hypertext; everything except text +// leaves is a hyperlink implementation. +static guint interface_mask(WaNode *node) { + guint mask = IfaceComponent | IfaceAction | IfaceText | IfaceDocument; + if (!is_text_field(node->atkRole)) mask |= IfaceHypertext; + if (!is_text_leaf(node)) mask |= IfaceHyperlinkImpl; + if (node->isTable) mask |= IfaceTable; + if (node->isCell) mask |= IfaceTableCell; + if (node->isFrame) mask |= IfaceWindow; + // Selection containers; the menu bar is verified, the rest follow Chromium. + switch (node->atkRole) { + case ATK_ROLE_MENU_BAR: case ATK_ROLE_MENU: case ATK_ROLE_LIST_BOX: case ATK_ROLE_PAGE_TAB_LIST: + case ATK_ROLE_TREE: case ATK_ROLE_TREE_TABLE: + mask |= IfaceSelection; + break; + default: + break; + } + return mask; +} + +static void create_accessibles(WaNode *node) { + if (!node->atkRole) node->atkRole = map_role(node); + WaAccessible *accessible = g_object_new(type_for_mask(interface_mask(node)), NULL); + accessible->node = node; + node->accessible = ATK_OBJECT(accessible); + atk_object_set_role(node->accessible, node->atkRole); + if (node->parent) atk_object_set_parent(node->accessible, node->parent->accessible); + for (guint i = 0; i < node->children->len; i++) create_accessibles(g_ptr_array_index(node->children, i)); +} + +// ---------------------------------------------------------------- AtkUtil + +static AtkObject *wa_util_get_root(void) { + return applicationNode ? applicationNode->accessible : NULL; +} + +static const gchar *wa_util_get_toolkit_name(void) { + return "Chromium"; +} + +static const gchar *wa_util_get_toolkit_version(void) { + return "1.0"; +} + +static void install_util(void) { + AtkUtilClass *utilClass = ATK_UTIL_CLASS(g_type_class_ref(ATK_TYPE_UTIL)); + utilClass->get_root = wa_util_get_root; + utilClass->get_toolkit_name = wa_util_get_toolkit_name; + utilClass->get_toolkit_version = wa_util_get_toolkit_version; +} + +// ---------------------------------------------------------------- live mode: worker connection + +static GPid workerPid; +static int workerInput = -1; +static int workerOutput = -1; +static GString *workerBuffer; +static GQueue *pendingMessages; // JsonObject *, received while answering a synchronous request +static gboolean workerClosed; +static long nextRequestId = 1; +static guint pendingIdleSource; +static GMainLoop *mainLoop; +static int exitStatus; +static const gsize maxBufferedBytes = 256u << 20; + +static void handle_message(JsonObject *message); + +static void write_worker(const char *line) { + if (workerInput < 0) return; + GString *data = g_string_new(line); + g_string_append_c(data, '\n'); + gsize written = 0; + while (written < data->len) { + ssize_t result = write(workerInput, data->str + written, data->len - written); + if (result < 0 && errno == EINTR) continue; + if (result <= 0) { + g_warning("worker input closed: %s", g_strerror(errno)); + close(workerInput); + workerInput = -1; + break; + } + written += (gsize)result; + } + g_string_free(data, TRUE); +} + +// Read whatever the worker has sent, waiting at most timeoutMs. +static void read_worker(int timeoutMs) { + if (workerOutput < 0 || workerClosed) return; + struct pollfd descriptor = {.fd = workerOutput, .events = POLLIN}; + if (poll(&descriptor, 1, timeoutMs) <= 0) return; + char chunk[65536]; + ssize_t count = read(workerOutput, chunk, sizeof(chunk)); + if (count > 0) { + g_string_append_len(workerBuffer, chunk, count); + if (workerBuffer->len > maxBufferedBytes) { + g_warning("worker sent an oversized message; disconnecting"); + workerClosed = TRUE; + } + } else if (count == 0 || (errno != EINTR && errno != EAGAIN)) { + workerClosed = TRUE; + } +} + +static JsonObject *parse_line(const char *line) { + JsonParser *parser = json_parser_new(); + JsonObject *object = NULL; + if (json_parser_load_from_data(parser, line, -1, NULL)) { + JsonNode *root = json_parser_get_root(parser); + if (root && JSON_NODE_HOLDS_OBJECT(root)) object = json_object_ref(json_node_get_object(root)); + } + if (!object) g_warning("ignored a malformed worker message"); + g_object_unref(parser); + return object; +} + +static JsonObject *take_message(void) { + for (;;) { + char *newline = memchr(workerBuffer->str, '\n', workerBuffer->len); + if (!newline) return NULL; + gsize length = (gsize)(newline - workerBuffer->str); + char *line = g_strndup(workerBuffer->str, length); + g_string_erase(workerBuffer, 0, (gssize)length + 1); + JsonObject *object = parse_line(line); + g_free(line); + if (object) return object; + } +} + +static gboolean process_pending(gpointer data) { + (void)data; + pendingIdleSource = 0; + JsonObject *message; + while ((message = g_queue_pop_head(pendingMessages))) { + handle_message(message); + json_object_unref(message); + } + return G_SOURCE_REMOVE; +} + +static void queue_pending(JsonObject *message) { + g_queue_push_tail(pendingMessages, message); + if (!pendingIdleSource) pendingIdleSource = g_idle_add(process_pending, NULL); +} + +static long send_request(const char *op, long id, const char *extraFields) { + long requestId = nextRequestId++; + char *line = g_strdup_printf("{\"type\":\"request\",\"requestId\":%ld,\"op\":\"%s\",\"id\":%ld%s}", requestId, op, + id, extraFields ? extraFields : ""); + write_worker(line); + g_free(line); + return requestId; +} + +static gboolean worker_request_async(const char *op, long id, const char *extraFields) { + if (workerInput < 0 || workerClosed) return FALSE; + send_request(op, id, extraFields); + return TRUE; +} + +// Called from ATK callbacks, which must answer synchronously. Waits a bounded +// time for the reply; every other message is queued and applied later from +// the main loop, so the tree never changes under the caller. +// Synchronous request statistics, logged every few seconds while requests +// happen, so live tests show where reader queries spend their time. +typedef struct { + guint count; + guint timeouts; + double totalMs; + double maxMs; +} WaRequestStats; + +static GHashTable *requestStats; // op name -> WaRequestStats * +static guint statsSource; + +static gboolean log_request_stats(gpointer data) { + (void)data; + statsSource = 0; + GString *summary = g_string_new("synchronous requests in the last 3 s:"); + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init(&iter, requestStats); + while (g_hash_table_iter_next(&iter, &key, &value)) { + WaRequestStats *stats = value; + g_string_append_printf(summary, " %s n=%u avg=%.1fms max=%.1fms", (const char *)key, stats->count, + stats->totalMs / stats->count, stats->maxMs); + if (stats->timeouts) g_string_append_printf(summary, " timeouts=%u", stats->timeouts); + } + g_message("%s", summary->str); + g_string_free(summary, TRUE); + g_hash_table_remove_all(requestStats); + return G_SOURCE_REMOVE; +} + +static void record_request(const char *op, double elapsedMs, gboolean timedOut) { + if (!requestStats) requestStats = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + WaRequestStats *stats = g_hash_table_lookup(requestStats, op); + if (!stats) { + stats = g_new0(WaRequestStats, 1); + g_hash_table_insert(requestStats, g_strdup(op), stats); + } + stats->count++; + stats->totalMs += elapsedMs; + stats->maxMs = MAX(stats->maxMs, elapsedMs); + if (timedOut) stats->timeouts++; + if (!statsSource) statsSource = g_timeout_add_seconds(3, log_request_stats, NULL); +} + +static JsonObject *worker_request_sync_timeout(const char *op, long id, const char *extraFields, int timeoutMs) { + if (workerInput < 0 || workerClosed) return NULL; + gint64 startUs = g_get_monotonic_time(); + long requestId = send_request(op, id, extraFields); + gint64 deadline = g_get_monotonic_time() + (gint64)timeoutMs * 1000; + for (;;) { + JsonObject *message; + while ((message = take_message())) { + if (g_strcmp0(json_object_get_string_member_with_default(message, "type", ""), "reply") == 0 && + json_object_get_int_member_with_default(message, "requestId", 0) == requestId) { + record_request(op, (g_get_monotonic_time() - startUs) / 1000.0, FALSE); + return message; + } + queue_pending(message); + } + gint64 remainingMs = (deadline - g_get_monotonic_time()) / 1000; + if (remainingMs <= 0 || workerClosed) break; + read_worker((int)remainingMs); + } + g_warning("worker request %ld (%s on %ld) got no reply within %d ms", requestId, op, id, timeoutMs); + record_request(op, (g_get_monotonic_time() - startUs) / 1000.0, TRUE); + return NULL; +} + +static JsonObject *worker_request_sync(const char *op, long id, const char *extraFields) { + return worker_request_sync_timeout(op, id, extraFields, requestTimeoutMs); +} + +// ---------------------------------------------------------------- live mode: applying updates + +static guint interface_mask(WaNode *node); +static void create_accessibles(WaNode *node); + +static gboolean traceMessages; + +static void defunct_subtree(WaNode *node) { + if (node->defunct) return; + if (traceMessages) g_printerr("trace: defunct %ld %s\n", node->id, atk_role_get_name(node->atkRole)); + node->defunct = TRUE; + if (node->id == focusedId) focusedId = 0; + if (node_for_id(node->id) == node) g_hash_table_remove(nodesById, &node->id); + atk_object_notify_state_change(node->accessible, ATK_STATE_DEFUNCT, TRUE); + for (guint i = 0; i < node->children->len; i++) { + WaNode *child = g_ptr_array_index(node->children, i); + defunct_subtree(child); + child->parent = NULL; + } + g_ptr_array_set_size(node->children, 0); + g_clear_object(&node->hyperlink); + for (int b = 0; b < 4; b++) g_clear_pointer(&node->boundaryCache[b], g_hash_table_unref); + g_clear_pointer(&node->characterExtents, g_array_unref); + // Drop the tree's reference last; the node may be freed from here on. + g_object_unref(node->accessible); +} + +static void clear_boundary_caches(WaNode *node, gboolean linesOnly) { + for (int b = 0; b < 4; b++) + if (!linesOnly || b == 2) g_clear_pointer(&node->boundaryCache[b], g_hash_table_unref); + g_clear_pointer(&node->characterExtents, g_array_unref); // positions follow both text and layout +} + +// Replace existing's properties with fresh's, keeping identity, tree links, +// the accessible object and live state. Frees fresh. +static void adopt_properties(WaNode *existing, WaNode *fresh) { + WaNode old = *existing; + *existing = *fresh; + existing->id = old.id; + existing->parent = old.parent; + existing->children = old.children; + existing->isFrame = old.isFrame; + existing->isApplication = old.isApplication; + existing->accessible = old.accessible; + existing->hyperlink = old.hyperlink; + existing->defunct = old.defunct; + existing->caret = old.caret; // the caret changes only through caret messages + existing->selectionStart = old.selectionStart; + existing->selectionEnd = old.selectionEnd; + for (int b = 0; b < 4; b++) existing->boundaryCache[b] = old.boundaryCache[b]; + existing->characterExtents = old.characterExtents; // cleared below if the text changed + existing->liveExtentsValid = FALSE; + if (existing->isFrame) existing->atkRole = ATK_ROLE_FRAME; + free_node_properties(&old); + g_free(fresh); +} + +static void emit_text_diff(WaNode *node, const gunichar *oldText, long oldCount) { + const gunichar *newText = node->characters; + long newCount = node->characterCount; + long prefix = 0; + while (prefix < oldCount && prefix < newCount && oldText[prefix] == newText[prefix]) prefix++; + long suffix = 0; + while (suffix < oldCount - prefix && suffix < newCount - prefix && + oldText[oldCount - 1 - suffix] == newText[newCount - 1 - suffix]) + suffix++; + long removed = oldCount - prefix - suffix, inserted = newCount - prefix - suffix; + if (removed > 0) { + gchar *text = g_ucs4_to_utf8(oldText + prefix, removed, NULL, NULL, NULL); + g_signal_emit_by_name(node->accessible, "text-remove", (gint)prefix, (gint)removed, text); + g_free(text); + } + if (inserted > 0) { + gchar *text = g_ucs4_to_utf8(newText + prefix, inserted, NULL, NULL, NULL); + g_signal_emit_by_name(node->accessible, "text-insert", (gint)prefix, (gint)inserted, text); + g_free(text); + } +} + +typedef struct { + char *name; + char *description; + AtkStateSet *states; + gunichar *text; + long textCount; + AtkRole role; +} WaObservable; + +static void capture(WaNode *node, WaObservable *observable) { + observable->name = g_strdup(node->name); + observable->description = g_strdup(node->description); + observable->states = atk_object_ref_state_set(node->accessible); + observable->textCount = node->characterCount; + observable->text = node->characterCount ? g_memdup2(node->characters, sizeof(gunichar) * node->characterCount) : NULL; + observable->role = node->atkRole; +} + +// children-changed:add events wait for the end of the worker's batch and go +// out in document order, after focus changes, as native Chromium sends them. +static GPtrArray *deferredAdditions; // AtkObject *, referenced + +static void document_order(WaNode *node, GHashTable *order, guint *next) { + g_hash_table_insert(order, node, GUINT_TO_POINTER(++*next)); + for (guint i = 0; i < node->children->len; i++) document_order(g_ptr_array_index(node->children, i), order, next); +} + +static GHashTable *flushOrder; + +static gint compare_document_order(gconstpointer first, gconstpointer second) { + guint a = GPOINTER_TO_UINT(g_hash_table_lookup(flushOrder, node_of(*(AtkObject *const *)first))); + guint b = GPOINTER_TO_UINT(g_hash_table_lookup(flushOrder, node_of(*(AtkObject *const *)second))); + return a < b ? -1 : a > b; +} + +static void flush_additions(void) { + if (!deferredAdditions || deferredAdditions->len == 0) return; + flushOrder = g_hash_table_new(g_direct_hash, g_direct_equal); + guint next = 0; + document_order(applicationNode, flushOrder, &next); + g_ptr_array_sort(deferredAdditions, compare_document_order); + for (guint i = 0; i < deferredAdditions->len; i++) { + AtkObject *child = g_ptr_array_index(deferredAdditions, i); + WaNode *childNode = node_of(child); + WaNode *parent = childNode->parent; + if (childNode->defunct || !parent || parent->defunct) continue; + gint index = -1; + for (guint j = 0; j < parent->children->len; j++) + if (g_ptr_array_index(parent->children, j) == childNode) index = (gint)j; + if (index >= 0) g_signal_emit_by_name(parent->accessible, "children-changed::add", index, child); + } + g_ptr_array_set_size(deferredAdditions, 0); + g_clear_pointer(&flushOrder, g_hash_table_unref); +} + +static gboolean only_embedded_objects(const gunichar *text, long count) { + for (long i = 0; i < count; i++) + if (text[i] != 0xFFFC) return FALSE; + return TRUE; +} + +// Emit the AT-SPI events for what changed since capture(), then free it. +// When the node's children changed, native Chromium reports its text as wholly +// replaced, and reports nothing for text made only of embedded objects; edits +// within one text object are reported as the minimal changed range. +static void emit_changes(WaNode *node, WaObservable *before, gboolean childrenChanged) { + AtkObject *accessible = node->accessible; + if (before->role != node->atkRole) atk_object_set_role(accessible, node->atkRole); + if (g_strcmp0(before->name ? before->name : "", node->name ? node->name : "") != 0) + g_object_notify(G_OBJECT(accessible), "accessible-name"); + if (g_strcmp0(before->description ? before->description : "", node->description ? node->description : "") != 0) + g_object_notify(G_OBJECT(accessible), "accessible-description"); + gboolean textChanged = before->textCount != node->characterCount || + (node->characterCount && + memcmp(before->text, node->characters, sizeof(gunichar) * node->characterCount) != 0); + if (textChanged) { + clear_boundary_caches(node, FALSE); + if (!childrenChanged) { + emit_text_diff(node, before->text, before->textCount); + } else if (!(only_embedded_objects(before->text, before->textCount) && + only_embedded_objects(node->characters, node->characterCount))) { + if (before->textCount > 0) { + gchar *text = g_ucs4_to_utf8(before->text, before->textCount, NULL, NULL, NULL); + g_signal_emit_by_name(node->accessible, "text-remove", 0, (gint)before->textCount, text); + g_free(text); + } + if (node->characterCount > 0) { + gchar *text = g_ucs4_to_utf8(node->characters, node->characterCount, NULL, NULL, NULL); + g_signal_emit_by_name(node->accessible, "text-insert", 0, (gint)node->characterCount, text); + g_free(text); + } + } + } + AtkStateSet *after = atk_object_ref_state_set(accessible); + for (int state = ATK_STATE_INVALID + 1; state < ATK_STATE_LAST_DEFINED; state++) { + if (state == ATK_STATE_FOCUSED || state == ATK_STATE_DEFUNCT) continue; // focus comes from focus messages + gboolean was = atk_state_set_contains_state(before->states, state); + gboolean is = atk_state_set_contains_state(after, state); + if (was != is) atk_object_notify_state_change(accessible, state, is); + } + g_object_unref(after); + g_object_unref(before->states); + g_free(before->name); + g_free(before->description); + g_free(before->text); +} + +static gboolean is_ancestor(WaNode *candidate, WaNode *node) { + for (WaNode *current = node; current; current = current->parent) + if (current == candidate) return TRUE; + return FALSE; +} + +// A fresh node whose role and interfaces are computed as they would be in +// place, so it can be compared with an existing one. +static WaNode *prepare_fresh(JsonObject *object, WaNode *parent, gboolean isFrame) { + WaNode *fresh = new_node(object); + fresh->parent = parent; + fresh->isFrame = isFrame; + fresh->atkRole = isFrame ? ATK_ROLE_FRAME : map_role(fresh); + return fresh; +} + +static void discard_fresh(WaNode *fresh) { + free_node_properties(fresh); + g_free(fresh); +} + +static void postprocess_node(WaNode *node) { + synthesize_view_links_node(node); + if (!inside_document(node)) adapt_views_node(node); +} + +static void postprocess_subtree(WaNode *node) { + synthesize_view_links(node); + if (!inside_document(node)) adapt_views_layer(node); +} + +static void reconcile_existing(WaNode *node, WaNode *fresh, JsonObject *object, gboolean withChildren); + +// Make node's children match the provider's list: keep objects whose IDs +// survive (their identity matters to readers), create new ones, and retire +// the rest. Removals are emitted here; additions are returned in `added` for +// the caller to emit after text changes, in native order. Returns whether the +// child list changed. +static gboolean reconcile_children(WaNode *node, JsonArray *childArray, GPtrArray *added) { + gboolean changed = FALSE; + GPtrArray *oldChildren = node->children; + GPtrArray *newChildren = g_ptr_array_new(); + node->children = newChildren; + for (guint i = 0; childArray && i < json_array_get_length(childArray); i++) { + JsonObject *childObject = json_array_get_object_element(childArray, i); + long id = member_long(childObject, "id", 0); + WaNode *existing = id ? node_for_id(id) : NULL; + WaNode *placed = NULL; + if (existing && !existing->defunct && !is_ancestor(existing, node)) { + WaNode *fresh = prepare_fresh(childObject, node, existing->isFrame); + if (interface_mask(fresh) == interface_mask(existing)) { + if (existing->parent != node && existing->parent) { + WaNode *oldParent = existing->parent; + gint oldIndex = -1; + for (guint j = 0; j < oldParent->children->len; j++) + if (g_ptr_array_index(oldParent->children, j) == existing) oldIndex = (gint)j; + if (oldIndex >= 0) { + g_ptr_array_remove_index(oldParent->children, oldIndex); + g_signal_emit_by_name(oldParent->accessible, "children-changed::remove", oldIndex, existing->accessible); + } + } + existing->parent = node; + atk_object_set_parent(existing->accessible, node->accessible); + g_ptr_array_add(newChildren, existing); + reconcile_existing(existing, fresh, childObject, TRUE); + placed = existing; + } else { + if (traceMessages) + g_printerr("trace: node %ld interfaces changed 0x%x -> 0x%x (role %s -> %s)\n", existing->id, + interface_mask(existing), interface_mask(fresh), atk_role_get_name(existing->atkRole), + atk_role_get_name(fresh->atkRole)); + discard_fresh(fresh); // interfaces changed: the old object is retired below + if (existing->parent != node) { + WaNode *oldParent = existing->parent; + if (oldParent) { + g_ptr_array_remove(oldParent->children, existing); + g_signal_emit_by_name(oldParent->accessible, "children-changed::remove", -1, existing->accessible); + } + defunct_subtree(existing); + } + } + } + if (!placed) { + if (existing && !existing->defunct && is_ancestor(existing, node)) { + g_warning("node %ld would become its own descendant; ignored", id); + continue; + } + WaNode *created = load_node(childObject, node); + created->atkRole = map_role(created); + g_ptr_array_add(newChildren, created); + postprocess_subtree(created); + create_accessibles(created); + } + } + for (guint i = 0; i < oldChildren->len; i++) { + WaNode *old = g_ptr_array_index(oldChildren, i); + gboolean kept = FALSE; + for (guint j = 0; j < newChildren->len && !kept; j++) kept = g_ptr_array_index(newChildren, j) == old; + if (kept) continue; + changed = TRUE; + if (old->parent != node) continue; + g_signal_emit_by_name(node->accessible, "children-changed::remove", (gint)i, old->accessible); + defunct_subtree(old); + } + for (guint i = 0; i < newChildren->len; i++) { + WaNode *child = g_ptr_array_index(newChildren, i); + gboolean existed = FALSE; + for (guint j = 0; j < oldChildren->len && !existed; j++) existed = g_ptr_array_index(oldChildren, j) == child; + if (!existed) { + g_ptr_array_add(added, g_object_ref(child->accessible)); + changed = TRUE; + } + } + g_ptr_array_unref(oldChildren); + return changed; +} + +static void reconcile_existing(WaNode *node, WaNode *fresh, JsonObject *object, gboolean withChildren) { + WaObservable before; + capture(node, &before); + adopt_properties(node, fresh); + GPtrArray *added = g_ptr_array_new_with_free_func(g_object_unref); + gboolean childrenChanged = FALSE; + if (withChildren && json_object_has_member(object, "children")) + childrenChanged = reconcile_children(node, json_object_get_array_member(object, "children"), added); + postprocess_node(node); + emit_changes(node, &before, childrenChanged); + if (!deferredAdditions) deferredAdditions = g_ptr_array_new_with_free_func(g_object_unref); + for (guint i = 0; i < added->len; i++) g_ptr_array_add(deferredAdditions, g_object_ref(g_ptr_array_index(added, i))); + g_ptr_array_unref(added); +} + +// Apply a node or subtree record to the node with the same ID. When its +// interfaces change the object must be replaced; ask for a full subtree. +static void apply_record(JsonObject *object, gboolean withChildren) { + long id = member_long(object, "id", 0); + WaNode *node = node_for_id(id); + if (!node || node->defunct) { + g_debug("update for unknown node %ld ignored", id); + return; + } + WaNode *fresh = prepare_fresh(object, node->parent, node->isFrame); + if (!node->isFrame && interface_mask(fresh) != interface_mask(node)) { + discard_fresh(fresh); + WaNode *parent = node->parent; + if (parent) worker_request_async("refresh", parent->id, NULL); + return; + } + reconcile_existing(node, fresh, object, withChildren); +} + +static void apply_focus(long id) { + if (id == focusedId) return; + WaNode *previous = focusedId ? node_for_id(focusedId) : NULL; + focusedId = id; + if (previous && !previous->defunct) atk_object_notify_state_change(previous->accessible, ATK_STATE_FOCUSED, FALSE); + WaNode *node = node_for_id(id); + if (node && !node->defunct) atk_object_notify_state_change(node->accessible, ATK_STATE_FOCUSED, TRUE); +} + +// The object holding the document's current range selection, if any. +static long selectionOwnerId; + +static void apply_selection(WaNode *node, JsonObject *message) { + long start = -1, end = -1; + if (json_object_has_member(message, "selection") && + !JSON_NODE_HOLDS_NULL(json_object_get_member(message, "selection"))) { + JsonArray *range = json_object_get_array_member(message, "selection"); + if (json_array_get_length(range) == 2) { + start = utf16_boundary_to_character(node, (long)json_array_get_int_element(range, 0), FALSE); + end = utf16_boundary_to_character(node, (long)json_array_get_int_element(range, 1), TRUE); + } + } + if (start == end) start = end = -1; // a collapsed selection is no selection + if (start != node->selectionStart || end != node->selectionEnd) { + node->selectionStart = start; + node->selectionEnd = end; + g_signal_emit_by_name(node->accessible, "text-selection-changed"); + } + if (start >= 0) selectionOwnerId = node->id; + else if (selectionOwnerId == node->id) selectionOwnerId = 0; +} + +static void apply_caret(JsonObject *message) { + WaNode *node = node_for_id(member_long(message, "id", 0)); + if (!node || node->defunct || !node->hasText) return; + // A caret arriving for an object that is not yet focused means focus is + // moving there. If another object held a range selection, the document + // selection collapses: native Chromium reports that on the new object. + if (node->id != focusedId && selectionOwnerId && selectionOwnerId != node->id) { + WaNode *owner = node_for_id(selectionOwnerId); + if (owner && !owner->defunct) owner->selectionStart = owner->selectionEnd = -1; + selectionOwnerId = 0; + g_signal_emit_by_name(node->accessible, "text-selection-changed"); + } + // Native order: selection change, then caret move. + apply_selection(node, message); + long caret16 = member_long(message, "caret", -1); + long caret = caret16 < 0 ? -1 : utf16_boundary_to_character(node, caret16, FALSE); + if (caret != node->caret) { + node->caret = caret; + if (caret >= 0) g_signal_emit_by_name(node->accessible, "text-caret-moved", (gint)caret); + } +} + +// Windows Chromium reports scrolling to an anchor (an in-page link target) as +// EVENT_SYSTEM_SCROLLINGSTART on the target; native Linux Chromium moves the +// caret to the start of the target instead, which is how readers continue +// reading from there. +static void apply_anchor(JsonObject *message) { + WaNode *node = node_for_id(member_long(message, "id", 0)); + if (!node || node->defunct || !node->hasText) return; + node->caret = 0; + g_signal_emit_by_name(node->accessible, "text-caret-moved", 0); +} + +static void invalidate_layout(void) { + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init(&iter, nodesById); + while (g_hash_table_iter_next(&iter, &key, &value)) { + WaNode *node = value; + node->liveExtentsValid = FALSE; + clear_boundary_caches(node, TRUE); + } +} + +static void apply_foreground(gboolean active) { + if (active == frameActive || !frameNode) return; + frameActive = active; + atk_object_notify_state_change(frameNode->accessible, ATK_STATE_ACTIVE, active); + g_signal_emit_by_name(frameNode->accessible, active ? "activate" : "deactivate"); +} + +static void worker_gone(void) { + if (exitStatus) return; + g_message("browser worker ended; retiring the published window"); + exitStatus = 3; + if (frameNode && !frameNode->defunct) { + g_ptr_array_remove(applicationNode->children, frameNode); + g_signal_emit_by_name(applicationNode->accessible, "children-changed::remove", 0, frameNode->accessible); + defunct_subtree(frameNode); + frameNode = NULL; + } + if (mainLoop) g_main_loop_quit(mainLoop); +} + +static void trace_message(const char *type, JsonObject *message) { + long id = member_long(message, "id", 0); + if (!id && json_object_has_member(message, "node")) id = member_long(json_object_get_object_member(message, "node"), "id", 0); + long children = -1; + if (json_object_has_member(message, "node")) { + JsonObject *node = json_object_get_object_member(message, "node"); + if (json_object_has_member(node, "children")) children = json_array_get_length(json_object_get_array_member(node, "children")); + } + g_printerr("trace: %s id=%ld children=%ld\n", type, id, children); +} + +static void handle_message(JsonObject *message) { + const char *type = json_object_get_string_member_with_default(message, "type", ""); + if (traceMessages) trace_message(type, message); + if (strcmp(type, "tree") == 0) { + if (frameNode && json_object_has_member(message, "root")) { + JsonObject *root = json_object_get_object_member(message, "root"); + WaNode *fresh = prepare_fresh(root, applicationNode, TRUE); + reconcile_existing(frameNode, fresh, root, TRUE); + } + apply_focus(member_long(message, "focusedId", 0)); + } else if (strcmp(type, "subtree") == 0 || strcmp(type, "node") == 0) { + if (json_object_has_member(message, "node")) + apply_record(json_object_get_object_member(message, "node"), strcmp(type, "subtree") == 0); + } else if (strcmp(type, "focus") == 0) { + apply_focus(member_long(message, "id", 0)); + } else if (strcmp(type, "caret") == 0) { + apply_caret(message); + } else if (strcmp(type, "selection") == 0) { + WaNode *node = node_for_id(member_long(message, "id", 0)); + if (node && !node->defunct && node->hasText) apply_selection(node, message); + } else if (strcmp(type, "layout") == 0) { + invalidate_layout(); + } else if (strcmp(type, "anchor") == 0) { + apply_anchor(message); + } else if (strcmp(type, "flush") == 0) { + flush_additions(); + } else if (strcmp(type, "foreground") == 0) { + apply_foreground(json_object_get_boolean_member_with_default(message, "active", FALSE)); + } else if (strcmp(type, "reply") == 0) { + if (!json_object_get_boolean_member_with_default(message, "ok", FALSE)) + g_debug("worker request %ld failed: hr=%ld", member_long(message, "requestId", 0), member_long(message, "hr", 0)); + } else if (strcmp(type, "gone") == 0) { + worker_gone(); + } else if (strcmp(type, "hello") != 0) { + g_warning("unknown worker message type %s", type); + } +} + +static gboolean on_worker_output(gint fd, GIOCondition condition, gpointer data) { + (void)fd; + (void)condition; + (void)data; + read_worker(0); + JsonObject *message; + while ((message = g_queue_pop_head(pendingMessages))) { // keep arrival order + handle_message(message); + json_object_unref(message); + } + while (!exitStatus && (message = take_message())) { + handle_message(message); + json_object_unref(message); + } + if (workerClosed && !exitStatus) worker_gone(); + return exitStatus ? G_SOURCE_REMOVE : G_SOURCE_CONTINUE; +} + +static gboolean spawn_worker(char **command) { + GError *error = NULL; + if (!g_spawn_async_with_pipes(NULL, command, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, + &workerPid, &workerInput, &workerOutput, NULL, &error)) { + fprintf(stderr, "Cannot start worker: %s\n", error->message); + g_error_free(error); + return FALSE; + } + workerBuffer = g_string_new(NULL); + pendingMessages = g_queue_new(); + return TRUE; +} + +// Wait for the worker's first tree, applying hello on the way. +static JsonObject *wait_for_first_tree(int seconds) { + gint64 deadline = g_get_monotonic_time() + (gint64)seconds * G_USEC_PER_SEC; + while (g_get_monotonic_time() < deadline && !workerClosed) { + JsonObject *message; + while ((message = take_message())) { + const char *type = json_object_get_string_member_with_default(message, "type", ""); + if (strcmp(type, "tree") == 0) return message; + if (strcmp(type, "hello") == 0) { + x11Window = (unsigned long long)json_object_get_int_member_with_default(message, "x11Window", 0); + if (json_object_get_boolean_member_with_default(message, "foreground", FALSE)) frameActive = TRUE; + g_message("worker connected to window \"%s\"", json_object_get_string_member_with_default(message, "title", "")); + json_object_unref(message); + } else if (strcmp(type, "gone") == 0) { + json_object_unref(message); + return NULL; + } else { + queue_pending(message); + } + } + read_worker(250); + } + return NULL; +} + +// ---------------------------------------------------------------- main + + +static gboolean announce(gpointer data) { + (void)data; + if (frameActive) { + g_signal_emit_by_name(frameNode->accessible, "activate"); + atk_object_notify_state_change(frameNode->accessible, ATK_STATE_ACTIVE, TRUE); + } + WaNode *focused = node_for_id(focusedId); + if (focused) { + atk_object_notify_state_change(focused->accessible, ATK_STATE_FOCUSED, TRUE); + g_message("announced focus on node %ld (%s)", focused->id, atk_role_get_name(focused->atkRole)); + } + return G_SOURCE_REMOVE; +} + +static gboolean quit_loop(gpointer loop) { + g_main_loop_quit(loop); + return G_SOURCE_REMOVE; +} + +// Build the published tree: the provider's window root becomes the frame, under +// a synthesized application root like the one native Chromium publishes. +static void build_initial_tree(JsonObject *rootObject, long initialFocus) { + nodesById = g_hash_table_new(g_int64_hash, g_int64_equal); + G_STATIC_ASSERT(sizeof(long) == sizeof(gint64)); + frameNode = load_node(rootObject, NULL); + frameNode->isFrame = TRUE; + frameNode->atkRole = ATK_ROLE_FRAME; + focusedId = initialFocus; + synthesize_view_links(frameNode); + adapt_views_layer(frameNode); + + applicationNode = g_new0(WaNode, 1); + applicationNode->id = syntheticIds--; + applicationNode->isApplication = TRUE; + applicationNode->atkRole = ATK_ROLE_APPLICATION; + applicationNode->name = g_strdup(applicationName); + parse_attributes(applicationNode, "explicit-name:true;name-from:attribute;"); + applicationNode->hasText = TRUE; + applicationNode->characters = g_new(gunichar, 2); + applicationNode->characters[0] = 0xFFFC; + applicationNode->characterCount = 1; + applicationNode->caret = -1; + applicationNode->selectionStart = applicationNode->selectionEnd = -1; + applicationNode->links = g_array_new(FALSE, FALSE, sizeof(WaLink)); + WaLink frameLink = {.start = 0, .end = 1, .id = frameNode->id}; + g_array_append_val(applicationNode->links, frameLink); + applicationNode->relations = g_ptr_array_new(); + applicationNode->actions = g_ptr_array_new_with_free_func(g_free); + g_ptr_array_add(applicationNode->actions, g_strdup("doDefault")); + g_ptr_array_add(applicationNode->actions, g_strdup("showContextMenu")); + applicationNode->children = g_ptr_array_new(); + g_ptr_array_add(applicationNode->children, frameNode); + frameNode->parent = applicationNode; + g_hash_table_insert(nodesById, &applicationNode->id, applicationNode); + create_accessibles(applicationNode); +} + +static void usage(const char *program) { + fprintf(stderr, + "Usage: %s (SNAPSHOT.json | --worker COMMAND...) [--app-name NAME] [--active] [--announce] " + "[--quit-after SECONDS]\n--worker must come last; everything after it is the command.\n", + program); +} + +int main(int argc, char **argv) { + const char *snapshotPath = NULL; + char **workerCommand = NULL; + gboolean announceFocus = FALSE; + int quitAfterSeconds = 0; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--app-name") == 0 && i + 1 < argc) applicationName = argv[++i]; + else if (strcmp(argv[i], "--active") == 0) frameActive = TRUE; + else if (strcmp(argv[i], "--announce") == 0) announceFocus = TRUE; + else if (strcmp(argv[i], "--quit-after") == 0 && i + 1 < argc) quitAfterSeconds = atoi(argv[++i]); + else if (strcmp(argv[i], "--worker") == 0 && i + 1 < argc) { + workerCommand = argv + i + 1; + break; + } else if (!snapshotPath && argv[i][0] != '-') snapshotPath = argv[i]; + else { + fprintf(stderr, "Unknown argument: %s\n", argv[i]); + usage(argv[0]); + return 2; + } + } + if (!snapshotPath == !workerCommand) { + usage(argv[0]); + return 2; + } + + JsonParser *parser = NULL; + JsonObject *firstTree = NULL; + if (workerCommand) { + liveMode = TRUE; + const char *trace = g_getenv("WINE_ACCESS_BROWSER_TRACE"); + traceMessages = trace && *trace; + signal(SIGPIPE, SIG_IGN); + // Identifies this process to the reader's Wine ownership check. Readers + // read /proc/PID/environ, which only shows the environment the process + // started with, so restart once with the marker instead of setenv alone. + if (g_strcmp0(g_getenv("WINE_ACCESS_BROWSER_PUBLISHER"), "1") != 0) { + g_setenv("WINE_ACCESS_BROWSER_PUBLISHER", "1", TRUE); + // Exec the real path so the process keeps its own name. + char *self = g_file_read_link("/proc/self/exe", NULL); + if (self) execv(self, argv); + fprintf(stderr, "Cannot restart with the publisher marker: %s\n", g_strerror(errno)); + return 1; + } + if (!spawn_worker(workerCommand)) return 1; + firstTree = wait_for_first_tree(90); + if (!firstTree) { + fprintf(stderr, "The worker sent no tree\n"); + return 3; + } + build_initial_tree(json_object_get_object_member(firstTree, "root"), member_long(firstTree, "focusedId", 0)); + } else { + parser = json_parser_new(); + GError *error = NULL; + if (!json_parser_load_from_file(parser, snapshotPath, &error)) { + fprintf(stderr, "Cannot read %s: %s\n", snapshotPath, error->message); + return 1; + } + JsonObject *document = json_node_get_object(json_parser_get_root(parser)); + const char *format = json_object_get_string_member_with_default(document, "format", ""); + if (strcmp(format, "wine-access-browser-snapshot-1") != 0) { + fprintf(stderr, "Unsupported snapshot format: %s\n", format); + return 1; + } + build_initial_tree(json_object_get_object_member(document, "root"), member_long(document, "focusedId", 0)); + } + + install_util(); + if (atk_bridge_adaptor_init(&argc, &argv) != 0) { + fprintf(stderr, "atk-bridge initialization failed; is the accessibility bus available?\n"); + return 1; + } + g_message("published %u objects as application \"%s\" (toolkit Chromium, %s mode)", g_hash_table_size(nodesById), + applicationName, liveMode ? "live" : "snapshot"); + // The helper waits for this line before retiring legacy announcements. + fputs("published\n", stdout); + fflush(stdout); + + mainLoop = g_main_loop_new(NULL, FALSE); + g_unix_signal_add(SIGINT, quit_loop, mainLoop); + g_unix_signal_add(SIGTERM, quit_loop, mainLoop); + if (liveMode) { + g_unix_fd_add(workerOutput, G_IO_IN | G_IO_HUP | G_IO_ERR, on_worker_output, NULL); + if (!g_queue_is_empty(pendingMessages) && !pendingIdleSource) pendingIdleSource = g_idle_add(process_pending, NULL); + } + if (announceFocus) g_timeout_add(1000, announce, NULL); + if (quitAfterSeconds > 0) g_timeout_add_seconds(quitAfterSeconds, quit_loop, mainLoop); + g_main_loop_run(mainLoop); + atk_bridge_adaptor_cleanup(); + g_main_loop_unref(mainLoop); + if (workerInput >= 0) close(workerInput); // the worker exits when its input closes + if (firstTree) json_object_unref(firstTree); + if (parser) g_object_unref(parser); + return exitStatus; +} diff --git a/browser_worker.cpp b/browser_worker.cpp new file mode 100644 index 0000000..7537e66 --- /dev/null +++ b/browser_worker.cpp @@ -0,0 +1,1260 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// Wine Access browser worker. +// +// Runs inside the browser's Wine prefix, owns every MSAA/IA2 call for one +// Chromium window, and talks to wine-access-browser-publisher over +// stdin/stdout with one JSON message per line. Protected (password) text and +// values never leave this process. +// +// Usage: wine-access-browser-worker.exe (--hwnd DECIMAL | --title TEXT) [--wait-window SECONDS] +// --title is for tests; the helper always passes --hwnd. +// +// Worker -> publisher: +// {"type":"hello","protocol":1,"hwnd":N,"windowsPid":N,"x11Window":N,"title":S,"foreground":BOOL} +// {"type":"tree","generation":N,"focusedId":N,"root":NODE} full tree +// {"type":"subtree","generation":N,"node":NODE} replace a node and its descendants +// {"type":"node","generation":N,"node":NODE-WITHOUT-CHILDREN} update one node's properties +// {"type":"focus","id":N} +// {"type":"caret","id":N,"caret":UTF16,"selection":[S,E]|null} +// {"type":"selection","id":N,"selection":[S,E]|null} +// {"type":"layout"} extents and line boundaries are stale +// {"type":"anchor","id":N} scrolled to an anchor (in-page link target) +// {"type":"flush"} end of one batch of changes +// {"type":"foreground","active":BOOL} +// {"type":"reply","requestId":N,"ok":BOOL,"hr":N,...} +// {"type":"gone"} +// Publisher -> worker (flat objects, integers only besides "type" and "op"): +// {"type":"request","requestId":N,"op":OP,...} +// OP: action(id,index) focus(id) setCaret(id,offset) setSelection(id,start,end) +// scrollTo(id,scrollType) scrollSubstring(id,start,end,scrollType) +// boundary(id,offset,granularity) extents(id) characterExtents(id,offset) +// characterExtentsAll(id) (every character, at most 4096) +// refresh(id) +// All offsets are UTF-16, as IA2 reports them. + +#include +#include +#include +#include + +#include "Accessible2.h" +#include "AccessibleAction.h" +#include "AccessibleEventID.h" +#include "AccessibleHyperlink.h" +#include "AccessibleHypertext.h" +#include "AccessibleRelation.h" +#include "AccessibleTable2.h" +#include "AccessibleTableCell.h" +#include "AccessibleText.h" +#include "IA2CommonTypes.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +constexpr UINT WM_APP_REQUEST = WM_APP + 1; +constexpr UINT WM_APP_INPUT_CLOSED = WM_APP + 2; +constexpr int ProtocolVersion = 1; +constexpr size_t MaxQueuedEvents = 20000; +constexpr int MaxDepth = 80; +constexpr int MaxNodes = 20000; + +HWND targetWindow; +DWORD targetProcessId; +DWORD mainThreadId; +DWORD queryThreadId; +IAccessible *windowRoot; // main thread's apartment only +CRITICAL_SECTION outputLock; +long generation; +std::map parentOf; // uniqueID -> parent uniqueID, for everything sent +LARGE_INTEGER perfFrequency; + +VARIANT self_child() { + VARIANT value; + VariantInit(&value); + value.vt = VT_I4; + value.lVal = CHILDID_SELF; + return value; +} +const VARIANT selfChild = self_child(); + +double now_ms() { + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + return counter.QuadPart * 1000.0 / perfFrequency.QuadPart; +} + +// ------------------------------------------------------------------ output + +void write_all(HANDLE handle, const std::string &data) { + size_t written = 0; + while (written < data.size()) { + DWORD chunk = 0; + if (!WriteFile(handle, data.data() + written, (DWORD)(data.size() - written), &chunk, nullptr) || chunk == 0) + ExitProcess(4); // the publisher went away + written += chunk; + } +} + +// Both the main thread and the query thread write; one line at a time. +void send(const std::string &message) { + EnterCriticalSection(&outputLock); + write_all(GetStdHandle(STD_OUTPUT_HANDLE), message + "\n"); + LeaveCriticalSection(&outputLock); +} + +// Diagnostics go to stderr: message first, then the time. +void log_message(const std::string &message) { + char timeText[64]; + time_t now = time(nullptr); + struct tm local {}; + localtime_s(&local, &now); // both threads log + strftime(timeText, sizeof(timeText), "%a %b %e %H:%M:%S %Y", &local); + EnterCriticalSection(&outputLock); + write_all(GetStdHandle(STD_ERROR_HANDLE), "wine-access-browser-worker: " + message + " [" + timeText + "]\n"); + LeaveCriticalSection(&outputLock); +} + +std::string to_utf8(const wchar_t *text, size_t length) { + if (!length) return {}; + int needed = WideCharToMultiByte(CP_UTF8, 0, text, (int)length, nullptr, 0, nullptr, nullptr); + std::string result(needed, '\0'); + WideCharToMultiByte(CP_UTF8, 0, text, (int)length, result.data(), needed, nullptr, nullptr); + return result; +} + +std::string json_quote_utf8(const std::string &utf8) { + std::string result = "\""; + for (unsigned char c : utf8) { + switch (c) { + case '"': result += "\\\""; break; + case '\\': result += "\\\\"; break; + case '\n': result += "\\n"; break; + case '\r': result += "\\r"; break; + case '\t': result += "\\t"; break; + default: + if (c < 0x20) { + char escaped[8]; + snprintf(escaped, sizeof(escaped), "\\u%04x", c); + result += escaped; + } else { + result += (char)c; + } + } + } + return result + "\""; +} + +std::string json_bstr(BSTR value) { + std::string result = value ? json_quote_utf8(to_utf8(value, SysStringLen(value))) : "null"; + SysFreeString(value); + return result; +} + +// ------------------------------------------------------------------ COM helpers + +IAccessible2 *get_ia2(IUnknown *unknown) { + if (!unknown) return nullptr; + IServiceProvider *provider = nullptr; + IAccessible2 *ia2 = nullptr; + if (SUCCEEDED(unknown->QueryInterface(IID_IServiceProvider, (void **)&provider)) && provider) { + provider->QueryService(IID_IAccessible, __uuidof(IAccessible2), (void **)&ia2); + provider->Release(); + } + if (!ia2) unknown->QueryInterface(__uuidof(IAccessible2), (void **)&ia2); + return ia2; +} + +template +T *ia2_interface(IAccessible2 *ia2) { + T *result = nullptr; + if (ia2) ia2->QueryInterface(__uuidof(T), (void **)&result); + return result; +} + +long unique_id_of(IUnknown *unknown) { + IAccessible2 *ia2 = get_ia2(unknown); + long uniqueId = 0; + if (ia2) { + ia2->get_uniqueID(&uniqueId); + ia2->Release(); + } + return uniqueId; +} + +// Roots that can resolve uniqueIDs: the top-level window resolves Chromium's +// views objects, and its child windows (Chrome_RenderWidgetHostHWND) resolve +// web content. get_accChild on the wrong root fails with E_INVALIDARG. +// Per thread: COM proxies belong to the apartment that created them. +thread_local std::vector> resolutionRoots; + +BOOL CALLBACK add_child_root(HWND hwnd, LPARAM) { + for (const auto &entry : resolutionRoots) + if (entry.first == hwnd) return TRUE; + IAccessible *root = nullptr; + if (SUCCEEDED(AccessibleObjectFromWindow(hwnd, (DWORD)OBJID_CLIENT, IID_IAccessible, (void **)&root)) && root) + resolutionRoots.push_back({hwnd, root}); + return TRUE; +} + +void refresh_resolution_roots() { + add_child_root(targetWindow, 0); + EnumChildWindows(targetWindow, add_child_root, 0); +} + +IAccessible *resolve_with_roots(long id) { + VARIANT child; + VariantInit(&child); + child.vt = VT_I4; + child.lVal = id; + for (const auto &entry : resolutionRoots) { + IDispatch *dispatch = nullptr; + if (FAILED(entry.second->get_accChild(child, &dispatch)) || !dispatch) continue; + IAccessible *accessible = nullptr; + dispatch->QueryInterface(IID_IAccessible, (void **)&accessible); + dispatch->Release(); + if (accessible) return accessible; + } + return nullptr; +} + +// Resolve a uniqueID to its object. Returns an owned reference or null. +IAccessible *resolve(long id) { + IAccessible *accessible = resolve_with_roots(id); + if (accessible) return accessible; + size_t knownRoots = resolutionRoots.size(); + refresh_resolution_roots(); // a render widget window may have appeared + return resolutionRoots.size() > knownRoots ? resolve_with_roots(id) : nullptr; +} + +long msaa_state(IAccessible *accessible) { + VARIANT value; + VariantInit(&value); + long state = 0; + if (SUCCEEDED(accessible->get_accState(selfChild, &value)) && value.vt == VT_I4) state = value.lVal; + VariantClear(&value); + return state; +} + +bool is_protected(IAccessible *accessible) { + return (msaa_state(accessible) & STATE_SYSTEM_PROTECTED) != 0; +} + +// ------------------------------------------------------------------ requests + +struct PendingRequest { + std::string line; + double receivedMs; +}; + +void handle_request(const std::string &line); +std::set pendingSubtreeRefreshes; +void handle_posted_request(LPARAM parameter); + +// Answer queued requests while a long walk is in progress. +void service_requests() { + MSG message; + while (PeekMessageW(&message, nullptr, WM_APP_REQUEST, WM_APP_REQUEST, PM_REMOVE)) + handle_posted_request(message.lParam); +} + +// ------------------------------------------------------------------ node records + +std::string id_array(IUnknown **items, long count) { + std::string result = "["; + for (long i = 0; i < count; i++) { + if (i) result += ","; + result += std::to_string(unique_id_of(items[i])); + if (items[i]) items[i]->Release(); + } + CoTaskMemFree(items); + return result + "]"; +} + +int recordedNodes; + +void node_record(IAccessible *accessible, long parentId, bool withChildren, int depth, std::string &json) { + // Answer pending requests between objects so a long walk never delays a + // reader's synchronous query by more than one object's worth of calls. + ++recordedNodes; + service_requests(); + long role = 0; + VARIANT value; + VariantInit(&value); + if (SUCCEEDED(accessible->get_accRole(selfChild, &value)) && value.vt == VT_I4) role = value.lVal; + VariantClear(&value); + long state = msaa_state(accessible); + bool isProtected = (state & STATE_SYSTEM_PROTECTED) != 0; + + IAccessible2 *ia2 = get_ia2(accessible); + long uniqueId = 0; + if (ia2) ia2->get_uniqueID(&uniqueId); + if (parentId) parentOf[uniqueId] = parentId; + + json += "{\"id\":" + std::to_string(uniqueId) + ",\"msaaRole\":" + std::to_string(role) + + ",\"msaaStates\":" + std::to_string(state); + BSTR text = nullptr; + if (SUCCEEDED(accessible->get_accName(selfChild, &text))) json += ",\"name\":" + json_bstr(text); + text = nullptr; + if (SUCCEEDED(accessible->get_accDescription(selfChild, &text)) && text) json += ",\"description\":" + json_bstr(text); + text = nullptr; + if (!isProtected && SUCCEEDED(accessible->get_accValue(selfChild, &text)) && text) + json += ",\"value\":" + json_bstr(text); + text = nullptr; + if (SUCCEEDED(accessible->get_accDefaultAction(selfChild, &text)) && text) + json += ",\"defaultAction\":" + json_bstr(text); + long left = 0, top = 0, width = 0, height = 0; + if (SUCCEEDED(accessible->accLocation(&left, &top, &width, &height, selfChild))) + json += ",\"location\":[" + std::to_string(left) + "," + std::to_string(top) + "," + std::to_string(width) + + "," + std::to_string(height) + "]"; + + if (ia2) { + long ia2Role = 0; + AccessibleStates ia2States = 0; + ia2->role(&ia2Role); + ia2->get_states(&ia2States); + json += ",\"ia2Role\":" + std::to_string(ia2Role) + ",\"ia2States\":" + std::to_string((long)ia2States); + BSTR attributes = nullptr; + if (SUCCEEDED(ia2->get_attributes(&attributes)) && attributes) json += ",\"attributes\":" + json_bstr(attributes); + long level = 0, setSize = 0, position = 0; + if (SUCCEEDED(ia2->get_groupPosition(&level, &setSize, &position)) && (level || setSize || position)) + json += ",\"groupPosition\":[" + std::to_string(level) + "," + std::to_string(setSize) + "," + + std::to_string(position) + "]"; + long relationCount = 0; + if (SUCCEEDED(ia2->get_nRelations(&relationCount)) && relationCount > 0) { + json += ",\"relations\":["; + bool first = true; + for (long i = 0; i < relationCount; i++) { + IAccessibleRelation *relation = nullptr; + if (FAILED(ia2->get_relation(i, &relation)) || !relation) continue; + BSTR type = nullptr; + long targetCount = 0; + relation->get_relationType(&type); + relation->get_nTargets(&targetCount); + if (!first) json += ","; + first = false; + json += "{\"type\":" + json_bstr(type) + ",\"targets\":["; + for (long j = 0; j < targetCount; j++) { + IUnknown *target = nullptr; + if (j) json += ","; + if (SUCCEEDED(relation->get_target(j, &target)) && target) { + json += std::to_string(unique_id_of(target)); + target->Release(); + } else { + json += "0"; + } + } + json += "]}"; + relation->Release(); + } + json += "]"; + } + if (auto *textIface = ia2_interface(ia2)) { + long characterCount = 0; + textIface->get_nCharacters(&characterCount); + json += ",\"textLength\":" + std::to_string(characterCount); + if (!isProtected) { + BSTR content = nullptr; + if (SUCCEEDED(textIface->get_text(0, IA2_TEXT_OFFSET_LENGTH, &content))) json += ",\"text\":" + json_bstr(content); + long caret = 0; + if (textIface->get_caretOffset(&caret) == S_OK) json += ",\"caret\":" + std::to_string(caret); + } + textIface->Release(); + } + if (auto *hypertext = ia2_interface(ia2)) { + long linkCount = 0; + if (SUCCEEDED(hypertext->get_nHyperlinks(&linkCount)) && linkCount > 0) { + json += ",\"hyperlinks\":["; + for (long i = 0; i < linkCount; i++) { + IAccessibleHyperlink *link = nullptr; + if (i) json += ","; + long startIndex = -1, endIndex = -1; + if (SUCCEEDED(hypertext->get_hyperlink(i, &link)) && link) { + link->get_startIndex(&startIndex); + link->get_endIndex(&endIndex); + json += "[" + std::to_string(startIndex) + "," + std::to_string(endIndex) + "," + + std::to_string(unique_id_of(link)) + "]"; + link->Release(); + } else { + json += "null"; + } + } + json += "]"; + } + hypertext->Release(); + } + if (auto *action = ia2_interface(ia2)) { + long actionCount = 0; + if (SUCCEEDED(action->nActions(&actionCount)) && actionCount > 0) { + json += ",\"actions\":["; + for (long i = 0; i < actionCount; i++) { + BSTR actionName = nullptr; + if (i) json += ","; + json += SUCCEEDED(action->get_name(i, &actionName)) ? json_bstr(actionName) : "null"; + } + json += "]"; + } + action->Release(); + } + if (auto *table = ia2_interface(ia2)) { + long rows = 0, columns = 0; + table->get_nRows(&rows); + table->get_nColumns(&columns); + json += ",\"table\":{\"rows\":" + std::to_string(rows) + ",\"columns\":" + std::to_string(columns) + "}"; + table->Release(); + } + if (auto *cell = ia2_interface(ia2)) { + long row = 0, column = 0, rowExtent = 1, columnExtent = 1; + cell->get_rowIndex(&row); + cell->get_columnIndex(&column); + cell->get_rowExtent(&rowExtent); + cell->get_columnExtent(&columnExtent); + json += ",\"cell\":{\"row\":" + std::to_string(row) + ",\"column\":" + std::to_string(column) + + ",\"rowSpan\":" + std::to_string(rowExtent) + ",\"columnSpan\":" + std::to_string(columnExtent); + IUnknown **headers = nullptr; + long headerCount = 0; + if (SUCCEEDED(cell->get_columnHeaderCells(&headers, &headerCount))) + json += ",\"columnHeaders\":" + id_array(headers, headerCount); + headers = nullptr; + headerCount = 0; + if (SUCCEEDED(cell->get_rowHeaderCells(&headers, &headerCount))) + json += ",\"rowHeaders\":" + id_array(headers, headerCount); + json += "}"; + cell->Release(); + } + ia2->Release(); + } + + if (withChildren) { + json += ",\"children\":["; + long childCount = 0; + if (depth < MaxDepth && recordedNodes < MaxNodes && SUCCEEDED(accessible->get_accChildCount(&childCount)) && + childCount > 0) { + std::vector children(childCount); + long obtained = 0; + if (SUCCEEDED(AccessibleChildren(accessible, 0, childCount, children.data(), &obtained))) { + bool first = true; + for (long i = 0; i < obtained; i++) { + if (children[i].vt == VT_DISPATCH && children[i].pdispVal) { + IAccessible *child = nullptr; + if (SUCCEEDED(children[i].pdispVal->QueryInterface(IID_IAccessible, (void **)&child)) && child) { + if (!first) json += ","; + first = false; + node_record(child, uniqueId, true, depth + 1, json); + child->Release(); + } + } + VariantClear(&children[i]); + } + } + } + json += "]"; + if (recordedNodes >= MaxNodes) json += ",\"truncated\":true"; + } + json += "}"; +} + +// Follow accFocus from the window root to the focused object. +long focused_unique_id() { + IAccessible *current = windowRoot; + current->AddRef(); + for (int depth = 0; depth < 64; depth++) { + VARIANT focus; + VariantInit(&focus); + if (FAILED(current->get_accFocus(&focus))) break; + if (focus.vt != VT_DISPATCH || !focus.pdispVal) { + VariantClear(&focus); + break; + } + IAccessible *next = nullptr; + focus.pdispVal->QueryInterface(IID_IAccessible, (void **)&next); + VariantClear(&focus); + if (!next || next == current) { + if (next) next->Release(); + break; + } + current->Release(); + current = next; + } + long focusedId = unique_id_of(current); + current->Release(); + return focusedId; +} + +void send_tree() { + generation++; + parentOf.clear(); + recordedNodes = 0; + double startMs = now_ms(); + std::string json = "{\"type\":\"tree\",\"generation\":" + std::to_string(generation) + + ",\"focusedId\":" + std::to_string(focused_unique_id()) + ",\"root\":"; + node_record(windowRoot, 0, true, 0, json); + json += "}"; + send(json); + log_message("sent tree generation " + std::to_string(generation) + ": " + std::to_string(recordedNodes) + + " nodes in " + std::to_string((long)(now_ms() - startMs)) + " ms"); +} + +void send_subtree(long id) { + IAccessible *accessible = resolve(id); + if (!accessible) { + log_message("subtree " + std::to_string(id) + " no longer resolves; sending the whole tree"); + send_tree(); + return; + } + recordedNodes = 0; + auto parent = parentOf.find(id); + std::string json = "{\"type\":\"subtree\",\"generation\":" + std::to_string(generation) + ",\"node\":"; + node_record(accessible, parent == parentOf.end() ? 0 : parent->second, true, 0, json); + json += "}"; + accessible->Release(); + send(json); +} + +void send_node(long id) { + IAccessible *accessible = resolve(id); + if (!accessible) return; // already gone; a structural event will follow + recordedNodes = 0; + auto parent = parentOf.find(id); + std::string json = "{\"type\":\"node\",\"generation\":" + std::to_string(generation) + ",\"node\":"; + node_record(accessible, parent == parentOf.end() ? 0 : parent->second, false, 0, json); + json += "}"; + accessible->Release(); + send(json); +} + +std::string selection_json(IAccessibleText *text) { + long selectionCount = 0, start = 0, end = 0; + if (SUCCEEDED(text->get_nSelections(&selectionCount)) && selectionCount > 0 && + SUCCEEDED(text->get_selection(0, &start, &end))) + return "[" + std::to_string(start) + "," + std::to_string(end) + "]"; + return "null"; +} + +void send_caret(long id, bool selectionOnly) { + IAccessible *accessible = resolve(id); + if (!accessible) return; + IAccessible2 *ia2 = get_ia2(accessible); + IAccessibleText *text = ia2_interface(ia2); + if (text) { + std::string selection = selection_json(text); + if (selectionOnly) { + send("{\"type\":\"selection\",\"id\":" + std::to_string(id) + ",\"selection\":" + selection + "}"); + } else { + long caret = -1; + if (text->get_caretOffset(&caret) != S_OK) caret = -1; + send("{\"type\":\"caret\",\"id\":" + std::to_string(id) + ",\"caret\":" + std::to_string(caret) + + ",\"selection\":" + selection + "}"); + } + text->Release(); + } + if (ia2) ia2->Release(); + accessible->Release(); +} + +// ------------------------------------------------------------------ request handling + +// Requests are flat JSON objects written by the publisher; read one member. +bool member_long(const std::string &line, const char *key, long &value) { + std::string pattern = std::string("\"") + key + "\":"; + size_t position = line.find(pattern); + if (position == std::string::npos) return false; + const char *start = line.c_str() + position + pattern.size(); + char *end = nullptr; + long parsed = strtol(start, &end, 10); + if (end == start) return false; + value = parsed; + return true; +} + +std::string member_string(const std::string &line, const char *key) { + std::string pattern = std::string("\"") + key + "\":\""; + size_t position = line.find(pattern); + if (position == std::string::npos) return {}; + size_t start = position + pattern.size(); + size_t end = line.find('"', start); + return end == std::string::npos ? std::string() : line.substr(start, end - start); +} + +void reply(long requestId, HRESULT hr, const std::string &fields = "") { + send("{\"type\":\"reply\",\"requestId\":" + std::to_string(requestId) + ",\"ok\":" + + (SUCCEEDED(hr) ? "true" : "false") + ",\"hr\":" + std::to_string((long)hr) + fields + "}"); +} + +// Objects already resolved on the query thread. Resolving costs a +// get_accChild plus an IA2 QueryService (about 4-5 ms), and readers query the +// same objects repeatedly. A stale entry fails its call and is resolved again. +struct CachedObject { + IAccessible *accessible; + IAccessible2 *ia2; +}; +thread_local std::map objectCache; +constexpr size_t MaxCachedObjects = 2048; +constexpr long MaxExtentCharacters = 4096; + +void release_cached(CachedObject &entry) { + if (entry.ia2) entry.ia2->Release(); + entry.accessible->Release(); +} + +void forget_cached_object(long id) { + auto found = objectCache.find(id); + if (found == objectCache.end()) return; + release_cached(found->second); + objectCache.erase(found); +} + +// Owned references, or false when the object no longer resolves. +bool cached_object(long id, IAccessible **accessible, IAccessible2 **ia2) { + auto found = objectCache.find(id); + if (found == objectCache.end()) { + IAccessible *resolved = resolve(id); + if (!resolved) return false; + if (objectCache.size() >= MaxCachedObjects) { + for (auto &entry : objectCache) release_cached(entry.second); + objectCache.clear(); + } + found = objectCache.emplace(id, CachedObject{resolved, get_ia2(resolved)}).first; + } + *accessible = found->second.accessible; + (*accessible)->AddRef(); + *ia2 = found->second.ia2; + if (*ia2) (*ia2)->AddRef(); + return true; +} + +bool is_stale_result(HRESULT hr) { + return hr == E_FAIL || hr == RPC_E_DISCONNECTED || hr == CO_E_OBJNOTCONNECTED || hr == RPC_E_SERVER_DIED || + hr == RPC_E_SERVER_DIED_DNE; +} + +bool is_read_only_op(const std::string &op) { + return op == "extents" || op == "boundary" || op == "characterExtents" || op == "characterExtentsAll"; +} + +HRESULT perform_request(const std::string &op, const std::string &line, IAccessible *accessible, IAccessible2 *ia2, + std::string &fields) { + HRESULT hr = E_NOTIMPL; + fields.clear(); + long a = 0, b = 0, c = 0; + if (op == "action") { + member_long(line, "index", a); + IAccessibleAction *action = ia2_interface(ia2); + if (action) { + hr = action->doAction(a); + action->Release(); + } else if (a == 0) { + hr = accessible->accDoDefaultAction(selfChild); // views objects have no IA2 actions + } else { + hr = E_INVALIDARG; + } + } else if (op == "focus") { + hr = accessible->accSelect(SELFLAG_TAKEFOCUS, selfChild); + } else if (op == "extents") { + long left = 0, top = 0, width = 0, height = 0; + hr = accessible->accLocation(&left, &top, &width, &height, selfChild); + fields = ",\"extents\":[" + std::to_string(left) + "," + std::to_string(top) + "," + std::to_string(width) + + "," + std::to_string(height) + "]"; + } else if (op == "scrollTo") { + member_long(line, "scrollType", a); + hr = ia2 ? ia2->scrollTo((IA2ScrollType)a) : E_NOINTERFACE; + } else { + IAccessibleText *text = ia2_interface(ia2); + bool protectedText = is_protected(accessible); + if (!text) { + hr = E_NOINTERFACE; + } else if (op == "setCaret" && member_long(line, "offset", a)) { + hr = text->setCaretOffset(a); + } else if (op == "setSelection" && member_long(line, "start", a) && member_long(line, "end", b)) { + long selectionCount = 0; + text->get_nSelections(&selectionCount); + hr = selectionCount > 0 ? text->setSelection(0, a, b) : text->addSelection(a, b); + } else if (op == "scrollSubstring" && member_long(line, "start", a) && member_long(line, "end", b)) { + member_long(line, "scrollType", c); + hr = text->scrollSubstringTo(a, b, (IA2ScrollType)c); + } else if (op == "boundary" && member_long(line, "offset", a) && member_long(line, "granularity", b)) { + if (protectedText) { + hr = E_ACCESSDENIED; // boundaries would reveal word lengths + } else { + long startOffset = -1, endOffset = -1; + BSTR segment = nullptr; + hr = text->get_textAtOffset(a, (IA2TextBoundaryType)b, &startOffset, &endOffset, &segment); + SysFreeString(segment); + if (hr != S_OK) startOffset = endOffset = -1; + fields = ",\"start\":" + std::to_string(startOffset) + ",\"end\":" + std::to_string(endOffset); + if (SUCCEEDED(hr)) hr = S_OK; + } + } else if (op == "characterExtentsAll") { + // Every character's screen rectangle in one round trip; readers ask for + // range extents, which would otherwise cost one request per character. + long characterCount = 0; + text->get_nCharacters(&characterCount); + if (characterCount > MaxExtentCharacters) { + hr = E_INVALIDARG; + } else { + hr = S_OK; + fields = ",\"extents\":["; + for (long offset = 0; offset < characterCount; offset++) { + long x = 0, y = 0, width = 0, height = 0; + if (FAILED(text->get_characterExtents(offset, IA2_COORDTYPE_SCREEN_RELATIVE, &x, &y, &width, &height))) + x = y = width = height = 0; + if (offset) fields += ","; + fields += "[" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(width) + "," + + std::to_string(height) + "]"; + } + fields += "]"; + } + } else if (op == "characterExtents" && member_long(line, "offset", a)) { + long x = 0, y = 0, width = 0, height = 0; + hr = text->get_characterExtents(a, IA2_COORDTYPE_SCREEN_RELATIVE, &x, &y, &width, &height); + fields = ",\"extents\":[" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(width) + "," + + std::to_string(height) + "]"; + } else { + hr = E_INVALIDARG; + } + if (text) text->Release(); + } + return hr; +} + +void handle_request(const std::string &line) { + long requestId = 0, id = 0; + std::string op = member_string(line, "op"); + if (member_string(line, "type") != "request" || !member_long(line, "requestId", requestId) || op.empty()) { + log_message("malformed request ignored"); + return; + } + if (!member_long(line, "id", id)) { + reply(requestId, E_INVALIDARG); + return; + } + if (op == "refresh") { + pendingSubtreeRefreshes.insert(id); // performed with the next event batch + reply(requestId, S_OK); + return; + } + IAccessible *accessible = nullptr; + IAccessible2 *ia2 = nullptr; + if (!cached_object(id, &accessible, &ia2)) { + reply(requestId, E_FAIL, ",\"gone\":true"); + return; + } + std::string fields; + HRESULT hr = perform_request(op, line, accessible, ia2, fields); + if (is_stale_result(hr)) { + // The cached object may have died; resolve it afresh. Only read-only + // queries are retried, so an action can never run twice. + if (ia2) ia2->Release(); + accessible->Release(); + ia2 = nullptr; + forget_cached_object(id); + if (!is_read_only_op(op)) { + reply(requestId, hr, fields); + return; + } + if (!cached_object(id, &accessible, &ia2)) { + reply(requestId, E_FAIL, ",\"gone\":true"); + return; + } + hr = perform_request(op, line, accessible, ia2, fields); + } + if (ia2) ia2->Release(); + accessible->Release(); + reply(requestId, hr, fields); +} + +// ------------------------------------------------------------------ events + +struct QueuedEvent { + DWORD event; + HWND hwnd; + LONG idObject; + LONG idChild; +}; +std::vector eventQueue; +double firstEventMs, lastEventMs; +long droppedEvents; + +bool belongs_to_target(HWND hwnd) { + return hwnd == targetWindow || IsChild(targetWindow, hwnd); +} + +void CALLBACK win_event_proc(HWINEVENTHOOK, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD, DWORD) { + if (event == EVENT_SYSTEM_FOREGROUND) { + eventQueue.push_back({event, hwnd, idObject, idChild}); + lastEventMs = now_ms(); + if (eventQueue.size() == 1) firstEventMs = lastEventMs; + return; + } + if (!hwnd || !belongs_to_target(hwnd)) return; + // Caret location changes flood while typing and navigating and say nothing + // about layout; drop them here. + if (event == EVENT_OBJECT_LOCATIONCHANGE && idObject != OBJID_CLIENT) return; + if (eventQueue.size() >= MaxQueuedEvents) { + droppedEvents++; + return; + } + if (eventQueue.empty()) firstEventMs = now_ms(); + lastEventMs = now_ms(); + eventQueue.push_back({event, hwnd, idObject, idChild}); +} + +bool is_property_event(DWORD event) { + switch (event) { + case EVENT_OBJECT_STATECHANGE: case EVENT_OBJECT_NAMECHANGE: case EVENT_OBJECT_VALUECHANGE: + case EVENT_OBJECT_DESCRIPTIONCHANGE: case IA2_EVENT_TEXT_INSERTED: case IA2_EVENT_TEXT_REMOVED: + case IA2_EVENT_TEXT_UPDATED: case IA2_EVENT_TEXT_CHANGED: case IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED: + case IA2_EVENT_TEXT_ATTRIBUTE_CHANGED: case IA2_EVENT_HYPERTEXT_CHANGED: case IA2_EVENT_HYPERTEXT_NLINKS_CHANGED: + case IA2_EVENT_ACTION_CHANGED: + return true; + default: + return false; + } +} + +// Events that move content on screen. A location change of the caret object +// (OBJID_CARET) only means the caret moved; treating it as layout would +// discard every cached boundary and position on each arrow press. +bool is_layout_event(const QueuedEvent &queued) { + if (queued.event == EVENT_OBJECT_LOCATIONCHANGE) return queued.idObject == OBJID_CLIENT; + return queued.event == EVENT_SYSTEM_SCROLLINGSTART || queued.event == EVENT_SYSTEM_SCROLLINGEND || + queued.event == IA2_EVENT_VISIBLE_DATA_CHANGED || queued.event == 0x8015; +} + +bool has_ancestor_in(long id, const std::set &ids) { + for (int guard = 0; guard < MaxDepth; guard++) { + auto parent = parentOf.find(id); + if (parent == parentOf.end()) return false; + id = parent->second; + if (ids.count(id)) return true; + } + return false; +} + +long parent_from_provider(long id) { + IAccessible *accessible = resolve(id); + if (!accessible) return 0; + IDispatch *parentDispatch = nullptr; + long parentId = 0; + if (SUCCEEDED(accessible->get_accParent(&parentDispatch)) && parentDispatch) { + parentId = unique_id_of(parentDispatch); + parentDispatch->Release(); + } + accessible->Release(); + return parentId; +} + +// Translate one coalesced batch of events into messages, in an order the +// publisher can apply directly: structure, then properties, then focus, +// caret, selection, and layout. +void process_events_inner(std::vector &batch); + +void process_events() { + std::vector batch; + batch.swap(eventQueue); + double startMs = now_ms(); + size_t batchSize = batch.size(); + std::map kinds; + for (const QueuedEvent &queued : batch) kinds[queued.event]++; + process_events_inner(batch); + double elapsedMs = now_ms() - startMs; + if (elapsedMs > 100) { + std::string summary; + for (const auto &entry : kinds) { + char item[48]; + snprintf(item, sizeof(item), " 0x%lx:%d", (unsigned long)entry.first, entry.second); + summary += item; + } + log_message("slow event batch: " + std::to_string(batchSize) + " events in " + std::to_string((long)elapsedMs) + + " ms," + summary); + } +} + +void process_events_inner(std::vector &batch) { + if (droppedEvents) { + log_message("event queue overflowed (" + std::to_string(droppedEvents) + " dropped); resynchronizing"); + droppedEvents = 0; + send_tree(); + send("{\"type\":\"flush\"}"); + return; + } + bool fullTree = false, layout = false; + std::set subtrees = pendingSubtreeRefreshes; + pendingSubtreeRefreshes.clear(); + std::vector nodes, carets, selections, anchors; + long focusId = 0; + int foreground = -1; + for (const QueuedEvent &queued : batch) { + if (queued.event == EVENT_SYSTEM_FOREGROUND) { + foreground = belongs_to_target(queued.hwnd) ? 1 : 0; + continue; + } + if (queued.event == EVENT_OBJECT_DESTROY && queued.hwnd == targetWindow && queued.idObject == OBJID_WINDOW) { + send("{\"type\":\"gone\"}"); + ExitProcess(0); + } + if (is_layout_event(queued)) { + layout = true; + // Chromium reports scrolling to an anchor as SCROLLINGSTART on the target. + if (queued.event == EVENT_SYSTEM_SCROLLINGSTART && queued.idObject == OBJID_CLIENT && + queued.idChild != CHILDID_SELF) + anchors.push_back(queued.idChild); + continue; + } + if (queued.idObject != OBJID_CLIENT) continue; + long id = queued.idChild; + switch (queued.event) { + case IA2_EVENT_DOCUMENT_LOAD_COMPLETE: case IA2_EVENT_DOCUMENT_RELOAD: + // The event names the document; refresh just that subtree when it is + // known, otherwise resend everything. + if (parentOf.count(id)) subtrees.insert(id); + else fullTree = true; + break; + case EVENT_OBJECT_REORDER: case IA2_EVENT_ROLE_CHANGED: + subtrees.insert(queued.event == IA2_EVENT_ROLE_CHANGED && parentOf.count(id) ? parentOf[id] : id); + break; + case EVENT_OBJECT_SHOW: { + long parentId = parent_from_provider(id); + if (!parentId && parentOf.count(id)) parentId = parentOf[id]; + if (parentId) subtrees.insert(parentId); + else fullTree = true; + break; + } + case EVENT_OBJECT_HIDE: + if (parentOf.count(id)) subtrees.insert(parentOf[id]); + break; // an object never sent needs no removal + case EVENT_OBJECT_FOCUS: + focusId = id; + nodes.push_back(id); + break; + case IA2_EVENT_TEXT_CARET_MOVED: + carets.push_back(id); + break; + case IA2_EVENT_TEXT_SELECTION_CHANGED: case 0x8014: + selections.push_back(id); + break; + default: + if (is_property_event(queued.event)) nodes.push_back(id); + break; + } + } + if (fullTree) { + send_tree(); + } else { + for (long id : subtrees) + if (!has_ancestor_in(id, subtrees)) send_subtree(id); + } + // Native Chromium order: the newly focused object's caret, then focus, then + // property changes (such as checked); while typing, text changes before the + // caret. So: focus target's caret, focus, node updates, remaining carets. + std::set sentCarets; + if (focusId) { + if (std::find(carets.begin(), carets.end(), focusId) != carets.end()) { + send_caret(focusId, false); + sentCarets.insert(focusId); + } + send("{\"type\":\"focus\",\"id\":" + std::to_string(focusId) + "}"); + } + if (!fullTree) { + std::set sentNodes; + for (long id : nodes) { + if (subtrees.count(id) || has_ancestor_in(id, subtrees) || !sentNodes.insert(id).second) continue; + send_node(id); + } + } + for (auto it = carets.rbegin(); it != carets.rend(); ++it) + if (sentCarets.insert(*it).second) send_caret(*it, false); + std::set sentSelections; + for (long id : selections) + if (!sentCarets.count(id) && sentSelections.insert(id).second) send_caret(id, true); + if (layout) send("{\"type\":\"layout\"}"); + for (long id : anchors) send("{\"type\":\"anchor\",\"id\":" + std::to_string(id) + "}"); + if (foreground >= 0) send(std::string("{\"type\":\"foreground\",\"active\":") + (foreground ? "true" : "false") + "}"); + send("{\"type\":\"flush\"}"); +} + +// Synchronous queries and actions run on their own COM apartment, so the main +// thread's event walks never delay a reader's query. +DWORD WINAPI query_thread(LPVOID ready) { + CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + MSG message; + PeekMessageW(&message, nullptr, WM_USER, WM_USER, PM_NOREMOVE); // create the queue + refresh_resolution_roots(); + SetEvent((HANDLE)ready); + while (GetMessageW(&message, nullptr, 0, 0) > 0) { + if (message.message == WM_APP_REQUEST) { + handle_posted_request(message.lParam); + } else { + TranslateMessage(&message); + DispatchMessageW(&message); + } + } + for (auto &entry : objectCache) release_cached(entry.second); + objectCache.clear(); + for (auto &entry : resolutionRoots) entry.second->Release(); + resolutionRoots.clear(); + CoUninitialize(); + return 0; +} + +// Handle one request posted by the input thread, logging slow ones: the time +// spent waiting in the queue and the time spent answering. +void handle_posted_request(LPARAM parameter) { + auto *request = reinterpret_cast(parameter); + double startMs = now_ms(); + handle_request(request->line); + double doneMs = now_ms(); + if (doneMs - request->receivedMs > 100) + log_message("slow request: waited " + std::to_string((long)(startMs - request->receivedMs)) + " ms, answered in " + + std::to_string((long)(doneMs - startMs)) + " ms: op " + member_string(request->line, "op")); + delete request; +} + +// ------------------------------------------------------------------ startup + +DWORD WINAPI input_thread(LPVOID) { + HANDLE input = GetStdHandle(STD_INPUT_HANDLE); + std::string buffer; + char chunk[4096]; + DWORD readBytes = 0; + while (ReadFile(input, chunk, sizeof(chunk), &readBytes, nullptr) && readBytes > 0) { + buffer.append(chunk, readBytes); + size_t newline; + while ((newline = buffer.find('\n')) != std::string::npos) { + auto *request = new PendingRequest{buffer.substr(0, newline), now_ms()}; + buffer.erase(0, newline + 1); + // Refreshes change what the main thread sends; everything else is a + // query or an action for the query thread. + DWORD target = member_string(request->line, "op") == "refresh" ? mainThreadId : queryThreadId; + if (!PostThreadMessageW(target, WM_APP_REQUEST, 0, (LPARAM)request)) delete request; + } + if (buffer.size() > (1u << 20)) buffer.clear(); // never let a broken peer grow memory + } + PostThreadMessageW(queryThreadId, WM_QUIT, 0, 0); + PostThreadMessageW(mainThreadId, WM_APP_INPUT_CLOSED, 0, 0); + return 0; +} + +struct FindWindowState { + std::wstring titlePart; + HWND found = nullptr; +}; + +BOOL CALLBACK find_window_proc(HWND hwnd, LPARAM param) { + auto *state = reinterpret_cast(param); + wchar_t title[512] = {0}, className[256] = {0}; + GetWindowTextW(hwnd, title, 512); + GetClassNameW(hwnd, className, 256); + if (wcsstr(className, L"Chrome_WidgetWin") && wcsstr(title, state->titlePart.c_str()) && IsWindowVisible(hwnd)) { + state->found = hwnd; + return FALSE; + } + return TRUE; +} + +// Pump everything except publisher requests, which stay queued for the main loop. +void pump(double milliseconds) { + double endMs = now_ms() + milliseconds; + while (now_ms() < endMs) { + MSG message; + while (PeekMessageW(&message, nullptr, 0, WM_APP_REQUEST - 1, PM_REMOVE) || + PeekMessageW(&message, nullptr, WM_APP_REQUEST + 1, 0xFFFFFFFF, PM_REMOVE)) { + TranslateMessage(&message); + DispatchMessageW(&message); + } + MsgWaitForMultipleObjects(0, nullptr, FALSE, 20, QS_ALLINPUT); + } +} + +bool document_has_content(IAccessible *accessible, int depth = 0) { + VARIANT roleValue; + VariantInit(&roleValue); + if (SUCCEEDED(accessible->get_accRole(selfChild, &roleValue)) && roleValue.vt == VT_I4 && + roleValue.lVal == ROLE_SYSTEM_DOCUMENT) { + long childCount = 0; + accessible->get_accChildCount(&childCount); + return childCount > 0; + } + VariantClear(&roleValue); + long childCount = 0; + if (depth > 40 || FAILED(accessible->get_accChildCount(&childCount)) || childCount <= 0) return false; + std::vector children(childCount); + long obtained = 0; + if (FAILED(AccessibleChildren(accessible, 0, childCount, children.data(), &obtained))) return false; + bool found = false; + for (long i = 0; i < obtained; i++) { + if (!found && children[i].vt == VT_DISPATCH && children[i].pdispVal) { + IAccessible *child = nullptr; + if (SUCCEEDED(children[i].pdispVal->QueryInterface(IID_IAccessible, (void **)&child)) && child) { + found = document_has_content(child, depth + 1); + child->Release(); + } + } + VariantClear(&children[i]); + } + return found; +} + +void default_action_sweep(IAccessible *accessible, int depth = 0) { + BSTR text = nullptr; + accessible->get_accDefaultAction(selfChild, &text); + SysFreeString(text); + long childCount = 0; + if (depth > 40 || FAILED(accessible->get_accChildCount(&childCount)) || childCount <= 0) return; + std::vector children(childCount); + long obtained = 0; + if (FAILED(AccessibleChildren(accessible, 0, childCount, children.data(), &obtained))) return; + for (long i = 0; i < obtained; i++) { + if (children[i].vt == VT_DISPATCH && children[i].pdispVal) { + IAccessible *child = nullptr; + if (SUCCEEDED(children[i].pdispVal->QueryInterface(IID_IAccessible, (void **)&child)) && child) { + default_action_sweep(child, depth + 1); + child->Release(); + } + } + VariantClear(&children[i]); + } +} + +// Chromium exposes web content only after a client looks like a screen +// reader. The measured trigger is accDefaultAction on the pre-activation +// tree; verify the result instead of trusting it. +bool activate_web_content() { + if (document_has_content(windowRoot)) return true; + default_action_sweep(windowRoot); + double deadlineMs = now_ms() + 10000; + while (now_ms() < deadlineMs) { + pump(100); + if (document_has_content(windowRoot)) return true; + } + return false; +} + +} // namespace + +int wmain(int argc, wchar_t **argv) { + QueryPerformanceFrequency(&perfFrequency); + std::wstring titlePart; + HWND hwndArgument = nullptr; + double waitWindowSeconds = 30; + for (int i = 1; i < argc; i++) { + std::wstring arg = argv[i]; + auto next = [&]() -> std::wstring { return i + 1 < argc ? argv[++i] : L""; }; + if (arg == L"--title") titlePart = next(); + else if (arg == L"--hwnd") hwndArgument = (HWND)(ULONG_PTR)_wcstoui64(next().c_str(), nullptr, 10); + else if (arg == L"--wait-window") waitWindowSeconds = _wtof(next().c_str()); + else { + log_message("unknown argument"); + return 2; + } + } + if (titlePart.empty() && !hwndArgument) { + log_message("usage: wine-access-browser-worker.exe (--hwnd DECIMAL | --title TEXT) [--wait-window SECONDS]"); + return 2; + } + + InitializeCriticalSection(&outputLock); + mainThreadId = GetCurrentThreadId(); + MSG message; + PeekMessageW(&message, nullptr, WM_USER, WM_USER, PM_NOREMOVE); // create the queue before the input thread posts + CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + if (hwndArgument) { + targetWindow = IsWindow(hwndArgument) ? hwndArgument : nullptr; + } else { + FindWindowState state; + state.titlePart = titlePart; + double deadlineMs = now_ms() + waitWindowSeconds * 1000.0; + while (!state.found && now_ms() < deadlineMs) { + EnumWindows(find_window_proc, (LPARAM)&state); + if (!state.found) pump(250); + } + targetWindow = state.found; + } + if (!targetWindow) { + log_message("browser window not found"); + send("{\"type\":\"gone\"}"); + return 3; + } + GetWindowThreadProcessId(targetWindow, &targetProcessId); + if (FAILED(AccessibleObjectFromWindow(targetWindow, (DWORD)OBJID_CLIENT, IID_IAccessible, (void **)&windowRoot)) || + !windowRoot) { + log_message("AccessibleObjectFromWindow failed"); + send("{\"type\":\"gone\"}"); + return 3; + } + wchar_t title[512] = {0}; + GetWindowTextW(targetWindow, title, 512); + HANDLE x11Window = GetPropW(targetWindow, L"__wine_x11_whole_window"); + send("{\"type\":\"hello\",\"protocol\":" + std::to_string(ProtocolVersion) + ",\"hwnd\":" + + std::to_string((unsigned long long)(ULONG_PTR)targetWindow) + ",\"windowsPid\":" + + std::to_string(targetProcessId) + ",\"x11Window\":" + std::to_string((unsigned long long)(ULONG_PTR)x11Window) + + ",\"title\":" + json_quote_utf8(to_utf8(title, wcslen(title))) + + ",\"foreground\":" + (GetForegroundWindow() == targetWindow ? "true" : "false") + "}"); + + HWINEVENTHOOK objectHook = SetWinEventHook(EVENT_MIN, EVENT_MAX, nullptr, win_event_proc, targetProcessId, 0, + WINEVENT_OUTOFCONTEXT); + HWINEVENTHOOK foregroundHook = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, nullptr, + win_event_proc, 0, 0, WINEVENT_OUTOFCONTEXT); + if (!objectHook || !foregroundHook) log_message("SetWinEventHook failed"); + + if (!activate_web_content()) log_message("web content did not appear after activation; publishing what exists"); + refresh_resolution_roots(); + HANDLE queryReady = CreateEventW(nullptr, TRUE, FALSE, nullptr); + HANDLE queryThread = CreateThread(nullptr, 0, query_thread, queryReady, 0, &queryThreadId); + WaitForSingleObject(queryReady, 10000); + CloseHandle(queryReady); + { + std::string rootClasses; + for (const auto &entry : resolutionRoots) { + wchar_t className[256] = {0}; + GetClassNameW(entry.first, className, 256); + rootClasses += " " + to_utf8(className, wcslen(className)); + } + log_message("resolution roots:" + rootClasses); + } + send_tree(); + CloseHandle(CreateThread(nullptr, 0, input_thread, nullptr, 0, nullptr)); + + bool running = true; + while (running) { + DWORD timeout = eventQueue.empty() && pendingSubtreeRefreshes.empty() ? 1000 : 10; + MsgWaitForMultipleObjects(0, nullptr, FALSE, timeout, QS_ALLINPUT); + while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) { + if (message.message == WM_APP_REQUEST) { + handle_posted_request(message.lParam); + } else if (message.message == WM_APP_INPUT_CLOSED) { + running = false; + } else { + TranslateMessage(&message); + DispatchMessageW(&message); + } + } + // Coalesce bursts: wait for 25 ms of quiet, but never longer than 150 ms. + double nowMs = now_ms(); + if ((!eventQueue.empty() && (nowMs - lastEventMs >= 25 || nowMs - firstEventMs >= 150)) || + (eventQueue.empty() && !pendingSubtreeRefreshes.empty())) + process_events(); + if (!IsWindow(targetWindow)) { + send("{\"type\":\"gone\"}"); + running = false; + } + } + PostThreadMessageW(queryThreadId, WM_QUIT, 0, 0); + WaitForSingleObject(queryThread, 5000); + CloseHandle(queryThread); + for (auto &entry : resolutionRoots) entry.second->Release(); + if (objectHook) UnhookWinEvent(objectHook); + if (foregroundHook) UnhookWinEvent(foregroundHook); + windowRoot->Release(); + CoUninitialize(); + return 0; +} diff --git a/distro-packages/ArchLinux/wine-access-git/PKGBUILD b/distro-packages/ArchLinux/wine-access-git/PKGBUILD index 1380f75..2c4df3a 100644 --- a/distro-packages/ArchLinux/wine-access-git/PKGBUILD +++ b/distro-packages/ArchLinux/wine-access-git/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc='Wine accessibility helper with MSAA, NVDA Controller, and Tolk compatib arch=('x86_64') url='https://git.stormux.org/storm/wine-access' license=('LGPL-2.1-or-later') -depends=('glib2' 'wine' 'libxcb') +depends=('glib2' 'wine' 'libxcb' 'at-spi2-core' 'json-glib' 'libx11') makedepends=('cmake' 'git' 'pkgconf' 'mingw-w64-gcc') optdepends=('orca>=51: Orca screen reader integration') provides=('wine-access') diff --git a/docs/browser.md b/docs/browser.md new file mode 100644 index 0000000..1b90610 --- /dev/null +++ b/docs/browser.md @@ -0,0 +1,119 @@ +# Browser accessibility (Chromium under Wine) + +Wine Access publishes Windows Chromium windows (Electron, CEF and other +Chromium hosts) on the Linux accessibility bus so that Cthulhu and Orca read +them with their own browser support: browse and focus modes, structural +navigation, tables, forms, live regions, speech and Braille. It is on for every +Chromium window the helper sees; there is no switch to turn it off. + +## Components + +```text +Chromium window in a Wine prefix + | MSAA + IAccessible2, cross-process through Wine's ia2comproxy.dll +wine-access-browser-worker.exe (PE, one per window, inside the prefix) + | JSON lines over stdin/stdout +wine-access-browser-publisher (native Linux, ATK + atk-bridge) + | AT-SPI on the accessibility bus, toolkit "Chromium" +Cthulhu / Orca browser support +``` + +- The helper (`browser_bridge.cpp`) starts one publisher for each visible + top-level `Chrome_WidgetWin_1` window that contains a + `Chrome_RenderWidgetHostHWND`. The publisher starts the worker through the + prefix's own Wine loader (`WINELOADER`, which both readers pass, or the + helper's preloader) so it joins the same wineserver. +- When the publisher prints `published`, the helper stops legacy + announcements (WinEvent presentation, control polling) for that window; + otherwise every change would be spoken twice. If the publisher exits while + the window still exists, the window returns to legacy announcements and the + helper retries with backoff (at most three failures per window). +- Publishers follow the helper: they receive SIGTERM when it dies, because + readers stop the helper with a signal that skips its shutdown code. The + worker exits when its input closes. +- The publisher re-executes itself with `WINE_ACCESS_BROWSER_PUBLISHER=1` in + its environment and gives each frame a `wine-access-x11-window` attribute. + Readers that compare the accessible window's PID with the X11 window owner + (Cthulhu) use these to accept the publisher for that window only: same user, + same prefix, matching window. Orca checks window state, not PIDs. + +## Worker (`browser_worker.cpp`) + +- Activation: Chromium exposes web content only to clients that look like + screen readers. The worker calls `accDefaultAction` on every object of the + initial window tree (the measured trigger), then verifies that content + appeared. +- Identity: objects are keyed by IA2 `uniqueID`. Web content resolves through + the `Chrome_RenderWidgetHostHWND` child's root, browser UI through the + top-level window. +- Threads: the main thread owns the WinEvent hook and sends tree updates; a + query thread with its own COM apartment answers the publisher's synchronous + queries and actions, so long refreshes never delay a reader. Each thread + caches its resolved objects; a stale object is resolved again, and only + read-only queries are retried. +- Events are coalesced per batch and sent in native order: structure, the + newly focused object's caret, focus, property changes, remaining carets and + selections, layout, anchors, then `flush`. +- Privacy: protected (password) text, values and boundaries never leave the + worker; only the length is sent. + +## Publisher (`browser_publisher.c`) + +The publisher's output must match native Linux Chromium for the same page. +Rules established by comparison with native Chromium 158 and Electron 42: + +- Roles follow `map_role`; pairings not yet covered by the fixture are marked. +- Every object exposes Action, Component, Document and Text; text fields lack + Hypertext; everything except DOM text leaves is a hyperlink implementation. +- Chromium's views layer (browser UI) has no IA2 links or actions: links are + rebuilt when its text is one embedded-object character per child, actions + come from the MSAA default action plus `showContextMenu`, and internal + `view_N` ids are dropped. Never inside web content. +- Exactly one focused object (the end of the window's `accFocus` chain); no + read-only state on documents and lists; header cells report no header cells. +- Offsets convert explicitly between UTF-16 (Windows) and characters + (AT-SPI). Boundaries inside a surrogate pair round to whole characters; + native Chromium reports such a word end as `-1`. +- Word, sentence, line and paragraph boundaries come from IA2 + `get_textAtOffset` on demand (they depend on layout); at the end of the text + no segment is reported. Character and range extents come from one batched + request per object. Both are cached until the text or the layout changes. +- Events: removals and text changes are emitted at once, additions at the end + of the worker's batch in document order. When a container's children + change, its text is reported as wholly replaced (nothing for text made only + of embedded objects). Scrolling to an anchor moves the caret to the target. +- The frame's extents come from the X11 window, which readers compare with the + window manager's view of the foreground window. +- Every few seconds of activity the publisher logs synchronous request counts + and times; `WINE_ACCESS_BROWSER_TRACE=1` logs every worker message. + +## Verification + +- `ctest -R browser-publisher-snapshot`: publishes a recorded Electron 45 + snapshot (no Wine) and compares the tree, including text boundaries, with + native Chromium 158 and Electron 42. +- `tests/browser/live_checks.sh BUILD_DIR PREFIX`: needs native Chromium and a + prefix with Electron (`WINE_ACCESS_BROWSER_TEST_ELECTRON`, default + `C:\electron\v45\electron.exe`). Runs the worker protocol checks, the + helper lifecycle (publish, no legacy announcements, restart, no orphans), + and the same scripted scenario natively and through the bridge, comparing + trees and AT-SPI event sequences and checking that no password characters + appear. +- Every test runs through `tests/browser/private_session.sh`: a private + runtime directory and no display for the private D-Bus session, with a + tripwire on the user's display. A bare `dbus-run-session` can take over the + user's accessibility bus socket or advertise the test bus on the user's + display. + +Recorded results do not prove audible speech, Braille or keyboard behavior; +check those live with each reader. + +## Limitations + +- Full Chrome does not start under Wine 11.22 (missing + `user32.GetPointerDevice`); Electron and other embedded Chromium work. +- Firefox, WebView2 (a Chromium window inside another application's window), + 32-bit browsers and iframes are untested. +- Each Chromium window is its own AT-SPI application. +- The frame's active state follows Wine's foreground events; a Linux window + taking focus may not always deactivate it. diff --git a/main.cpp b/main.cpp index 987877c..fec6d12 100644 --- a/main.cpp +++ b/main.cpp @@ -12,6 +12,7 @@ #include "foreground_hooks.h" #include "hook_exclusions.h" #include "reader_endpoint.h" +#include "browser_bridge.h" #include "msaa_events.h" #include "reader_events.h" #include "bootstrapper_controls.h" @@ -48,6 +49,9 @@ GDBusConnection *connection = nullptr; ReviewIdentityStore reviewIdentities; ReviewService reviewService; MsaaEventReader msaaEvents; +// Event-thread owned. Chromium windows it has published are presented through +// AT-SPI by the reader's browser support; legacy announcements skip them. +BrowserBridge browserBridge; BootstrapperControlReader bootstrapperReader; HWND lastBootstrapperWindow = nullptr; std::string lastBootstrapperIdentity, lastBootstrapperPresentation; @@ -537,7 +541,7 @@ void poll_control_focus(bool refresh = false) { GUITHREADINFO info{}; info.cbSize = sizeof(info); HWND foreground = GetForegroundWindow(); - const bool focused = foreground && !hook_excluded_window(foreground) && + const bool focused = foreground && !hook_excluded_window(foreground) && !browserBridge.owns(foreground) && GetGUIThreadInfo(GetWindowThreadProcessId(foreground, nullptr), &info) && !(info.flags & GUI_INMENUMODE); HWND bootstrapper = focused && info.hwndFocus == foreground && @@ -905,6 +909,7 @@ HANDLE start_menu_host32(HWND bridge) { void CALLBACK winevent_callback(HWINEVENTHOOK, DWORD event, HWND window, LONG objectId, LONG childId, DWORD, DWORD) { + browserBridge.window_event(window, event); const bool presentationEvent = event == EVENT_OBJECT_FOCUS || event == EVENT_OBJECT_NAMECHANGE || event == EVENT_OBJECT_VALUECHANGE || event == EVENT_OBJECT_SELECTION || event == EVENT_OBJECT_STATECHANGE; if (presentationEvent && !msaa_event_in_foreground(window)) return; @@ -931,6 +936,10 @@ void CALLBACK winevent_callback(HWINEVENTHOOK, DWORD event, HWND window, // already retired the previous application's pending events. if (hook_excluded_window(window)) return; + // A published browser window is presented through AT-SPI; announcing it + // here too would speak every change twice. + if (browserBridge.owns(window)) + return; if (HWND combo = combo_event_control(window, event)) { // The combo's internal list can emit focus events even while the combo // retains keyboard focus. Keep a single source for focus and value updates. @@ -979,6 +988,7 @@ bool current_msaa_source(const MsaaEvent &source) { void present_msaa_result(const MsaaResult &result) { const auto &source = result.source; if (!current_msaa_source(source) || GetTickCount64() >= source.deadline) return; + if (browserBridge.owns(source.window)) return; // published after this event was queued if (source.event == EVENT_OBJECT_FOCUS && pendingMsaaFocus.generation == source.generation) pendingMsaaFocus = {}; HWND window = source.window; @@ -1391,6 +1401,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) { editReaderActive = editReaderActive || menuHost32 != nullptr; } } + const bool browserBridgeActive = dialogReaderEnabled && browserBridge.start(); MSG message{}; // Native lists, tabs, trees and combo boxes can omit change WinEvents in Wine. // Observe only the foreground control; never read background selections. @@ -1406,7 +1417,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) { "\"controller\":%s,\"review\":%s,\"msaa_worker\":%s,\"win_events\":%s," "\"menu_hook\":%s,\"input_hook\":%s," "\"menu_hook_available\":%s,\"input_hook_available\":%s," - "\"host32_started\":%s,\"control_poll\":%s}\n", + "\"host32_started\":%s,\"control_poll\":%s,\"browser_bridge\":%s}\n", readerEndpoint.busName, dialogReaderEnabled ? "true" : "false", hookExclusions.count, controllerActive ? "true" : "false", reviewActive ? "true" : "false", @@ -1414,7 +1425,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) { foregroundHooks.menu ? "true" : "false", foregroundHooks.input ? "true" : "false", foregroundHooks.menu_callback ? "true" : "false", foregroundHooks.input_callback ? "true" : "false", - menuHost32 ? "true" : "false", listTimer ? "true" : "false"); + menuHost32 ? "true" : "false", listTimer ? "true" : "false", + browserBridgeActive ? "true" : "false"); while (GetMessageW(&message, nullptr, 0, 0) > 0) { if (listTimer && message.message == WM_TIMER && message.hwnd == nullptr && message.wParam == listTimer) { @@ -1430,12 +1442,14 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, char *, int) { wine_access_update_hooks(&foregroundHooks, FALSE); poll_control_focus(); reviewService.focus_changed(reviewIdentities.observe_foreground()); + browserBridge.poll(); continue; } TranslateMessage(&message); DispatchMessageW(&message); } if (listTimer) KillTimer(nullptr, listTimer); + browserBridge.stop(); readerEvents.stop(); msaaEvents.stop(); bootstrapperReader.stop(); diff --git a/tests/README.md b/tests/README.md index 40eee0c..54f640a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -911,3 +911,52 @@ If startup fails, retain the identity/startup diagnostics and the actual runner/prefix information before changing configuration. Review debug logs for private text before sharing. Check controller-only exclusions using the procedure above when the application requires them. + +## Browser accessibility + +Design, mapping rules and limitations are in [docs/browser.md](../docs/browser.md). +Every browser test runs through `tests/browser/private_session.sh`, which gives +its D-Bus session a private runtime directory and no display. A bare +`dbus-run-session` is not enough: the accessibility bus launcher can take over +the user's accessibility bus socket, or advertise the test bus on the user's +display, and the running reader would then lose or receive the test's objects. + +The CTest needs no Wine. It publishes a recorded Electron 45 snapshot and +compares the tree, including word, sentence, line and paragraph boundaries, +with native Chromium 158 and Electron 42 (`tests/browser/data/`): + +```sh +ctest --test-dir build -R browser-publisher-snapshot --output-on-failure +``` + +The live checks need native Chromium (`chromium`, or +`WINE_ACCESS_BROWSER_TEST_CHROMIUM`) and a Wine prefix with Electron installed +(`C:\electron\v45\electron.exe`, or `WINE_ACCESS_BROWSER_TEST_ELECTRON`). +They copy the fixture app from `tests/browser/fixture-app/` into the prefix: + +```sh +tests/browser/live_checks.sh build /path/to/electron-prefix +``` + +They cover the worker protocol (including that a typed password never leaves +the worker), the helper lifecycle (publishing, no legacy announcements while +typing in a published window, restarting a killed publisher, no orphaned +publisher or worker), and one scripted scenario run natively and through the +bridge, comparing the trees and AT-SPI event sequences. Allowed differences are +listed with their reasons in `compare_dumps.py` and `compare_events.py`. +`WINE_ACCESS_BROWSER_TRACE=1` logs every worker message. + +Live acceptance with each reader, using an Electron app (for example the +fixture app run with `wine electron.exe C:\wine-access-browser-test`): + +1. The window and page are announced and browse mode starts. +2. Headings, links, form fields and the table navigate by their usual keys; + arrowing through text, including emoji, reads normally and promptly. +3. Typing in a text field echoes characters once, without role or name; + typing in the password field never speaks the characters. +4. The checkbox toggles, the Add item button's live region is announced, and + the in-page link moves to its target heading. +5. Switching to another window and back follows focus, and keys are not + swallowed or delivered to the wrong window. +6. The helper log shows `browser publisher ... published`; publisher request + statistics show no timeouts. diff --git a/tests/browser/atspi_dump.py b/tests/browser/atspi_dump.py new file mode 100755 index 0000000..95e1625 --- /dev/null +++ b/tests/browser/atspi_dump.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python3 +"""Dump an application's AT-SPI tree as plain text, for comparing the Wine +Access publisher against native Linux Chromium on the same fixture. + +Usage: atspi_dump.py --app-name NAME [--wait SECONDS] [--max-nodes N] +Waits for an application whose name contains NAME (case ignored) and a +document-web descendant with children, then prints the tree. Never prints +the text of password-text objects. +""" + +import argparse +import sys +import time +import warnings + +import gi + +gi.require_version("Atspi", "2.0") +from gi.repository import Atspi # noqa: E402 + +# get_action_name is deprecated, but its replacement fails through PyGObject. +warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*get_action_name.*") + +nodeCount = 0 +showBoundaries = False +GRANULARITIES = (("word", Atspi.TextGranularity.WORD), ("sentence", Atspi.TextGranularity.SENTENCE), + ("line", Atspi.TextGranularity.LINE), ("paragraph", Atspi.TextGranularity.PARAGRAPH)) + + +def boundary_segments(accessible, characterCount, granularity): + """Distinct (start, end) segments reported at every offset.""" + segments = [] + for offset in range(characterCount + 1): + segment = safe(lambda: Atspi.Text.get_string_at_offset(accessible, offset, granularity)) + if segment is None: + entry = "error" + else: + entry = f"{segment.start_offset}-{segment.end_offset}" + if not segments or segments[-1] != entry: + segments.append(entry) + return segments + + +def safe(call, default=None): + try: + return call() + except Exception: # AT-SPI raises GLib.Error for defunct objects + return default + + +def short(text, limit=100): + if text is None: + return "(null)" + cleaned = text.replace("", "[obj]").replace("\n", "\\n") + if len(cleaned) > limit: + cleaned = cleaned[:limit] + "..." + return f'"{cleaned}" len={len(text)}' + + +def state_names(accessible): + stateSet = safe(lambda: accessible.get_state_set()) + if stateSet is None: + return "?" + names = [Atspi.StateType(state).value_nick for state in stateSet.get_states()] + return ",".join(sorted(names)) or "-" + + +def interface_names(accessible): + return ",".join(sorted(safe(lambda: accessible.get_interfaces(), []) or [])) or "-" + + +def find_document(accessible, depth=0): + if depth > 40: + return None + if safe(lambda: accessible.get_role()) == Atspi.Role.DOCUMENT_WEB: + if (safe(lambda: accessible.get_child_count(), 0) or 0) > 0: + return accessible + for index in range(safe(lambda: accessible.get_child_count(), 0) or 0): + child = safe(lambda: accessible.get_child_at_index(index)) + if child is not None: + found = find_document(child, depth + 1) + if found is not None: + return found + return None + + +def describe(accessible, depth, maxNodes): + global nodeCount + if nodeCount >= maxNodes: + return + nodeCount += 1 + indent = " " * depth + role = safe(lambda: accessible.get_role_name(), "?") + name = safe(lambda: accessible.get_name(), "") + states = state_names(accessible) + childCount = safe(lambda: accessible.get_child_count(), 0) or 0 + print(f"{indent}- {role} name={short(name, 60)} children={childCount}") + print(f"{indent} states: {states}") + print(f"{indent} interfaces: {interface_names(accessible)}") + attributes = safe(lambda: accessible.get_attributes(), {}) or {} + if attributes: + joined = ";".join(f"{key}:{value}" for key, value in sorted(attributes.items())) + print(f"{indent} attrs: {short(joined, 240)}") + relations = safe(lambda: accessible.get_relation_set(), []) or [] + if relations: + parts = [f"{relation.get_relation_type().value_nick}({relation.get_n_targets()})" for relation in relations] + print(f"{indent} relations: {' '.join(parts)}") + text = safe(lambda: accessible.get_text_iface()) + if text is not None: + characterCount = safe(lambda: text.get_character_count(), 0) or 0 + if role == "password text": + print(f"{indent} text: n={characterCount} (password, content not read)") + else: + content = safe(lambda: Atspi.Text.get_text(accessible, 0, characterCount), "") + caret = safe(lambda: text.get_caret_offset(), -1) + print(f"{indent} text: n={characterCount} {short(content)} caret={caret}") + if showBoundaries and characterCount: + for label, granularity in GRANULARITIES: + print(f"{indent} {label}s: {' '.join(boundary_segments(accessible, characterCount, granularity))}") + hypertext = safe(lambda: accessible.get_hypertext_iface()) + if hypertext is not None: + linkCount = safe(lambda: hypertext.get_n_links(), 0) or 0 + if linkCount: + ranges = [] + for index in range(min(linkCount, 6)): + link = safe(lambda: hypertext.get_link(index)) + if link is not None: + ranges.append(f"[{safe(lambda: link.get_start_index())}-{safe(lambda: link.get_end_index())}]") + print(f"{indent} hyperlinks: {linkCount} {' '.join(ranges)}") + action = safe(lambda: accessible.get_action_iface()) + if action is not None: + actionCount = safe(lambda: action.get_n_actions(), 0) or 0 + if actionCount: + names = [safe(lambda: Atspi.Action.get_action_name(accessible, index), "?") for index in range(actionCount)] + print(f"{indent} actions: {','.join(names)}") + table = safe(lambda: accessible.get_table_iface()) + if table is not None: + print(f"{indent} table: {safe(lambda: table.get_n_rows())}x{safe(lambda: table.get_n_columns())}") + cell = safe(lambda: accessible.get_table_cell()) + if cell is not None: + position = safe(lambda: Atspi.TableCell.get_position(accessible), None) + if isinstance(position, tuple): + position = "r{} c{}".format(*position[-2:]) + span = safe(lambda: Atspi.TableCell.get_row_column_span(accessible), None) + if isinstance(span, tuple): + span = "{}x{}".format(*span[-2:]) + columnHeaders = safe(lambda: Atspi.TableCell.get_column_header_cells(accessible), []) or [] + rowHeaders = safe(lambda: Atspi.TableCell.get_row_header_cells(accessible), []) or [] + print(f"{indent} cell: position={position} span={span} columnHeaders={len(columnHeaders)} " + f"rowHeaders={len(rowHeaders)}") + for index in range(childCount): + child = safe(lambda: accessible.get_child_at_index(index)) + if child is not None: + describe(child, depth + 1, maxNodes) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--app-name", required=True) + parser.add_argument("--wait", type=float, default=30) + parser.add_argument("--max-nodes", type=int, default=3000) + parser.add_argument("--whole-app", action="store_true", help="dump the application, not just the document") + parser.add_argument("--boundaries", action="store_true", help="also dump word/sentence/line/paragraph segments") + options = parser.parse_args() + global showBoundaries + showBoundaries = options.boundaries + + deadline = time.monotonic() + options.wait + application = None + document = None + while time.monotonic() < deadline: + desktop = Atspi.get_desktop(0) + for index in range(desktop.get_child_count()): + candidate = safe(lambda: desktop.get_child_at_index(index)) + candidateName = safe(lambda: candidate.get_name(), "") if candidate else "" + if candidate is not None and options.app_name.lower() in (candidateName or "").lower(): + application = candidate + document = find_document(candidate) + if document is not None: + break + if document is not None: + break + time.sleep(0.5) + if application is None: + print(f"No application matching {options.app_name}") + return 3 + print(f"application: name={short(safe(lambda: application.get_name()))} " + f"toolkit={safe(lambda: application.get_toolkit_name())} " + f"version={safe(lambda: application.get_toolkit_version())} " + f"pid={safe(lambda: application.get_process_id())}") + if document is None: + print("No document-web with children found") + return 4 + describe(application if options.whole_app else document, 0, options.max_nodes) + print(f"nodes={nodeCount}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/browser/compare_dumps.py b/tests/browser/compare_dumps.py new file mode 100755 index 0000000..a33aa94 --- /dev/null +++ b/tests/browser/compare_dumps.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 +"""Compare a native Chromium AT-SPI dump with a Wine Access publisher dump. + +Usage: compare_dumps.py NATIVE.txt PUBLISHER.txt [--baseline chromium|electron42] +Exits 0 when the dumps match after the documented allowed differences, 1 +otherwise, printing a unified diff of what remains. +""" + +import argparse +import difflib +import re +import sys + +# Differences that are real and expected, applied to the native side so it +# reads as the Wine side would. Each rule documents its reason. +ATTRIBUTE_LINE = re.compile(r'^(\s*attrs: )"(.*)" len=\d+$') +ROLE_LINE = re.compile(r'^(\s*- )(\S.*?)( name=.*)$') + +# Lines that identify the run rather than the tree. +ignoredPrefixes = ("application:",) + + +def attribute_line(indent, attributes): + joined = ";".join(attributes) + return f'{indent}"{joined}" len={len(joined)}' + + +def normalize(lines, baseline): + result = list(lines) + for index, line in enumerate(result): + match = ATTRIBUTE_LINE.match(line) + if not match: + continue + attributes = match.group(2).split(";") + # Chromium's views frame class is platform-specific. + attributes = ["class:WinFrameView" if item == "class:NativeFrameView" else item for item in attributes] + # Electron 42's Chromium exposes an unnamed
as a section with no + # xml-roles; Chromium 156 (Electron 45 under Wine) and 158 expose a + # form. Only the node whose own attributes say tag:form is changed. + if baseline == "electron42" and "tag:form" in attributes and "xml-roles:form" not in attributes: + roleIndex = next((candidate for candidate in range(index - 1, max(index - 4, -1), -1) + if ROLE_LINE.match(result[candidate])), None) + roleMatch = ROLE_LINE.match(result[roleIndex]) if roleIndex is not None else None + if roleMatch and roleMatch.group(2) == "section": + result[roleIndex] = f"{roleMatch.group(1)}form{roleMatch.group(3)}" + attributes = sorted(attributes + ["xml-roles:form"]) + result[index] = attribute_line(match.group(1), attributes) + return [line for line in result if not line.startswith(ignoredPrefixes)] + + +BOUNDARY_LINE = re.compile(r"^(\s*(?:words|sentences|lines|paragraphs): )(.*)$") + + +TEXT_LINE = re.compile(r'^\s*text: n=\d+ "(.*)" len=(\d+) caret=-?\d+$') + + +def allow_rounded_emoji_words(nativeLines, publisherLines): + """Native Chromium reports a word ending inside a surrogate pair (next to + an emoji) as "start--1"; the publisher rounds the end up to the next whole + character. Accept exactly that: the publisher's segment must start where + native's does and end immediately after a supplementary-plane character + of the object's own text.""" + if len(nativeLines) != len(publisherLines): + return + text = None + for index, (nativeLine, publisherLine) in enumerate(zip(nativeLines, publisherLines)): + textMatch = TEXT_LINE.match(publisherLine) + if textMatch: + # Undo the dump's display substitutions, then only trust untruncated + # text (the dump truncates after 100 characters). + content = textMatch.group(1).replace("[obj]", "\ufffc").replace("\\n", "\n") + text = content if len(content) == int(textMatch.group(2)) else None + continue + nativeMatch = BOUNDARY_LINE.match(nativeLine) + publisherMatch = BOUNDARY_LINE.match(publisherLine) + if not nativeMatch or not publisherMatch or nativeMatch.group(1) != publisherMatch.group(1) or text is None: + continue + nativeTokens = nativeMatch.group(2).split() + publisherTokens = publisherMatch.group(2).split() + if len(nativeTokens) != len(publisherTokens): + continue + for position, (nativeToken, publisherToken) in enumerate(zip(nativeTokens, publisherTokens)): + start = re.fullmatch(r"(\d+)--1", nativeToken) + rounded = re.fullmatch(r"(\d+)-(\d+)", publisherToken) + if not start or not rounded or start.group(1) != rounded.group(1): + continue + end = int(rounded.group(2)) + if int(rounded.group(1)) < end <= len(text) and ord(text[end - 1]) > 0xFFFF: + nativeTokens[position] = publisherToken + nativeLines[index] = nativeMatch.group(1) + " ".join(nativeTokens) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("native") + parser.add_argument("publisher") + parser.add_argument("--baseline", choices=["chromium", "electron42"], default="chromium") + options = parser.parse_args() + with open(options.native, encoding="utf-8") as nativeFile: + nativeLines = normalize(nativeFile.read().splitlines(), options.baseline) + with open(options.publisher, encoding="utf-8") as publisherFile: + publisherLines = normalize(publisherFile.read().splitlines(), "none") + if not nativeLines or not publisherLines or not nativeLines[-1].startswith("nodes="): + print("A dump is empty or incomplete") + return 1 + allow_rounded_emoji_words(nativeLines, publisherLines) + difference = list(difflib.unified_diff(nativeLines, publisherLines, "native", "publisher", lineterm="")) + if difference: + print("\n".join(difference)) + print(f"MISMATCH: {sum(1 for line in difference if line.startswith('-') and not line.startswith('---'))} " + f"native lines differ") + return 1 + print(f"MATCH ({options.baseline} baseline, {nativeLines[-1]}, allowed differences applied)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/browser/compare_events.py b/tests/browser/compare_events.py new file mode 100755 index 0000000..143f27b --- /dev/null +++ b/tests/browser/compare_events.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +"""Compare a native Chromium event log with a Wine Access publisher event log. + +Usage: compare_events.py NATIVE.events.txt PUBLISHER.events.txt +Exits 0 when the logs match after the documented normalizations, 1 otherwise. +""" + +import difflib +import re +import sys + +# Each rule: (reason, predicate or rewrite) applied to both logs. +DROPPED = [ + ("atk-bridge reports objects defunct when it drops its temporary references; native Chromium shows " + "the same on objects that stay in place, so these say nothing about presentation", + re.compile(r"^object:state-changed:defunct ")), + ("native Chromium has browser UI (address bar, navigation buttons) that an Electron window does not", + re.compile(r" src=(entry:Address and search bar|button:(Back|Forward|Reload|Home))\b")), +] +REWRITES = [ + ("the removed child is described after removal, so its role depends on timing; the event itself matters", + re.compile(r"^(object:children-changed:remove .*) data=.*$"), r"\1 data="), +] + + +def normalize(path): + lines = [] + with open(path, encoding="utf-8") as logFile: + for line in logFile.read().splitlines(): + if any(pattern.search(line) for _reason, pattern in DROPPED): + continue + for _reason, pattern, replacement in REWRITES: + line = pattern.sub(replacement, line) + lines.append(line) + return lines + + +def main(): + if len(sys.argv) != 3: + print(__doc__) + return 2 + nativeLines = normalize(sys.argv[1]) + publisherLines = normalize(sys.argv[2]) + if sum(1 for line in nativeLines if line.startswith("STEP")) == 0: + print("The native log has no steps") + return 1 + difference = list(difflib.unified_diff(nativeLines, publisherLines, "native", "publisher", lineterm="")) + if difference: + print("\n".join(difference)) + print("MISMATCH") + return 1 + events = sum(1 for line in nativeLines if not line.startswith("STEP")) + print(f"MATCH ({events} events after allowed differences)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/browser/data/electron45-snapshot.json b/tests/browser/data/electron45-snapshot.json new file mode 100644 index 0000000..25b2bd8 --- /dev/null +++ b/tests/browser/data/electron45-snapshot.json @@ -0,0 +1 @@ +{"format":"wine-access-browser-snapshot-1","hwnd":65682,"windowsPid":40,"title":"Wine Access Electron Test","focusedId":-89,"root":{"msaaRole":16,"msaaStates":0,"name":"Wine Access Electron Test","value":"","location":[132,158,1016,734],"id":-3,"ia2Role":16,"ia2States":1024,"attributes":"name-from:attribute;explicit-name:true;class:RootView;","textLength":1,"text":"","boundaries":{"word":[[-1,-1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,158,1016,734],"id":-6,"ia2Role":16,"ia2States":1024,"attributes":"class:NonClientView;","textLength":1,"text":"","boundaries":{"word":[[-1,-1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,158,1016,734],"id":-8,"ia2Role":16,"ia2States":1024,"attributes":"class:WinFrameView;","textLength":1,"text":"","boundaries":{"word":[[-1,-1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,158,1016,734],"id":-5,"ia2Role":16,"ia2States":1024,"attributes":"class:ClientView;","textLength":1,"text":"","boundaries":{"word":[[-1,-1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,158,1016,734],"id":-1,"ia2Role":16,"ia2States":1024,"attributes":"class:View;","textLength":2,"text":"","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1]]},"children":[{"msaaRole":2,"msaaStates":1048580,"name":null,"value":"","location":[132,158,1016,25],"id":-16,"ia2Role":2,"ia2States":1024,"attributes":"explicit-name:true;class:MenuBar;","textLength":4,"text":"","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]]},"children":[{"msaaRole":57,"msaaStates":1074790400,"name":"File","value":"","defaultAction":"open","location":[132,158,31,25],"id":-17,"ia2Role":57,"ia2States":1024,"attributes":"name-from:attribute;explicit-name:true;haspopup:menu;class:SubmenuButton;","textLength":4,"text":"File","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]]},"children":[]},{"msaaRole":57,"msaaStates":1074790400,"name":"Edit","value":"","defaultAction":"open","location":[163,158,33,25],"id":-22,"ia2Role":57,"ia2States":1024,"attributes":"name-from:attribute;explicit-name:true;haspopup:menu;class:SubmenuButton;id:view_1;","textLength":4,"text":"Edit","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]]},"children":[]},{"msaaRole":57,"msaaStates":1074790400,"name":"View","value":"","defaultAction":"open","location":[196,158,38,25],"id":-27,"ia2Role":57,"ia2States":1024,"attributes":"name-from:attribute;explicit-name:true;haspopup:menu;class:SubmenuButton;id:view_2;","textLength":4,"text":"View","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]]},"children":[]},{"msaaRole":57,"msaaStates":1074790400,"name":"Window","value":"","defaultAction":"open","location":[234,158,55,25],"id":-32,"ia2Role":57,"ia2States":1024,"attributes":"name-from:attribute;explicit-name:true;haspopup:menu;class:SubmenuButton;id:view_3;","textLength":6,"text":"Window","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1]]},"children":[]}]},{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,183,1016,709],"id":-2,"ia2Role":16,"ia2States":1024,"attributes":"class:View;","textLength":2,"text":"","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,183,1016,709],"id":-15,"ia2Role":16,"ia2States":1024,"attributes":"class:View;","textLength":2,"text":"","boundaries":{"word":[[-1,-1],[-1,-1],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[-1,-1],[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1],[-1,-1]]},"children":[{"msaaRole":10,"msaaStates":32768,"name":null,"value":"","location":[132,183,0,0],"id":-11,"ia2Role":10,"ia2States":1024,"attributes":"hidden:true;explicit-name:true;class:WebView;","textLength":1,"text":"","boundaries":{"word":[[-1,-1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[-1,-1],[-1,-1]],"paragraph":[[-1,-1],[-1,-1]]},"children":[{"msaaRole":16,"msaaStates":32768,"name":null,"value":"","location":[132,183,0,0],"id":-12,"ia2Role":16,"ia2States":1024,"attributes":"hidden:true;class:NativeViewHost;","textLength":0,"text":null,"children":[]}]},{"msaaRole":15,"msaaStates":1048644,"name":"Wine Access Electron Test","value":"file:///C:/electron-test-app/fixture.html","location":[132,183,1016,709],"id":-89,"ia2Role":15,"ia2States":1024,"attributes":"tag:#document;name-from:related-element;explicit-name:true;text-align:left;","textLength":1,"text":"","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"hyperlinks":[[0,1,-43]],"actions":["doDefault","showContextMenu","scrollBackward","scrollDown","scrollForward","scrollLeft","scrollRight","scrollUp"],"children":[{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,204,985,2653],"id":-43,"ia2Role":1069,"ia2States":1024,"attributes":"display:block;tag:main;xml-roles:main;text-align:left;","textLength":12,"text":"","boundaries":{"word":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[-1,-1]],"sentence":[[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[-1,-1]],"line":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[11,12]],"paragraph":[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11],[11,12],[-1,-1]]},"hyperlinks":[[0,1,-108],[1,2,-102],[2,3,-83],[3,4,-79],[4,5,-64],[5,6,-48],[6,7,-49],[7,8,-98],[8,9,-95],[9,10,-85],[10,11,-71],[11,12,-78]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":20,"msaaStates":0,"name":"Wine Access test page","value":"","location":[140,204,985,40],"id":-108,"ia2Role":1044,"ia2States":1024,"attributes":"display:block;tag:h1;level:1;name-from:contents;text-align:left;","groupPosition":[1,0,0],"textLength":21,"text":"Wine Access test page","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,12],[5,12],[5,12],[5,12],[5,12],[5,12],[5,12],[12,17],[12,17],[12,17],[12,17],[12,17],[17,21],[17,21],[17,21],[17,21],[-1,-1]],"sentence":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[-1,-1]],"line":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21]],"paragraph":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Wine Access test page","value":"","location":[140,204,359,40],"id":-50,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":21,"text":"Wine Access test page","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,12],[5,12],[5,12],[5,12],[5,12],[5,12],[5,12],[12,17],[12,17],[12,17],[12,17],[12,17],[17,21],[17,21],[17,21],[17,21],[-1,-1]],"sentence":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[-1,-1]],"line":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21]],"paragraph":[[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[0,21],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,264,985,20],"id":-102,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":30,"text":"This paragraph has an  in it.","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[15,19],[15,19],[15,19],[15,19],[19,22],[19,22],[19,22],[22,23],[22,24],[24,27],[24,27],[24,27],[27,29],[27,29],[29,30],[-1,-1]],"sentence":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[-1,-1]],"line":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30]],"paragraph":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[-1,-1]]},"hyperlinks":[[22,23,-90]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"This paragraph has an ","value":"","location":[140,264,163,20],"id":-56,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":22,"text":"This paragraph has an ","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[5,15],[15,19],[15,19],[15,19],[15,19],[19,22],[19,22],[19,22],[-1,-1]],"sentence":[[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[-1,-1]],"line":[[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22]],"paragraph":[[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[0,22],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]},{"msaaRole":30,"msaaStates":5242880,"name":"inline link to the details section","value":"file:///C:/electron-test-app/fixture.html#details","defaultAction":"jump","location":[302,264,219,20],"id":-90,"ia2Role":30,"ia2States":1024,"attributes":"display:inline;tag:a;name-from:contents;text-align:left;","textLength":34,"text":"inline link to the details section","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,12],[7,12],[7,12],[7,12],[7,12],[12,15],[12,15],[12,15],[15,19],[15,19],[15,19],[15,19],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[27,34],[27,34],[27,34],[27,34],[27,34],[27,34],[27,34],[-1,-1]],"sentence":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[-1,-1]],"line":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34]],"paragraph":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[-1,-1]]},"actions":["jump","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":4194304,"name":"inline link to the details section","value":"","defaultAction":"click ancestor","location":[302,264,219,20],"id":-52,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":34,"text":"inline link to the details section","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,12],[7,12],[7,12],[7,12],[7,12],[12,15],[12,15],[12,15],[15,19],[15,19],[15,19],[15,19],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[19,27],[27,34],[27,34],[27,34],[27,34],[27,34],[27,34],[27,34],[-1,-1]],"sentence":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[-1,-1]],"line":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34]],"paragraph":[[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[0,34],[-1,-1]]},"actions":["clickAncestor","showContextMenu"],"children":[]}]},{"msaaRole":41,"msaaStates":0,"name":" in it.","value":"","location":[520,264,38,20],"id":-107,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":7,"text":" in it.","boundaries":{"word":[[0,1],[1,4],[1,4],[1,4],[4,6],[4,6],[6,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,299,985,20],"id":-83,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":30,"text":"Emoji 🙂 and café before a .","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[6,7],[6,7],[6,9],[9,13],[9,13],[9,13],[9,13],[13,19],[13,19],[13,19],[13,19],[13,19],[13,19],[19,26],[19,26],[19,26],[19,26],[19,26],[19,26],[19,26],[26,28],[26,28],[28,29],[29,30],[-1,-1]],"sentence":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[-1,-1]],"line":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30]],"paragraph":[[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[0,30],[-1,-1]]},"hyperlinks":[[28,29,-80]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Emoji 🙂 and café before a ","value":"","location":[140,299,194,20],"id":-111,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":28,"text":"Emoji 🙂 and café before a ","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[6,7],[6,7],[6,9],[9,13],[9,13],[9,13],[9,13],[13,19],[13,19],[13,19],[13,19],[13,19],[13,19],[19,26],[19,26],[19,26],[19,26],[19,26],[19,26],[19,26],[26,28],[26,28],[-1,-1]],"sentence":[[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[-1,-1]],"line":[[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28]],"paragraph":[[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[0,28],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]},{"msaaRole":30,"msaaStates":5242880,"name":"second link","value":"file:///C:/electron-test-app/fixture.html#scores","defaultAction":"jump","location":[333,299,80,20],"id":-80,"ia2Role":30,"ia2States":1024,"attributes":"display:inline;tag:a;name-from:contents;text-align:left;","textLength":11,"text":"second link","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,11],[7,11],[7,11],[7,11],[-1,-1]],"sentence":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]],"line":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11]],"paragraph":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]]},"actions":["jump","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":4194304,"name":"second link","value":"","defaultAction":"click ancestor","location":[333,299,80,20],"id":-109,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":11,"text":"second link","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,11],[7,11],[7,11],[7,11],[-1,-1]],"sentence":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]],"line":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11]],"paragraph":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]]},"actions":["clickAncestor","showContextMenu"],"children":[]}]},{"msaaRole":41,"msaaStates":0,"name":".","value":"","location":[412,299,6,20],"id":-88,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":1,"text":".","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":"Details","value":"","location":[140,338,985,30],"id":-79,"ia2Role":1044,"ia2States":1024,"attributes":"display:block;tag:h2;level:2;name-from:contents;id:details;text-align:left;","groupPosition":[2,0,0],"textLength":7,"text":"Details","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Details","value":"","location":[140,338,84,30],"id":-93,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":7,"text":"Details","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,387,985,134],"id":-64,"ia2Role":1060,"ia2States":1024,"attributes":"display:block;tag:form;xml-roles:form;text-align:left;","textLength":4,"text":"","boundaries":{"word":[[0,1],[1,2],[2,3],[3,4],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[0,1],[1,2],[2,3],[3,4],[3,4]],"paragraph":[[0,1],[1,2],[2,3],[3,4],[-1,-1]]},"hyperlinks":[[0,1,-62],[1,2,-103],[2,3,-86],[3,4,-76]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,387,985,23],"id":-62,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":2,"text":"","boundaries":{"word":[[0,1],[1,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,1],[1,2],[1,2]],"paragraph":[[0,1],[1,2],[-1,-1]]},"hyperlinks":[[0,1,-54],[1,2,-42]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":42,"msaaStates":0,"name":null,"value":"","location":[140,387,76,20],"id":-54,"ia2Role":1049,"ia2States":1024,"attributes":"display:inline;tag:label;text-align:left;","relations":[{"type":"labelFor","targets":[-42]}],"textLength":9,"text":"User name","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,9],[5,9],[5,9],[5,9],[-1,-1]],"sentence":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[-1,-1]],"line":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9]],"paragraph":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"User name","value":"","location":[140,387,76,20],"id":-96,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":9,"text":"User name","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,9],[5,9],[5,9],[5,9],[-1,-1]],"sentence":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[-1,-1]],"line":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9]],"paragraph":[[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[0,9],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":42,"msaaStates":1048576,"name":"User name","value":"","defaultAction":"activate","location":[221,387,141,23],"id":-42,"ia2Role":42,"ia2States":13320,"attributes":"display:inline-block;tag:input;name-from:related-element;explicit-name:true;id:userName;text-align:left;text-model:a1;text-input-type:text;","relations":[{"type":"labelledBy","targets":[-54]}],"textLength":0,"text":null,"actions":["activate","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,425,985,23],"id":-103,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":2,"text":"","boundaries":{"word":[[0,1],[1,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,1],[1,2],[1,2]],"paragraph":[[0,1],[1,2],[-1,-1]]},"hyperlinks":[[0,1,-99],[1,2,-97]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":42,"msaaStates":0,"name":null,"value":"","location":[140,425,67,20],"id":-99,"ia2Role":1049,"ia2States":1024,"attributes":"display:inline;tag:label;text-align:left;","relations":[{"type":"labelFor","targets":[-97]}],"textLength":8,"text":"Password","boundaries":{"word":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]],"sentence":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]],"line":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8]],"paragraph":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Password","value":"","location":[140,425,67,20],"id":-69,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":8,"text":"Password","boundaries":{"word":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]],"sentence":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]],"line":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8]],"paragraph":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":42,"msaaStates":537919488,"name":"Password","defaultAction":"activate","location":[211,425,142,23],"id":-97,"ia2Role":42,"ia2States":13320,"attributes":"display:inline-block;tag:input;name-from:related-element;explicit-name:true;id:userPassword;text-align:left;text-model:a1;text-input-type:password;","relations":[{"type":"labelledBy","targets":[-99]}],"textLength":0,"actions":["activate","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,463,985,20],"id":-86,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":1,"text":"","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"hyperlinks":[[0,1,-63]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":44,"msaaStates":1048576,"name":"Remember me","value":"","defaultAction":"check","location":[144,466,13,14],"id":-63,"ia2Role":44,"ia2States":263168,"attributes":"display:inline-block;tag:input;checkable:true;name-from:related-element;explicit-name:true;id:rememberMe;text-align:left;","textLength":0,"text":null,"actions":["check","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,498,985,23],"id":-76,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":1,"text":"","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"hyperlinks":[[0,1,-58]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":43,"msaaStates":1048576,"name":"Sign in","value":"","defaultAction":"press","location":[140,498,55,23],"id":-58,"ia2Role":43,"ia2States":1024,"attributes":"display:inline-block;tag:button;name-from:contents;text-align:center;","textLength":7,"text":"Sign in","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,7],[5,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["press","showContextMenu"],"children":[]}]}]},{"msaaRole":20,"msaaStates":0,"name":"Updates","value":"","location":[140,540,985,30],"id":-48,"ia2Role":1044,"ia2States":1024,"attributes":"display:block;tag:h2;level:2;name-from:contents;text-align:left;","groupPosition":[2,0,0],"textLength":7,"text":"Updates","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Updates","value":"","location":[140,540,99,30],"id":-51,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":7,"text":"Updates","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"sentence":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]],"line":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7]],"paragraph":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,589,985,23],"id":-49,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;text-align:left;","textLength":1,"text":"","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"hyperlinks":[[0,1,-113]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":43,"msaaStates":1048576,"name":"Add item","value":"","defaultAction":"press","location":[140,589,68,23],"id":-113,"ia2Role":43,"ia2States":1024,"attributes":"display:inline-block;tag:button;name-from:contents;id:addItem;text-align:center;","textLength":8,"text":"Add item","boundaries":{"word":[[0,4],[0,4],[0,4],[0,4],[4,8],[4,8],[4,8],[4,8],[-1,-1]],"sentence":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]],"line":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8]],"paragraph":[[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[0,8],[-1,-1]]},"actions":["press","showContextMenu"],"children":[]}]},{"msaaRole":33,"msaaStates":64,"name":null,"value":"","location":[140,627,985,20],"id":-98,"ia2Role":33,"ia2States":1024,"attributes":"display:block;tag:ul;setsize:1;id:itemList;text-align:left;","groupPosition":[0,1,0],"textLength":1,"text":"","boundaries":{"word":[[0,1],[-1,-1]],"sentence":[[0,1],[-1,-1]],"line":[[0,1],[0,1]],"paragraph":[[0,1],[-1,-1]]},"hyperlinks":[[0,1,-104]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":34,"msaaStates":64,"name":null,"value":"","location":[180,627,945,20],"id":-104,"ia2Role":34,"ia2States":1024,"attributes":"display:list-item;tag:li;level:1;setsize:1;posinset:1;text-align:left;","groupPosition":[1,1,1],"textLength":12,"text":"• First item","boundaries":{"word":[[0,2],[0,2],[2,8],[2,8],[2,8],[2,8],[2,8],[2,8],[8,12],[8,12],[8,12],[8,12],[-1,-1]],"sentence":[[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[-1,-1]],"line":[[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12]],"paragraph":[[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[0,12],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"• ","value":"","location":[162,627,7,20],"id":-57,"ia2Role":41,"ia2States":1024,"attributes":"display:inline-block;tag:\\:\\:marker;name-from:contents;text-align:left;","textLength":2,"text":"• ","boundaries":{"word":[[0,2],[0,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,2],[0,2],[0,2]],"paragraph":[[0,2],[0,2],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]},{"msaaRole":41,"msaaStates":0,"name":"First item","value":"","location":[180,627,67,20],"id":-106,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":10,"text":"First item","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[6,10],[6,10],[6,10],[6,10],[-1,-1]],"sentence":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]],"line":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10]],"paragraph":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,662,985,20],"id":-95,"ia2Role":1054,"ia2States":1024,"attributes":"display:block;tag:p;live:polite;relevant:additions text;atomic:false;container-live:polite;container-relevant:additions text;container-atomic:false;container-busy:false;id:status;text-align:left;","textLength":15,"text":"No items added.","boundaries":{"word":[[0,3],[0,3],[0,3],[3,9],[3,9],[3,9],[3,9],[3,9],[3,9],[9,14],[9,14],[9,14],[9,14],[9,14],[14,15],[-1,-1]],"sentence":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[-1,-1]],"line":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15]],"paragraph":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"No items added.","value":"","location":[140,662,117,20],"id":-112,"ia2Role":41,"ia2States":1024,"attributes":"relevant:additions text;atomic:false;container-live:polite;container-relevant:additions text;container-atomic:false;container-busy:false;name-from:contents;","textLength":15,"text":"No items added.","boundaries":{"word":[[0,3],[0,3],[0,3],[3,9],[3,9],[3,9],[3,9],[3,9],[3,9],[9,14],[9,14],[9,14],[9,14],[9,14],[14,15],[-1,-1]],"sentence":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[-1,-1]],"line":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15]],"paragraph":[[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[0,15],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":0,"name":null,"value":"","location":[140,697,985,2001],"id":-85,"ia2Role":1060,"ia2States":1024,"attributes":"display:block;tag:div;text-align:left;","textLength":31,"text":"Spacer before the scores table.","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,14],[7,14],[7,14],[7,14],[7,14],[7,14],[7,14],[14,18],[14,18],[14,18],[14,18],[18,25],[18,25],[18,25],[18,25],[18,25],[18,25],[18,25],[25,30],[25,30],[25,30],[25,30],[25,30],[30,31],[-1,-1]],"sentence":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[-1,-1]],"line":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31]],"paragraph":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":0,"name":"Spacer before the scores table.","value":"","location":[140,697,217,20],"id":-82,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":31,"text":"Spacer before the scores table.","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,14],[7,14],[7,14],[7,14],[7,14],[7,14],[7,14],[14,18],[14,18],[14,18],[14,18],[18,25],[18,25],[18,25],[18,25],[18,25],[18,25],[18,25],[25,30],[25,30],[25,30],[25,30],[25,30],[30,31],[-1,-1]],"sentence":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[-1,-1]],"line":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31]],"paragraph":[[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[0,31],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":20,"msaaStates":65536,"name":"Scores","value":"","location":[140,2717,985,30],"id":-71,"ia2Role":1044,"ia2States":1024,"attributes":"display:block;tag:h2;level:2;name-from:contents;id:scores;text-align:left;","groupPosition":[2,0,0],"textLength":6,"text":"Scores","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"sentence":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"line":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[0,6]],"paragraph":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":65536,"name":"Scores","value":"","location":[140,2717,80,30],"id":-92,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":6,"text":"Scores","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"sentence":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"line":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[0,6]],"paragraph":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":24,"msaaStates":65536,"name":"High scores","value":"","location":[140,2766,146,91],"id":-78,"ia2Role":24,"ia2States":1024,"attributes":"display:table;tag:table;name-from:caption;explicit-name:true;text-align:left;","relations":[{"type":"labelledBy","targets":[-67]}],"textLength":4,"text":"","boundaries":{"word":[[0,1],[1,2],[2,3],[3,4],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[0,1],[1,2],[2,3],[3,4],[3,4]],"paragraph":[[0,1],[1,2],[2,3],[3,4],[-1,-1]]},"hyperlinks":[[0,1,-67],[1,2,-60],[2,3,-110],[3,4,-91]],"actions":["doDefault","showContextMenu"],"table":{"rows":3,"columns":2},"children":[{"msaaRole":20,"msaaStates":65536,"name":null,"value":"","location":[140,2766,146,20],"id":-67,"ia2Role":1026,"ia2States":1024,"attributes":"display:table-caption;tag:caption;text-align:center;","relations":[{"type":"labelFor","targets":[-78]}],"textLength":11,"text":"High scores","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[-1,-1]],"sentence":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]],"line":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11]],"paragraph":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":41,"msaaStates":65536,"name":"High scores","value":"","location":[171,2766,83,20],"id":-94,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":11,"text":"High scores","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[-1,-1]],"sentence":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]],"line":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11]],"paragraph":[[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[0,11],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":28,"msaaStates":65536,"name":null,"value":"","location":[142,2787,142,22],"id":-60,"ia2Role":28,"ia2States":1024,"attributes":"display:table-row;tag:tr;text-align:left;","textLength":2,"text":"","boundaries":{"word":[[0,1],[1,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,1],[1,2],[1,2]],"paragraph":[[0,1],[1,2],[-1,-1]]},"hyperlinks":[[0,1,-47],[1,2,-105]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":25,"msaaStates":65536,"name":"Player","value":"","location":[142,2787,93,22],"id":-47,"ia2Role":25,"ia2States":1024,"attributes":"display:table-cell;tag:th;name-from:contents;table-cell-index:0;text-align:center;","textLength":6,"text":"Player","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"sentence":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"line":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[0,6]],"paragraph":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":0,"column":0,"rowSpan":1,"columnSpan":1,"columnHeaders":[-47],"rowHeaders":[]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"Player","value":"","location":[162,2788,53,20],"id":-59,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":6,"text":"Player","boundaries":{"word":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"sentence":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]],"line":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[0,6]],"paragraph":[[0,6],[0,6],[0,6],[0,6],[0,6],[0,6],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":25,"msaaStates":65536,"name":"Score","value":"","location":[236,2787,48,22],"id":-105,"ia2Role":25,"ia2States":1024,"attributes":"display:table-cell;tag:th;name-from:contents;table-cell-index:1;text-align:center;","textLength":5,"text":"Score","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]],"sentence":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]],"line":[[0,5],[0,5],[0,5],[0,5],[0,5],[0,5]],"paragraph":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":0,"column":1,"rowSpan":1,"columnSpan":1,"columnHeaders":[-105],"rowHeaders":[]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"Score","value":"","location":[237,2788,46,20],"id":-73,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":5,"text":"Score","boundaries":{"word":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]],"sentence":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]],"line":[[0,5],[0,5],[0,5],[0,5],[0,5],[0,5]],"paragraph":[[0,5],[0,5],[0,5],[0,5],[0,5],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]}]},{"msaaRole":28,"msaaStates":65536,"name":null,"value":"","location":[142,2810,142,22],"id":-110,"ia2Role":28,"ia2States":1024,"attributes":"display:table-row;tag:tr;text-align:left;","textLength":2,"text":"","boundaries":{"word":[[0,1],[1,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,1],[1,2],[1,2]],"paragraph":[[0,1],[1,2],[-1,-1]]},"hyperlinks":[[0,1,-87],[1,2,-81]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":26,"msaaStates":65536,"name":"Player One","value":"","location":[142,2810,93,22],"id":-87,"ia2Role":26,"ia2States":1024,"attributes":"display:table-cell;tag:th;name-from:contents;table-cell-index:2;text-align:center;","textLength":10,"text":"Player One","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,10],[7,10],[7,10],[-1,-1]],"sentence":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]],"line":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10]],"paragraph":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":1,"column":0,"rowSpan":1,"columnSpan":1,"columnHeaders":[-47],"rowHeaders":[-87]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"Player One","value":"","location":[143,2811,91,20],"id":-75,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":10,"text":"Player One","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,10],[7,10],[7,10],[-1,-1]],"sentence":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]],"line":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10]],"paragraph":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":29,"msaaStates":65536,"name":"1200","value":"","location":[236,2810,48,22],"id":-81,"ia2Role":29,"ia2States":1024,"attributes":"display:table-cell;tag:td;name-from:contents;table-cell-index:3;text-align:left;","textLength":4,"text":"1200","boundaries":{"word":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[0,4],[0,4],[0,4],[0,4],[0,4]],"paragraph":[[0,4],[0,4],[0,4],[0,4],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":1,"column":1,"rowSpan":1,"columnSpan":1,"columnHeaders":[-105],"rowHeaders":[-87]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"1200","value":"","location":[237,2811,37,20],"id":-45,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":4,"text":"1200","boundaries":{"word":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"sentence":[[0,4],[0,4],[0,4],[0,4],[-1,-1]],"line":[[0,4],[0,4],[0,4],[0,4],[0,4]],"paragraph":[[0,4],[0,4],[0,4],[0,4],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]}]},{"msaaRole":28,"msaaStates":65536,"name":null,"value":"","location":[142,2833,142,22],"id":-91,"ia2Role":28,"ia2States":1024,"attributes":"display:table-row;tag:tr;text-align:left;","textLength":2,"text":"","boundaries":{"word":[[0,1],[1,2],[-1,-1]],"sentence":[[0,2],[0,2],[-1,-1]],"line":[[0,1],[1,2],[1,2]],"paragraph":[[0,1],[1,2],[-1,-1]]},"hyperlinks":[[0,1,-66],[1,2,-61]],"actions":["doDefault","showContextMenu"],"children":[{"msaaRole":26,"msaaStates":65536,"name":"Player Two","value":"","location":[142,2833,93,22],"id":-66,"ia2Role":26,"ia2States":1024,"attributes":"display:table-cell;tag:th;name-from:contents;table-cell-index:4;text-align:center;","textLength":10,"text":"Player Two","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,10],[7,10],[7,10],[-1,-1]],"sentence":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]],"line":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10]],"paragraph":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":2,"column":0,"rowSpan":1,"columnSpan":1,"columnHeaders":[-47],"rowHeaders":[-66]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"Player Two","value":"","location":[143,2834,91,20],"id":-72,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":10,"text":"Player Two","boundaries":{"word":[[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[0,7],[7,10],[7,10],[7,10],[-1,-1]],"sentence":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]],"line":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10]],"paragraph":[[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[0,10],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]},{"msaaRole":29,"msaaStates":65536,"name":"950","value":"","location":[236,2833,48,22],"id":-61,"ia2Role":29,"ia2States":1024,"attributes":"display:table-cell;tag:td;name-from:contents;table-cell-index:5;text-align:left;","textLength":3,"text":"950","boundaries":{"word":[[0,3],[0,3],[0,3],[-1,-1]],"sentence":[[0,3],[0,3],[0,3],[-1,-1]],"line":[[0,3],[0,3],[0,3],[0,3]],"paragraph":[[0,3],[0,3],[0,3],[-1,-1]]},"actions":["doDefault","showContextMenu"],"cell":{"row":2,"column":1,"rowSpan":1,"columnSpan":1,"columnHeaders":[-105],"rowHeaders":[-66]},"children":[{"msaaRole":41,"msaaStates":65536,"name":"950","value":"","location":[237,2834,28,20],"id":-68,"ia2Role":41,"ia2States":1024,"attributes":"name-from:contents;","textLength":3,"text":"950","boundaries":{"word":[[0,3],[0,3],[0,3],[-1,-1]],"sentence":[[0,3],[0,3],[0,3],[-1,-1]],"line":[[0,3],[0,3],[0,3],[0,3]],"paragraph":[[0,3],[0,3],[0,3],[-1,-1]]},"actions":["doDefault","showContextMenu"],"children":[]}]}]}]}]}]}]},{"msaaRole":16,"msaaStates":0,"name":null,"value":"","location":[132,183,1016,709],"id":-10,"ia2Role":16,"ia2States":1024,"attributes":"class:View;","textLength":0,"text":null,"children":[]}]}]}]}]}]}]}} diff --git a/tests/browser/data/native-chromium158-document.txt b/tests/browser/data/native-chromium158-document.txt new file mode 100644 index 0000000..edfe789 --- /dev/null +++ b/tests/browser/data/native-chromium158-document.txt @@ -0,0 +1,629 @@ +application: name="Chromium" len=8 toolkit=Chromium version=1.0 pid=135420 +- document web name="Wine Access Electron Test" len=25 children=1 + states: enabled,focusable,focused,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "explicit-name:true;name-from:related-element;tag:#document;text-align:left" len=74 + relations: embedded-by(1) + text: n=1 "[obj]" len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu,scrollBackward,scrollDown,scrollForward,scrollLeft,scrollRight,scrollUp + - landmark name="" len=0 children=12 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:main;text-align:left;xml-roles:main" len=53 + text: n=12 "[obj][obj][obj][obj][obj][obj][obj][obj][obj][obj][obj][obj]" len=12 caret=-1 + words: 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9 9-10 10-11 11-12 -1--1 + sentences: 0-12 -1--1 + lines: 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9 9-10 10-11 11-12 -1--1 + paragraphs: 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9 9-10 10-11 11-12 -1--1 + hyperlinks: 12 [0-1] [1-2] [2-3] [3-4] [4-5] [5-6] + actions: doDefault,showContextMenu + - heading name="Wine Access test page" len=21 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;level:1;name-from:contents;tag:h1;text-align:left" len=63 + text: n=21 "Wine Access test page" len=21 caret=-1 + words: 0-5 5-12 12-17 17-21 -1--1 + sentences: 0-21 -1--1 + lines: 0-21 -1--1 + paragraphs: 0-21 -1--1 + actions: doDefault,showContextMenu + - static name="Wine Access test page" len=21 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=21 "Wine Access test page" len=21 caret=-1 + words: 0-5 5-12 12-17 17-21 -1--1 + sentences: 0-21 -1--1 + lines: 0-21 -1--1 + paragraphs: 0-21 -1--1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=3 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=30 "This paragraph has an [obj] in it." len=30 caret=-1 + words: 0-5 5-15 15-19 19-22 22-23 22-24 24-27 27-29 29-30 -1--1 + sentences: 0-30 -1--1 + lines: 0-30 -1--1 + paragraphs: 0-30 -1--1 + hyperlinks: 1 [22-23] + actions: doDefault,showContextMenu + - static name="This paragraph has an " len=22 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=22 "This paragraph has an " len=22 caret=-1 + words: 0-5 5-15 15-19 19-22 -1--1 + sentences: 0-22 -1--1 + lines: 0-22 -1--1 + paragraphs: 0-22 -1--1 + actions: doDefault,showContextMenu + - link name="inline link to the details section" len=34 children=1 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;name-from:contents;tag:a;text-align:left" len=55 + text: n=34 "inline link to the details section" len=34 caret=-1 + words: 0-7 7-12 12-15 15-19 19-27 27-34 -1--1 + sentences: 0-34 -1--1 + lines: 0-34 -1--1 + paragraphs: 0-34 -1--1 + actions: jump,showContextMenu + - static name="inline link to the details section" len=34 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=34 "inline link to the details section" len=34 caret=-1 + words: 0-7 7-12 12-15 15-19 19-27 27-34 -1--1 + sentences: 0-34 -1--1 + lines: 0-34 -1--1 + paragraphs: 0-34 -1--1 + actions: clickAncestor,showContextMenu + - static name=" in it." len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 " in it." len=7 caret=-1 + words: 0-1 1-4 4-6 6-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=3 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=29 "Emoji 🙂 and café before a [obj]." len=29 caret=-1 + words: 0-6 6--1 6-8 8-12 12-18 18-25 25-27 27-28 28-29 -1--1 + sentences: 0-29 -1--1 + lines: 0-29 -1--1 + paragraphs: 0-29 -1--1 + hyperlinks: 1 [27-28] + actions: doDefault,showContextMenu + - static name="Emoji 🙂 and café before a " len=27 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=27 "Emoji 🙂 and café before a " len=27 caret=-1 + words: 0-6 6--1 6-8 8-12 12-18 18-25 25-27 -1--1 + sentences: 0-27 -1--1 + lines: 0-27 -1--1 + paragraphs: 0-27 -1--1 + actions: doDefault,showContextMenu + - link name="second link" len=11 children=1 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;name-from:contents;tag:a;text-align:left" len=55 + text: n=11 "second link" len=11 caret=-1 + words: 0-7 7-11 -1--1 + sentences: 0-11 -1--1 + lines: 0-11 -1--1 + paragraphs: 0-11 -1--1 + actions: jump,showContextMenu + - static name="second link" len=11 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=11 "second link" len=11 caret=-1 + words: 0-7 7-11 -1--1 + sentences: 0-11 -1--1 + lines: 0-11 -1--1 + paragraphs: 0-11 -1--1 + actions: clickAncestor,showContextMenu + - static name="." len=1 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=1 "." len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + actions: doDefault,showContextMenu + - heading name="Details" len=7 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:details;level:2;name-from:contents;tag:h2;text-align:left" len=74 + text: n=7 "Details" len=7 caret=-1 + words: 0-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: doDefault,showContextMenu + - static name="Details" len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 "Details" len=7 caret=-1 + words: 0-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: doDefault,showContextMenu + - form name="" len=0 children=4 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:form;text-align:left;xml-roles:form" len=53 + text: n=4 "[obj][obj][obj][obj]" len=4 caret=-1 + words: 0-1 1-2 2-3 3-4 -1--1 + sentences: 0-4 -1--1 + lines: 0-1 1-2 2-3 3-4 -1--1 + paragraphs: 0-1 1-2 2-3 3-4 -1--1 + hyperlinks: 4 [0-1] [1-2] [2-3] [3-4] + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=2 "[obj][obj]" len=2 caret=-1 + words: 0-1 1-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-1 1-2 -1--1 + paragraphs: 0-1 1-2 -1--1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - label name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;tag:label;text-align:left" len=40 + relations: label-for(1) + text: n=9 "User name" len=9 caret=-1 + words: 0-5 5-9 -1--1 + sentences: 0-9 -1--1 + lines: 0-9 -1--1 + paragraphs: 0-9 -1--1 + actions: doDefault,showContextMenu + - static name="User name" len=9 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=9 "User name" len=9 caret=-1 + words: 0-5 5-9 -1--1 + sentences: 0-9 -1--1 + lines: 0-9 -1--1 + paragraphs: 0-9 -1--1 + actions: doDefault,showContextMenu + - entry name="User name" len=9 children=0 + states: editable,enabled,focusable,selectable-text,sensitive,showing,single-line,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Text + attrs: "display:inline-block;explicit-name:true;id:userName;name-from:related-element;tag:input;text-align:left;text-input-type:text;text-model:a1" len=138 + relations: labelled-by(1) + text: n=0 "" len=0 caret=-1 + actions: activate,showContextMenu + - paragraph name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=2 "[obj][obj]" len=2 caret=-1 + words: 0-1 1-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-1 1-2 -1--1 + paragraphs: 0-1 1-2 -1--1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - label name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;tag:label;text-align:left" len=40 + relations: label-for(1) + text: n=8 "Password" len=8 caret=-1 + words: 0-8 -1--1 + sentences: 0-8 -1--1 + lines: 0-8 -1--1 + paragraphs: 0-8 -1--1 + actions: doDefault,showContextMenu + - static name="Password" len=8 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=8 "Password" len=8 caret=-1 + words: 0-8 -1--1 + sentences: 0-8 -1--1 + lines: 0-8 -1--1 + paragraphs: 0-8 -1--1 + actions: doDefault,showContextMenu + - password text name="Password" len=8 children=0 + states: editable,enabled,focusable,selectable-text,sensitive,showing,single-line,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Text + attrs: "display:inline-block;explicit-name:true;id:userPassword;name-from:related-element;tag:input;text-align:left;text-input-type:password;text-model:a1" len=146 + relations: labelled-by(1) + text: n=0 (password, content not read) + actions: activate,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - check box name="Remember me" len=11 children=0 + states: checkable,enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "checkable:true;display:inline-block;explicit-name:true;id:rememberMe;name-from:related-element;tag:input;text-align:left" len=120 + text: n=0 "" len=0 caret=-1 + actions: check,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - button name="Sign in" len=7 children=0 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;name-from:contents;tag:button;text-align:center" len=68 + text: n=7 "Sign in" len=7 caret=-1 + words: 0-5 5-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: press,showContextMenu + - heading name="Updates" len=7 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;level:2;name-from:contents;tag:h2;text-align:left" len=63 + text: n=7 "Updates" len=7 caret=-1 + words: 0-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: doDefault,showContextMenu + - static name="Updates" len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 "Updates" len=7 caret=-1 + words: 0-7 -1--1 + sentences: 0-7 -1--1 + lines: 0-7 -1--1 + paragraphs: 0-7 -1--1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - button name="Add item" len=8 children=0 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;id:addItem;name-from:contents;tag:button;text-align:center" len=79 + text: n=8 "Add item" len=8 caret=-1 + words: 0-4 4-8 -1--1 + sentences: 0-8 -1--1 + lines: 0-8 -1--1 + paragraphs: 0-8 -1--1 + actions: press,showContextMenu + - list name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:itemList;setsize:1;tag:ul;text-align:left" len=58 + text: n=1 "[obj]" len=1 caret=-1 + words: 0-1 -1--1 + sentences: 0-1 -1--1 + lines: 0-1 -1--1 + paragraphs: 0-1 -1--1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - list item name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:list-item;level:1;posinset:1;setsize:1;tag:li;text-align:left" len=69 + text: n=12 "• First item" len=12 caret=-1 + words: 0-2 2-8 8-12 -1--1 + sentences: 0-12 -1--1 + lines: 0-12 -1--1 + paragraphs: 0-12 -1--1 + actions: doDefault,showContextMenu + - static name="• " len=2 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;name-from:contents;tag:::marker;text-align:left" len=68 + text: n=2 "• " len=2 caret=-1 + words: 0-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-2 -1--1 + paragraphs: 0-2 -1--1 + actions: doDefault,showContextMenu + - static name="First item" len=10 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "First item" len=10 caret=-1 + words: 0-6 6-10 -1--1 + sentences: 0-10 -1--1 + lines: 0-10 -1--1 + paragraphs: 0-10 -1--1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "atomic:false;container-atomic:false;container-busy:false;container-live:polite;container-relevant:additions text;display:block;id:status;live:polite;relevant:additions text;tag:p;text-align:left" len=194 + text: n=15 "No items added." len=15 caret=-1 + words: 0-3 3-9 9-14 14-15 -1--1 + sentences: 0-15 -1--1 + lines: 0-15 -1--1 + paragraphs: 0-15 -1--1 + actions: doDefault,showContextMenu + - static name="No items added." len=15 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "atomic:false;container-atomic:false;container-busy:false;container-live:polite;container-relevant:additions text;name-from:contents;relevant:additions text" len=155 + text: n=15 "No items added." len=15 caret=-1 + words: 0-3 3-9 9-14 14-15 -1--1 + sentences: 0-15 -1--1 + lines: 0-15 -1--1 + paragraphs: 0-15 -1--1 + actions: doDefault,showContextMenu + - section name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:div;text-align:left" len=37 + text: n=31 "Spacer before the scores table." len=31 caret=-1 + words: 0-7 7-14 14-18 18-25 25-30 30-31 -1--1 + sentences: 0-31 -1--1 + lines: 0-31 -1--1 + paragraphs: 0-31 -1--1 + actions: doDefault,showContextMenu + - static name="Spacer before the scores table." len=31 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=31 "Spacer before the scores table." len=31 caret=-1 + words: 0-7 7-14 14-18 18-25 25-30 30-31 -1--1 + sentences: 0-31 -1--1 + lines: 0-31 -1--1 + paragraphs: 0-31 -1--1 + actions: doDefault,showContextMenu + - heading name="Scores" len=6 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:scores;level:2;name-from:contents;tag:h2;text-align:left" len=73 + text: n=6 "Scores" len=6 caret=-1 + words: 0-6 -1--1 + sentences: 0-6 -1--1 + lines: 0-6 -1--1 + paragraphs: 0-6 -1--1 + actions: doDefault,showContextMenu + - static name="Scores" len=6 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=6 "Scores" len=6 caret=-1 + words: 0-6 -1--1 + sentences: 0-6 -1--1 + lines: 0-6 -1--1 + paragraphs: 0-6 -1--1 + actions: doDefault,showContextMenu + - table name="High scores" len=11 children=4 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Table,Text + attrs: "display:table;explicit-name:true;name-from:caption;tag:table;text-align:left" len=76 + relations: labelled-by(1) + text: n=4 "[obj][obj][obj][obj]" len=4 caret=-1 + words: 0-1 1-2 2-3 3-4 -1--1 + sentences: 0-4 -1--1 + lines: 0-1 1-2 2-3 3-4 -1--1 + paragraphs: 0-1 1-2 2-3 3-4 -1--1 + hyperlinks: 4 [0-1] [1-2] [2-3] [3-4] + actions: doDefault,showContextMenu + table: 3x2 + - caption name="" len=0 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-caption;tag:caption;text-align:center" len=51 + relations: label-for(1) + text: n=11 "High scores" len=11 caret=-1 + words: 0-5 5-11 -1--1 + sentences: 0-11 -1--1 + lines: 0-11 -1--1 + paragraphs: 0-11 -1--1 + actions: doDefault,showContextMenu + - static name="High scores" len=11 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=11 "High scores" len=11 caret=-1 + words: 0-5 5-11 -1--1 + sentences: 0-11 -1--1 + lines: 0-11 -1--1 + paragraphs: 0-11 -1--1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + words: 0-1 1-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-1 1-2 -1--1 + paragraphs: 0-1 1-2 -1--1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - column header name="Player" len=6 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:0;tag:th;text-align:center" len=81 + text: n=6 "Player" len=6 caret=-1 + words: 0-6 -1--1 + sentences: 0-6 -1--1 + lines: 0-6 -1--1 + paragraphs: 0-6 -1--1 + actions: doDefault,showContextMenu + cell: position=r0 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player" len=6 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=6 "Player" len=6 caret=-1 + words: 0-6 -1--1 + sentences: 0-6 -1--1 + lines: 0-6 -1--1 + paragraphs: 0-6 -1--1 + actions: doDefault,showContextMenu + - column header name="Score" len=5 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:1;tag:th;text-align:center" len=81 + text: n=5 "Score" len=5 caret=-1 + words: 0-5 -1--1 + sentences: 0-5 -1--1 + lines: 0-5 -1--1 + paragraphs: 0-5 -1--1 + actions: doDefault,showContextMenu + cell: position=r0 c1 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Score" len=5 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=5 "Score" len=5 caret=-1 + words: 0-5 -1--1 + sentences: 0-5 -1--1 + lines: 0-5 -1--1 + paragraphs: 0-5 -1--1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + words: 0-1 1-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-1 1-2 -1--1 + paragraphs: 0-1 1-2 -1--1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - row header name="Player One" len=10 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:2;tag:th;text-align:center" len=81 + text: n=10 "Player One" len=10 caret=-1 + words: 0-7 7-10 -1--1 + sentences: 0-10 -1--1 + lines: 0-10 -1--1 + paragraphs: 0-10 -1--1 + actions: doDefault,showContextMenu + cell: position=r1 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player One" len=10 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "Player One" len=10 caret=-1 + words: 0-7 7-10 -1--1 + sentences: 0-10 -1--1 + lines: 0-10 -1--1 + paragraphs: 0-10 -1--1 + actions: doDefault,showContextMenu + - table cell name="1200" len=4 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:3;tag:td;text-align:left" len=79 + text: n=4 "1200" len=4 caret=-1 + words: 0-4 -1--1 + sentences: 0-4 -1--1 + lines: 0-4 -1--1 + paragraphs: 0-4 -1--1 + actions: doDefault,showContextMenu + cell: position=r1 c1 span=1x1 columnHeaders=1 rowHeaders=1 + - static name="1200" len=4 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=4 "1200" len=4 caret=-1 + words: 0-4 -1--1 + sentences: 0-4 -1--1 + lines: 0-4 -1--1 + paragraphs: 0-4 -1--1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + words: 0-1 1-2 -1--1 + sentences: 0-2 -1--1 + lines: 0-1 1-2 -1--1 + paragraphs: 0-1 1-2 -1--1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - row header name="Player Two" len=10 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:4;tag:th;text-align:center" len=81 + text: n=10 "Player Two" len=10 caret=-1 + words: 0-7 7-10 -1--1 + sentences: 0-10 -1--1 + lines: 0-10 -1--1 + paragraphs: 0-10 -1--1 + actions: doDefault,showContextMenu + cell: position=r2 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player Two" len=10 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "Player Two" len=10 caret=-1 + words: 0-7 7-10 -1--1 + sentences: 0-10 -1--1 + lines: 0-10 -1--1 + paragraphs: 0-10 -1--1 + actions: doDefault,showContextMenu + - table cell name="950" len=3 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:5;tag:td;text-align:left" len=79 + text: n=3 "950" len=3 caret=-1 + words: 0-3 -1--1 + sentences: 0-3 -1--1 + lines: 0-3 -1--1 + paragraphs: 0-3 -1--1 + actions: doDefault,showContextMenu + cell: position=r2 c1 span=1x1 columnHeaders=1 rowHeaders=1 + - static name="950" len=3 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=3 "950" len=3 caret=-1 + words: 0-3 -1--1 + sentences: 0-3 -1--1 + lines: 0-3 -1--1 + paragraphs: 0-3 -1--1 + actions: doDefault,showContextMenu +nodes=61 diff --git a/tests/browser/data/native-electron42-application.txt b/tests/browser/data/native-electron42-application.txt new file mode 100644 index 0000000..aa8d8e6 --- /dev/null +++ b/tests/browser/data/native-electron42-application.txt @@ -0,0 +1,504 @@ +application: name="electron" len=8 toolkit=Chromium version=1.0 pid=130722 +- application name="electron" len=8 children=1 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Application,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "explicit-name:true;name-from:attribute" len=38 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - frame name="Wine Access Electron Test" len=25 children=1 + states: active,enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:RootView;explicit-name:true;name-from:attribute" len=53 + relations: embeds(1) + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - panel name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:NonClientView" len=19 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - panel name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:NativeFrameView" len=21 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - panel name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:ClientView" len=16 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - panel name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:View" len=10 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - menu bar name="" len=0 children=4 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Selection,Text + attrs: "class:MenuBar;explicit-name:true" len=32 + text: n=4 "[obj][obj][obj][obj]" len=4 caret=-1 + hyperlinks: 4 [0-1] [1-2] [2-3] [3-4] + actions: doDefault,showContextMenu + - button name="File" len=4 children=0 + states: enabled,focusable,has-popup,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:SubmenuButton;explicit-name:true;haspopup:menu;name-from:attribute" len=72 + text: n=4 "File" len=4 caret=-1 + actions: open,showContextMenu + - button name="Edit" len=4 children=0 + states: enabled,focusable,has-popup,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:SubmenuButton;explicit-name:true;haspopup:menu;name-from:attribute" len=72 + text: n=4 "Edit" len=4 caret=-1 + actions: open,showContextMenu + - button name="View" len=4 children=0 + states: enabled,focusable,has-popup,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:SubmenuButton;explicit-name:true;haspopup:menu;name-from:attribute" len=72 + text: n=4 "View" len=4 caret=-1 + actions: open,showContextMenu + - button name="Window" len=6 children=0 + states: enabled,focusable,has-popup,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:SubmenuButton;explicit-name:true;haspopup:menu;name-from:attribute" len=72 + text: n=6 "Window" len=6 caret=-1 + actions: open,showContextMenu + - panel name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:View" len=10 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - panel name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:View" len=10 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - panel name="" len=0 children=1 + states: enabled,sensitive + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:WebView;explicit-name:true;hidden:true" len=44 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - panel name="" len=0 children=0 + states: enabled,sensitive + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:NativeViewHost;hidden:true" len=32 + text: n=0 "" len=0 caret=-1 + actions: doDefault,showContextMenu + - document web name="Wine Access Electron Test" len=25 children=1 + states: enabled,focusable,focused,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "explicit-name:true;name-from:related-element;tag:#document;text-align:left" len=74 + relations: embedded-by(1) + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu,scrollBackward,scrollDown,scrollForward,scrollLeft,scrollRight,scrollUp + - landmark name="" len=0 children=12 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:main;text-align:left;xml-roles:main" len=53 + text: n=12 "[obj][obj][obj][obj][obj][obj][obj][obj][obj][obj][obj][obj]" len=12 caret=-1 + hyperlinks: 12 [0-1] [1-2] [2-3] [3-4] [4-5] [5-6] + actions: doDefault,showContextMenu + - heading name="Wine Access test page" len=21 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;level:1;name-from:contents;tag:h1;text-align:left" len=63 + text: n=21 "Wine Access test page" len=21 caret=-1 + actions: doDefault,showContextMenu + - static name="Wine Access test page" len=21 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=21 "Wine Access test page" len=21 caret=-1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=3 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=30 "This paragraph has an [obj] in it." len=30 caret=-1 + hyperlinks: 1 [22-23] + actions: doDefault,showContextMenu + - static name="This paragraph has an " len=22 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=22 "This paragraph has an " len=22 caret=-1 + actions: doDefault,showContextMenu + - link name="inline link to the details section" len=34 children=1 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;name-from:contents;tag:a;text-align:left" len=55 + text: n=34 "inline link to the details section" len=34 caret=-1 + actions: jump,showContextMenu + - static name="inline link to the details section" len=34 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=34 "inline link to the details section" len=34 caret=-1 + actions: clickAncestor,showContextMenu + - static name=" in it." len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 " in it." len=7 caret=-1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=3 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=29 "Emoji 🙂 and café before a [obj]." len=29 caret=-1 + hyperlinks: 1 [27-28] + actions: doDefault,showContextMenu + - static name="Emoji 🙂 and café before a " len=27 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=27 "Emoji 🙂 and café before a " len=27 caret=-1 + actions: doDefault,showContextMenu + - link name="second link" len=11 children=1 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;name-from:contents;tag:a;text-align:left" len=55 + text: n=11 "second link" len=11 caret=-1 + actions: jump,showContextMenu + - static name="second link" len=11 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=11 "second link" len=11 caret=-1 + actions: clickAncestor,showContextMenu + - static name="." len=1 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=1 "." len=1 caret=-1 + actions: doDefault,showContextMenu + - heading name="Details" len=7 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:details;level:2;name-from:contents;tag:h2;text-align:left" len=74 + text: n=7 "Details" len=7 caret=-1 + actions: doDefault,showContextMenu + - static name="Details" len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 "Details" len=7 caret=-1 + actions: doDefault,showContextMenu + - section name="" len=0 children=4 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:form;text-align:left" len=38 + text: n=4 "[obj][obj][obj][obj]" len=4 caret=-1 + hyperlinks: 4 [0-1] [1-2] [2-3] [3-4] + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - label name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;tag:label;text-align:left" len=40 + relations: label-for(1) + text: n=9 "User name" len=9 caret=-1 + actions: doDefault,showContextMenu + - static name="User name" len=9 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=9 "User name" len=9 caret=-1 + actions: doDefault,showContextMenu + - entry name="User name" len=9 children=0 + states: editable,enabled,focusable,selectable-text,sensitive,showing,single-line,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Text + attrs: "display:inline-block;explicit-name:true;id:userName;name-from:related-element;tag:input;text-align:left;text-input-type:text;text-model:a1" len=138 + relations: labelled-by(1) + text: n=0 "" len=0 caret=-1 + actions: activate,showContextMenu + - paragraph name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - label name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline;tag:label;text-align:left" len=40 + relations: label-for(1) + text: n=8 "Password" len=8 caret=-1 + actions: doDefault,showContextMenu + - static name="Password" len=8 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=8 "Password" len=8 caret=-1 + actions: doDefault,showContextMenu + - password text name="Password" len=8 children=0 + states: editable,enabled,focusable,selectable-text,sensitive,showing,single-line,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Text + attrs: "display:inline-block;explicit-name:true;id:userPassword;name-from:related-element;tag:input;text-align:left;text-input-type:password;text-model:a1" len=146 + relations: labelled-by(1) + text: n=0 (password, content not read) + actions: activate,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - check box name="Remember me" len=11 children=0 + states: checkable,enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "checkable:true;display:inline-block;explicit-name:true;id:rememberMe;name-from:related-element;tag:input;text-align:left" len=120 + text: n=0 "" len=0 caret=-1 + actions: check,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - button name="Sign in" len=7 children=0 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;name-from:contents;tag:button;text-align:center" len=68 + text: n=7 "Sign in" len=7 caret=-1 + actions: press,showContextMenu + - heading name="Updates" len=7 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;level:2;name-from:contents;tag:h2;text-align:left" len=63 + text: n=7 "Updates" len=7 caret=-1 + actions: doDefault,showContextMenu + - static name="Updates" len=7 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=7 "Updates" len=7 caret=-1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:p;text-align:left" len=35 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - button name="Add item" len=8 children=0 + states: enabled,focusable,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;id:addItem;name-from:contents;tag:button;text-align:center" len=79 + text: n=8 "Add item" len=8 caret=-1 + actions: press,showContextMenu + - list name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:itemList;setsize:1;tag:ul;text-align:left" len=58 + text: n=1 "[obj]" len=1 caret=-1 + hyperlinks: 1 [0-1] + actions: doDefault,showContextMenu + - list item name="" len=0 children=2 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:list-item;level:1;posinset:1;setsize:1;tag:li;text-align:left" len=69 + text: n=12 "• First item" len=12 caret=-1 + actions: doDefault,showContextMenu + - static name="• " len=2 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:inline-block;name-from:contents;tag:::marker;text-align:left" len=68 + text: n=2 "• " len=2 caret=-1 + actions: doDefault,showContextMenu + - static name="First item" len=10 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "First item" len=10 caret=-1 + actions: doDefault,showContextMenu + - paragraph name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "atomic:false;container-atomic:false;container-busy:false;container-live:polite;container-relevant:additions text;display:block;id:status;live:polite;relevant:additions text;tag:p;text-align:left" len=194 + text: n=15 "No items added." len=15 caret=-1 + actions: doDefault,showContextMenu + - static name="No items added." len=15 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "atomic:false;container-atomic:false;container-busy:false;container-live:polite;container-relevant:additions text;name-from:contents;relevant:additions text" len=155 + text: n=15 "No items added." len=15 caret=-1 + actions: doDefault,showContextMenu + - section name="" len=0 children=1 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;tag:div;text-align:left" len=37 + text: n=31 "Spacer before the scores table." len=31 caret=-1 + actions: doDefault,showContextMenu + - static name="Spacer before the scores table." len=31 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=31 "Spacer before the scores table." len=31 caret=-1 + actions: doDefault,showContextMenu + - heading name="Scores" len=6 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:block;id:scores;level:2;name-from:contents;tag:h2;text-align:left" len=73 + text: n=6 "Scores" len=6 caret=-1 + actions: doDefault,showContextMenu + - static name="Scores" len=6 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=6 "Scores" len=6 caret=-1 + actions: doDefault,showContextMenu + - table name="High scores" len=11 children=4 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Table,Text + attrs: "display:table;explicit-name:true;name-from:caption;tag:table;text-align:left" len=76 + relations: labelled-by(1) + text: n=4 "[obj][obj][obj][obj]" len=4 caret=-1 + hyperlinks: 4 [0-1] [1-2] [2-3] [3-4] + actions: doDefault,showContextMenu + table: 3x2 + - caption name="" len=0 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-caption;tag:caption;text-align:center" len=51 + relations: label-for(1) + text: n=11 "High scores" len=11 caret=-1 + actions: doDefault,showContextMenu + - static name="High scores" len=11 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=11 "High scores" len=11 caret=-1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - column header name="Player" len=6 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:0;tag:th;text-align:center" len=81 + text: n=6 "Player" len=6 caret=-1 + actions: doDefault,showContextMenu + cell: position=r0 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player" len=6 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=6 "Player" len=6 caret=-1 + actions: doDefault,showContextMenu + - column header name="Score" len=5 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:1;tag:th;text-align:center" len=81 + text: n=5 "Score" len=5 caret=-1 + actions: doDefault,showContextMenu + cell: position=r0 c1 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Score" len=5 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=5 "Score" len=5 caret=-1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - row header name="Player One" len=10 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:2;tag:th;text-align:center" len=81 + text: n=10 "Player One" len=10 caret=-1 + actions: doDefault,showContextMenu + cell: position=r1 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player One" len=10 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "Player One" len=10 caret=-1 + actions: doDefault,showContextMenu + - table cell name="1200" len=4 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:3;tag:td;text-align:left" len=79 + text: n=4 "1200" len=4 caret=-1 + actions: doDefault,showContextMenu + cell: position=r1 c1 span=1x1 columnHeaders=1 rowHeaders=1 + - static name="1200" len=4 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=4 "1200" len=4 caret=-1 + actions: doDefault,showContextMenu + - table row name="" len=0 children=2 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "display:table-row;tag:tr;text-align:left" len=40 + text: n=2 "[obj][obj]" len=2 caret=-1 + hyperlinks: 2 [0-1] [1-2] + actions: doDefault,showContextMenu + - row header name="Player Two" len=10 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:4;tag:th;text-align:center" len=81 + text: n=10 "Player Two" len=10 caret=-1 + actions: doDefault,showContextMenu + cell: position=r2 c0 span=1x1 columnHeaders=0 rowHeaders=0 + - static name="Player Two" len=10 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=10 "Player Two" len=10 caret=-1 + actions: doDefault,showContextMenu + - table cell name="950" len=3 children=1 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,TableCell,Text + attrs: "display:table-cell;name-from:contents;table-cell-index:5;tag:td;text-align:left" len=79 + text: n=3 "950" len=3 caret=-1 + actions: doDefault,showContextMenu + cell: position=r2 c1 span=1x1 columnHeaders=1 rowHeaders=1 + - static name="950" len=3 children=0 + states: enabled,sensitive,visible + interfaces: Accessible,Action,Collection,Component,Document,Hypertext,Text + attrs: "name-from:contents" len=18 + text: n=3 "950" len=3 caret=-1 + actions: doDefault,showContextMenu + - panel name="" len=0 children=0 + states: enabled,sensitive,showing,visible + interfaces: Accessible,Action,Collection,Component,Document,Hyperlink,Hypertext,Text + attrs: "class:View" len=10 + text: n=0 "" len=0 caret=-1 + actions: doDefault,showContextMenu +nodes=77 diff --git a/tests/browser/fixture-app/fixture.html b/tests/browser/fixture-app/fixture.html new file mode 100644 index 0000000..2bc4933 --- /dev/null +++ b/tests/browser/fixture-app/fixture.html @@ -0,0 +1,45 @@ + + + + +Wine Access Electron Test + + +
+

Wine Access test page

+

This paragraph has an inline link to the details section in it.

+

Emoji 🙂 and café before a second link.

+

Details

+ +

+

+

+

+ +

Updates

+

+
  • First item
+

No items added.

+
Spacer before the scores table.
+

Scores

+ + + + + + + +
High scores
PlayerScore
Player One1200
Player Two950
+
+ + + diff --git a/tests/browser/fixture-app/main.js b/tests/browser/fixture-app/main.js new file mode 100644 index 0000000..53f1756 --- /dev/null +++ b/tests/browser/fixture-app/main.js @@ -0,0 +1,29 @@ +// Minimal Electron app for Wine Access browser testing. +// Pass --smoke-test to record the rendered heading and exit. +const { app, BrowserWindow } = require('electron'); +const fs = require('fs'); +const path = require('path'); + +const smokeTest = process.argv.includes('--smoke-test'); +const resultFile = path.join(__dirname, 'render-check.txt'); + +function write_result(text) { + fs.writeFileSync(resultFile, `${text}\n`); +} + +app.whenReady().then(async () => { + const mainWindow = new BrowserWindow({ width: 1024, height: 768 }); + try { + await mainWindow.loadFile(path.join(__dirname, 'fixture.html')); + const headingText = await mainWindow.webContents.executeJavaScript( + "document.querySelector('h1').textContent"); + write_result(`render-ok ${process.versions.electron} chrome ${process.versions.chrome} heading=${headingText}`); + } catch (error) { + write_result(`render-failed ${process.versions.electron}: ${error}`); + } + if (smokeTest) { + app.quit(); + } +}); + +app.on('window-all-closed', () => app.quit()); diff --git a/tests/browser/fixture-app/package.json b/tests/browser/fixture-app/package.json new file mode 100644 index 0000000..a8dd3e1 --- /dev/null +++ b/tests/browser/fixture-app/package.json @@ -0,0 +1,5 @@ +{ + "name": "wine-access-electron-test", + "version": "1.0.0", + "main": "main.js" +} diff --git a/tests/browser/helper_integration.py b/tests/browser/helper_integration.py new file mode 100755 index 0000000..c17020a --- /dev/null +++ b/tests/browser/helper_integration.py @@ -0,0 +1,193 @@ +#!/usr/bin/env python3 +"""End-to-end check of the helper's browser bridge. + +Runs inside live_session.sh's private session and display, with the Electron +fixture already started in WINEPREFIX. Registers a fake Cthulhu reader on the +session bus, starts wine-access.exe, and checks that the helper publishes the +Chromium window, that legacy announcements stop for it, that a killed +publisher is restarted, and that nothing is left behind when the helper exits. + +Usage: helper_integration.py BUILD_DIR +""" + +import os +import signal +import subprocess +import sys +import threading +import time +from pathlib import Path + +import gi + +gi.require_version("Atspi", "2.0") +from gi.repository import Atspi, Gio, GLib # noqa: E402 + +BUS_NAME = "org.stormux.Cthulhu1.Service" +OBJECT_PATH = "/" + BUS_NAME.replace(".", "/") +TITLE = "Wine Access Electron Test" + +failures = 0 +presented = [] +helperLines = [] + + +def check(name, condition, detail=""): + global failures + if condition: + print(f"PASS: {name}", flush=True) + else: + failures += 1 + print(f"FAIL: {name} {detail}", flush=True) + + +def pump(seconds): + context = GLib.MainContext.default() + deadline = time.monotonic() + seconds + while time.monotonic() < deadline: + while context.pending(): + context.iteration(False) + time.sleep(0.01) + + +def wait_until(predicate, seconds): + deadline = time.monotonic() + seconds + while time.monotonic() < deadline: + if predicate(): + return True + pump(0.1) + return predicate() + + +def register_reader(): + xml = '' + for index, kind in enumerate(["s"] * 7 + ["i", "i", "s"]): + xml += f'' + xml += '' + for method, inputs in (("SpeakText", "sb"), ("CancelSpeech", "")): + xml += '' + xml += "".join('' for kind in inputs) + xml += '' + xml += "" + + def record(connection, sender, path, interface, method, parameters, invocation): + if method == "PresentAccessibleEvent": + presented.append(parameters.unpack()) + invocation.return_value(GLib.Variant("(b)", (True,))) + + connection = Gio.bus_get_sync(Gio.BusType.SESSION, None) + connection.register_object(OBJECT_PATH, Gio.DBusNodeInfo.new_for_xml(xml).interfaces[0], record, None, None) + connection.call_sync("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName", + GLib.Variant("(su)", (BUS_NAME, 0)), None, Gio.DBusCallFlags.NONE, 1000, None) + return connection + + +def find(accessible, role, name=None, depth=0): + if accessible is None or depth > 60: + return None + try: + if accessible.get_role_name() == role and (name is None or (accessible.get_name() or "").startswith(name)): + return accessible + count = accessible.get_child_count() + except Exception: + return None + for index in range(count): + try: + found = find(accessible.get_child_at_index(index), role, name, depth + 1) + except Exception: + found = None + if found is not None: + return found + return None + + +def published_application(): + desktop = Atspi.get_desktop(0) + for index in range(desktop.get_child_count()): + application = desktop.get_child_at_index(index) + if application is not None and application.get_name() == "electron": + return application + return None + + +def process_pids(matches): + pids = [] + for entry in Path("/proc").iterdir(): + if not entry.name.isdigit(): + continue + try: + commandLine = (entry / "cmdline").read_bytes().split(b"\0") + except OSError: + continue + if commandLine and matches(commandLine): + pids.append(int(entry.name)) + return pids + + +def publisher_pids(): + return process_pids(lambda arguments: arguments[0].endswith(b"wine-access-browser-publisher")) + + +def worker_pids(): + return process_pids(lambda arguments: any(argument.lower().endswith(b"wine-access-browser-worker.exe") + for argument in arguments)) + + +def main(): + build = Path(sys.argv[1]).resolve() + readerConnection = register_reader() # releasing it would drop the reader's bus name + helper = subprocess.Popen([str(build / "wine-access.exe"), "--no-controller"], stderr=subprocess.PIPE, + env=os.environ.copy()) + threading.Thread(target=lambda: [helperLines.append(line.decode(errors="replace").rstrip()) + for line in helper.stderr], daemon=True).start() + try: + check("helper reports the browser bridge active", + wait_until(lambda: any('"browser_bridge":true' in line for line in helperLines), 30), + str(helperLines[-5:])) + subprocess.run(["xdotool", "search", "--name", TITLE, "windowactivate", "--sync"], capture_output=True) + published = wait_until(lambda: any("published; legacy announcements retired" in line + for line in helperLines), 60) + check("helper starts a publisher that publishes", published, str(helperLines[-5:])) + application = None + if published: + wait_until(lambda: published_application() is not None, 20) + application = published_application() + check("electron application appears on the accessibility bus", application is not None) + entry = find(application, "entry", "User name") if application else None + check("the page's text field is published", entry is not None) + if entry is not None: + Atspi.Component.grab_focus(entry) + pump(1.5) + presented.clear() + subprocess.run(["xdotool", "search", "--name", TITLE, "windowfocus", "--sync"], capture_output=True) + subprocess.run(["xdotool", "type", "--delay", "100", "abc"], capture_output=True) + pump(2.5) + text = Atspi.Text.get_text(entry, 0, -1) + check("typing reached the published field", text == "abc", repr(text)) + check("no legacy announcements while typing in the published window", not presented, + str(presented[:3])) + + before = publisher_pids() + check("exactly one publisher is running", len(before) == 1, str(before)) + if before: + os.kill(before[0], signal.SIGKILL) + restarted = wait_until(lambda: any(pid not in before for pid in publisher_pids()), 30) and \ + wait_until(lambda: sum("published; legacy announcements retired" in line for line in helperLines) >= 2, + 60) + check("a killed publisher is restarted and publishes again", restarted, str(helperLines[-5:])) + finally: + helper.send_signal(signal.SIGTERM) + try: + helper.wait(timeout=15) + except subprocess.TimeoutExpired: + helper.kill() + helper.wait() + check("no publisher survives the helper", wait_until(lambda: not publisher_pids(), 10), str(publisher_pids())) + check("no worker survives the helper", wait_until(lambda: not worker_pids(), 10), str(worker_pids())) + readerConnection.close_sync(None) + print("\n".join(line for line in helperLines if "browser" in line), flush=True) + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/browser/live_checks.sh b/tests/browser/live_checks.sh new file mode 100755 index 0000000..5b2f689 --- /dev/null +++ b/tests/browser/live_checks.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Run every live browser bridge check and compare the bridge with native +# Chromium. Needs Xvfb, native Chromium, and a Wine prefix with Electron. +# Usage: live_checks.sh BUILD_DIR PREFIX [OUTPUT_DIR] +# Exits non-zero if any check fails. +set -u + +if [[ $# -lt 2 ]]; then + echo "Usage: $0 BUILD_DIR PREFIX [OUTPUT_DIR]" + exit 2 +fi + +buildDir="$1" +winePrefix="$2" +outputDir="${3:-$(mktemp -d)}" +testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +failures=0 + +record() { + if [[ "$2" -eq 0 ]]; then + echo "PASS: $1" + else + echo "FAIL: $1" + failures=$((failures + 1)) + fi +} + +"$testDir/live_session.sh" worker "$buildDir" "$outputDir" "$winePrefix" > /dev/null +record "worker protocol ($(grep -c '^PASS' "$outputDir/worker.txt" 2> /dev/null) checks passed)" $? +grep '^FAIL' "$outputDir/worker.txt" 2> /dev/null + +"$testDir/live_session.sh" helper "$buildDir" "$outputDir" "$winePrefix" > /dev/null +record "helper bridge lifecycle ($(grep -c '^PASS' "$outputDir/helper.txt" 2> /dev/null) checks passed)" $? +grep '^FAIL' "$outputDir/helper.txt" 2> /dev/null + +"$testDir/live_session.sh" native "$buildDir" "$outputDir" > /dev/null +record "native Chromium reference session" $? +"$testDir/live_session.sh" wine "$buildDir" "$outputDir" "$winePrefix" > /dev/null +record "bridge session under Wine" $? + +python3 -I "$testDir/compare_dumps.py" "$outputDir/native.tree.txt" "$outputDir/wine.tree.txt" \ + > "$outputDir/tree.diff" +record "live tree and text boundaries match native Chromium" $? +python3 -I "$testDir/compare_events.py" "$outputDir/native.events.txt" "$outputDir/wine.events.txt" \ + > "$outputDir/events.diff" +record "event sequence matches native Chromium" $? +! grep -q -E 'WARNING|CRITICAL' "$outputDir/wine.publisher.log" +record "no publisher warnings" $? +grep -h 'passwordLeaks' "$outputDir/native.txt" "$outputDir/wine.txt" +grep -q 'passwordLeaks=0' "$outputDir/wine.txt" +record "no password characters in events" $? +grep -h '^reading:' "$outputDir/native.txt" "$outputDir/wine.txt" + +echo +echo "Results in $outputDir" +if [[ "$failures" -eq 0 ]]; then + echo "All live checks passed" +else + echo "$failures live check(s) failed" +fi +[[ "$failures" -eq 0 ]] diff --git a/tests/browser/live_driver.py b/tests/browser/live_driver.py new file mode 100755 index 0000000..820e130 --- /dev/null +++ b/tests/browser/live_driver.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +"""Drive the fixture through AT-SPI and log the events a reader would receive. + +The same scenario runs against native Chromium and against the Wine Access +publisher, so the two logs can be compared step by step. + +Usage: live_driver.py --app-name NAME --log FILE [--title TITLE] +Exits non-zero if the scenario cannot run or a password character leaks. +""" + +import argparse +import subprocess +import sys +import time +import warnings + +import gi + +gi.require_version("Atspi", "2.0") +from gi.repository import Atspi, GLib # noqa: E402 + +warnings.filterwarnings("ignore", category=DeprecationWarning) + +SECRET = "Qz7Xk9Wv" # no English letter runs, so fragments cannot match event names +EVENT_TYPES = [ + "object:state-changed", "object:text-changed", "object:text-caret-moved", "object:text-selection-changed", + "object:children-changed", "object:property-change:accessible-name", + "object:property-change:accessible-description", "object:property-change:accessible-value", + "window:activate", "window:deactivate", "document:load-complete", "object:active-descendant-changed", + "focus:", +] +# State changes that only reflect geometry or rendering, not presentation. +IGNORED_STATES = {"showing", "visible"} + +events = [] +recording = False + + +def safe(call, default=None): + try: + return call() + except Exception: + return default + + +def describe(accessible): + if accessible is None: + return "none" + role = safe(lambda: accessible.get_role_name(), "?") + name = safe(lambda: accessible.get_name(), "") or "" + return f"{role}:{name[:40]}" + + +def on_event(event): + if not recording: + return + eventType = event.type + if eventType.startswith("object:state-changed:") and eventType.split(":")[-1] in IGNORED_STATES: + return + data = event.any_data + if isinstance(data, str): + dataText = repr(data[:40]) + elif isinstance(data, Atspi.Accessible): + dataText = describe(data) + else: + dataText = "" + events.append(f"{eventType} d1={event.detail1} d2={event.detail2} src={describe(event.source)} data={dataText}") + + +def pump(seconds): + context = GLib.MainContext.default() + deadline = time.monotonic() + seconds + while time.monotonic() < deadline: + while context.pending(): + context.iteration(False) + time.sleep(0.01) + + +def find(accessible, predicate, depth=0): + if depth > 60 or accessible is None: + return None + if predicate(accessible): + return accessible + for index in range(safe(lambda: accessible.get_child_count(), 0) or 0): + found = find(safe(lambda: accessible.get_child_at_index(index)), predicate, depth + 1) + if found is not None: + return found + return None + + +def by_role_name(role, name=None): + def predicate(accessible): + if safe(lambda: accessible.get_role_name()) != role: + return False + return name is None or (safe(lambda: accessible.get_name(), "") or "").startswith(name) + return predicate + + +def measure_reading(document): + """Time what a reader does per line: line text, its range extents and the + first character's position, for every text object in document order.""" + objects = [] + + def collect(accessible, depth=0): + if depth > 60 or accessible is None: + return + if safe(lambda: accessible.get_text_iface()) is not None: + objects.append(accessible) + for index in range(safe(lambda: accessible.get_child_count(), 0) or 0): + collect(safe(lambda: accessible.get_child_at_index(index)), depth + 1) + + collect(document) + timings = [] + for accessible in objects: + count = safe(lambda: Atspi.Text.get_character_count(accessible), 0) or 0 + if count <= 0: + continue + started = time.monotonic() + line = safe(lambda: Atspi.Text.get_string_at_offset(accessible, 0, Atspi.TextGranularity.LINE)) + end = line.end_offset if line is not None and line.end_offset > 0 else count + safe(lambda: Atspi.Text.get_range_extents(accessible, 0, end, Atspi.CoordType.SCREEN)) + safe(lambda: Atspi.Text.get_character_extents(accessible, 0, Atspi.CoordType.SCREEN)) + timings.append((time.monotonic() - started) * 1000) + if not timings: + return "reading: no text objects" + timings.sort() + return (f"reading: objects={len(timings)} total={sum(timings):.0f}ms median={timings[len(timings) // 2]:.1f}ms " + f"max={timings[-1]:.1f}ms") + + +def xdotool(title, *arguments): + subprocess.run(["xdotool", "search", "--name", title, "windowactivate", "--sync"], capture_output=True) + subprocess.run(["xdotool", "search", "--name", title, "windowfocus", "--sync"], capture_output=True) + subprocess.run(["xdotool", *arguments], capture_output=True) + + +def main(): + global recording + parser = argparse.ArgumentParser() + parser.add_argument("--app-name", required=True) + parser.add_argument("--log", required=True) + parser.add_argument("--title", default="Wine Access Electron Test") + parser.add_argument("--step-seconds", type=float, default=1.5) + options = parser.parse_args() + + listener = Atspi.EventListener.new(on_event) + for eventType in EVENT_TYPES: + listener.register(eventType) + + deadline = time.monotonic() + 60 + application = document = None + while time.monotonic() < deadline and document is None: + desktop = Atspi.get_desktop(0) + for index in range(desktop.get_child_count()): + candidate = safe(lambda: desktop.get_child_at_index(index)) + if candidate is not None and options.app_name.lower() in (safe(lambda: candidate.get_name(), "") or "").lower(): + application = candidate + document = find(candidate, lambda a: safe(lambda: a.get_role()) == Atspi.Role.DOCUMENT_WEB + and (safe(lambda: a.get_child_count(), 0) or 0) > 0) + if document is not None: + break + pump(0.5) + if document is None: + print("document not found") + return 3 + + userName = find(document, by_role_name("entry", "User name")) + password = find(document, by_role_name("password text", "Password")) + checkbox = find(document, by_role_name("check box", "Remember me")) + addButton = find(document, by_role_name("button", "Add item")) + link = find(document, by_role_name("link", "inline link")) + table = find(document, by_role_name("table")) + missing = [name for name, value in (("entry", userName), ("password", password), ("checkbox", checkbox), + ("add button", addButton), ("link", link), ("table", table)) if value is None] + if missing: + print(f"fixture objects not found: {missing}") + return 3 + + steps = [ + ("focus entry", lambda: Atspi.Component.grab_focus(userName)), + ("type abc", lambda: xdotool(options.title, "type", "--delay", "100", "abc")), + ("caret to 1", lambda: Atspi.Text.set_caret_offset(userName, 1)), + ("select 0-2", lambda: Atspi.Text.add_selection(userName, 0, 2)), + ("check checkbox", lambda: Atspi.Action.do_action(checkbox, 0)), + ("add item", lambda: Atspi.Action.do_action(addButton, 0)), + ("follow link", lambda: Atspi.Action.do_action(link, 0)), + ("scroll table", lambda: Atspi.Component.scroll_to(table, Atspi.ScrollType.TOP_EDGE)), + ("focus password", lambda: Atspi.Component.grab_focus(password)), + ("type password", lambda: xdotool(options.title, "type", "--delay", "100", SECRET)), + ] + print(measure_reading(document), flush=True) + print(measure_reading(document) + " (second pass)", flush=True) + log = [] + pump(1.0) + recording = True + pump(0.5) + events.clear() + for label, action in steps: + result = safe(action, "error") + pump(options.step_seconds) + log.append(f"STEP {label} result={result}") + log.extend(events) + events.clear() + recording = False + with open(options.log, "w", encoding="utf-8") as logFile: + logFile.write("\n".join(log) + "\n") + # Any three consecutive secret characters inside an event's text payload, + # or the whole secret anywhere, is a leak. + fragments = [SECRET[index:index + 3] for index in range(len(SECRET) - 2)] + leaked = [line for line in log if SECRET in line or + (" data='" in line and any(fragment in line.split(" data=", 1)[1] for fragment in fragments))] + print(f"steps={len(steps)} events={sum(1 for line in log if not line.startswith('STEP'))} " + f"passwordLeaks={len(leaked)}") + return 1 if leaked else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/browser/live_session.sh b/tests/browser/live_session.sh new file mode 100755 index 0000000..f47ccde --- /dev/null +++ b/tests/browser/live_session.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# Live browser bridge checks against the Electron fixture app, on a private +# display and accessibility bus, never touching the user's session. +# Usage: live_session.sh MODE BUILD_DIR OUTPUT_DIR [PREFIX] +# MODE worker ia2 worker protocol checks (worker_driver.py) +# helper the helper starts, supervises and retires publishers +# (helper_integration.py) +# wine publisher + worker under Wine: tree dump and event scenario +# native native Linux Chromium reference: tree dump and event scenario +# PREFIX Wine prefix with Electron installed (worker and wine modes) +# Environment: +# WINE_ACCESS_BROWSER_TEST_ELECTRON Windows path of electron.exe in PREFIX +# (default C:\electron\v45\electron.exe) +# WINE_ACCESS_BROWSER_TEST_CHROMIUM native Chromium command (default chromium) +# WINE_ACCESS_BROWSER_TRACE=1 log every worker message (wine mode) +# Writes OUTPUT_DIR/.tree.txt, .events.txt, .txt and logs. +set -u + +if [[ $# -lt 3 ]]; then + echo "Usage: $0 worker|wine|native BUILD_DIR OUTPUT_DIR [PREFIX]" + exit 2 +fi + +sessionMode="$1" +buildDir="$(realpath "$2")" +outputDir="$(realpath -m "$3")" +winePrefix="${4:-}" +testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +electron="${WINE_ACCESS_BROWSER_TEST_ELECTRON:-C:\\electron\\v45\\electron.exe}" +chromiumCommand="${WINE_ACCESS_BROWSER_TEST_CHROMIUM:-chromium}" +case "$sessionMode" in + worker | wine | helper) + if [[ -z "$winePrefix" || ! -d "$winePrefix/drive_c" ]]; then + echo "$sessionMode mode needs a Wine prefix with Electron installed" + exit 2 + fi + ;; + native) ;; + *) + echo "Unknown mode: $sessionMode" + exit 2 + ;; +esac +mkdir -p "$outputDir" +workDir="$(mktemp -d)" +# Chromium's helper processes can still be writing the profile at exit. +trap 'rm -rf "$workDir" 2> /dev/null || { sleep 2; rm -rf "$workDir"; }' EXIT + +# The fixture app lives in the prefix so Electron can load it by Windows path. +appWindowsPath='C:\wine-access-browser-test' +if [[ -n "$winePrefix" ]]; then + mkdir -p "$winePrefix/drive_c/wine-access-browser-test" + cp "$testDir/fixture-app/"* "$winePrefix/drive_c/wine-access-browser-test/" + export WINEPREFIX="$winePrefix" +fi +export WINEDEBUG=-all +# Keep test Wine processes away from a live reader's Wine manager (Cthulhu and +# the Orca extension each skip processes carrying their own marker). +export CTHULHU_WINE_ACCESS_MANAGED=1 ORCA_WINE_ACCESS_MANAGED=1 +export sessionMode buildDir outputDir testDir electron chromiumCommand appWindowsPath workDir + +# shellcheck disable=SC2016 # expanded by the inner shell +timeout 300 "$testDir/private_session.sh" xvfb-run -a bash -c ' + title="Wine Access Electron Test" + worker="$buildDir/wine-access-browser-worker.exe" + if [[ "$sessionMode" == native ]]; then + "$chromiumCommand" --user-data-dir="$workDir/profile" --no-first-run --no-default-browser-check \ + --force-renderer-accessibility "file://$testDir/fixture-app/fixture.html" > "$workDir/browser.log" 2>&1 & + browserPid=$! + appName=chromium + else + wine "$electron" "$appWindowsPath" > "$workDir/browser.log" 2>&1 & + browserPid=$! + appName=electron + fi + if [[ "$sessionMode" == helper ]]; then + python3 -I "$testDir/helper_integration.py" "$buildDir" > "$outputDir/helper.txt" 2>&1 + status=$? + elif [[ "$sessionMode" == worker ]]; then + cd "$workDir" || exit 1 + python3 -I "$testDir/worker_driver.py" wine "$worker" --title "$title" > "$outputDir/worker.txt" 2>&1 + status=$? + cp "$workDir/worker.stderr.log" "$outputDir/worker.stderr.log" 2> /dev/null + else + if [[ "$sessionMode" == wine ]]; then + WINE_ACCESS_BROWSER_TRACE="${WINE_ACCESS_BROWSER_TRACE:-}" \ + "$buildDir/wine-access-browser-publisher" --worker wine "$worker" --title "$title" \ + > "$outputDir/wine.publisher.log" 2>&1 & + publisherPid=$! + fi + python3 -I "$testDir/atspi_dump.py" --app-name "$appName" --boundaries --wait 60 \ + > "$outputDir/$sessionMode.tree.txt" 2>&1 + python3 -I "$testDir/live_driver.py" --app-name "$appName" --title "$title" \ + --log "$outputDir/$sessionMode.events.txt" > "$outputDir/$sessionMode.txt" 2>&1 + status=$? + [[ -n "${publisherPid:-}" ]] && kill "$publisherPid" 2> /dev/null + fi + kill "$browserPid" 2> /dev/null + wait "$browserPid" 2> /dev/null + [[ "$sessionMode" != native ]] && wineserver -k 2> /dev/null + exit "$status" +' > /dev/null 2>&1 +sessionStatus=$? +[[ "$sessionMode" != native ]] && wineserver -k 2> /dev/null +echo "Live session $sessionMode exit status $sessionStatus; results in $outputDir" +exit "$sessionStatus" diff --git a/tests/browser/private_session.sh b/tests/browser/private_session.sh new file mode 100755 index 0000000..5cb0e20 --- /dev/null +++ b/tests/browser/private_session.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Run a command in a private D-Bus session whose accessibility bus lives in a +# private runtime directory, so tests can never touch the user's live +# accessibility bus. Refuses to run the command if isolation cannot be proven. +# Usage: private_session.sh COMMAND... +# +# Background: at-spi-bus-launcher puts its socket at +# $XDG_RUNTIME_DIR/at-spi/bus_, and advertises it in the AT_SPI_BUS +# property of its display's root window, which libatspi checks first. A +# launcher that sees the user's XDG_RUNTIME_DIR takes over the user's socket +# path and deletes it on exit; one that sees DISPLAY=:0 pulls the user's newly +# connecting applications onto the test bus. So the private D-Bus session gets +# a private runtime directory and no display at all; commands that need a +# display start their own (xvfb-run) inside it. +set -u + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 COMMAND..." + exit 2 +fi + +userDisplay="${DISPLAY:-}" +privateRuntime="$(mktemp -d)" +chmod 700 "$privateRuntime" +trap 'rm -rf "$privateRuntime"' EXIT +export XDG_RUNTIME_DIR="$privateRuntime" +unset AT_SPI_BUS_ADDRESS DISPLAY WAYLAND_DISPLAY +export userDisplay + +# shellcheck disable=SC2016 # expanded by the inner shell +dbus-run-session -- bash -c ' + busAddress="$(gdbus call --session --dest org.a11y.Bus --object-path /org/a11y/bus \ + --method org.a11y.Bus.GetAddress 2> /dev/null)" + case "$busAddress" in + *"unix:path=$XDG_RUNTIME_DIR/"*) ;; + *) + echo "Refusing to run: the accessibility bus is not private ($busAddress)" >&2 + exit 90 + ;; + esac + # Tripwire while the launcher is running (it removes the property on exit): + # the user display must never advertise the test bus. + if [[ -n "$userDisplay" ]] && DISPLAY="$userDisplay" xprop -root AT_SPI_BUS 2> /dev/null | + grep -q "$XDG_RUNTIME_DIR"; then + echo "Refusing to run: the user display advertises the test accessibility bus" >&2 + exit 91 + fi + gdbus call --session --dest org.a11y.Bus --object-path /org/a11y/bus \ + --method org.freedesktop.DBus.Properties.Set org.a11y.Status IsEnabled "" > /dev/null + "$@" +' private_session_inner "$@" +sessionStatus=$? +exit "$sessionStatus" diff --git a/tests/browser/publisher_snapshot_test.sh b/tests/browser/publisher_snapshot_test.sh new file mode 100755 index 0000000..484d446 --- /dev/null +++ b/tests/browser/publisher_snapshot_test.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# CTest: publish the recorded Electron 45 snapshot with the browser publisher +# on a private accessibility bus, and compare what readers would see with +# native Linux Chromium: the document with text boundaries against Chromium +# 158, and the whole application against Electron 42. No Wine is needed. +# Usage: publisher_snapshot_test.sh PUBLISHER +set -u + +if [[ $# -ne 1 || ! -x "$1" ]]; then + echo "Usage: $0 PUBLISHER" + exit 2 +fi + +publisher="$1" +testDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +dataDir="$testDir/data" +workDir="$(mktemp -d)" +trap 'rm -rf "$workDir"' EXIT +export publisher testDir dataDir workDir + +# shellcheck disable=SC2016 # expanded by the inner shell +timeout 180 "$testDir/private_session.sh" bash -c ' + "$publisher" "$dataDir/electron45-snapshot.json" --active > "$workDir/publisher.log" 2>&1 & + publisherPid=$! + python3 -I "$testDir/atspi_dump.py" --app-name electron --boundaries > "$workDir/document.txt" 2>&1 + python3 -I "$testDir/atspi_dump.py" --app-name electron --whole-app > "$workDir/application.txt" 2>&1 + kill "$publisherPid" 2> /dev/null + wait "$publisherPid" 2> /dev/null + exit 0 +' 2> "$workDir/session.log" +sessionStatus=$? +if [[ "$sessionStatus" -ne 0 ]]; then + echo "FAIL: private session (status $sessionStatus)" + cat "$workDir/session.log" + exit 1 +fi + +failures=0 +if python3 -I "$testDir/compare_dumps.py" "$dataDir/native-chromium158-document.txt" "$workDir/document.txt" \ + > "$workDir/document.diff"; then + echo "PASS: document and text boundaries match native Chromium 158" +else + echo "FAIL: document differs from native Chromium 158" + tail -n 40 "$workDir/document.diff" + failures=$((failures + 1)) +fi +if python3 -I "$testDir/compare_dumps.py" "$dataDir/native-electron42-application.txt" "$workDir/application.txt" \ + --baseline electron42 > "$workDir/application.diff"; then + echo "PASS: application matches native Electron 42" +else + echo "FAIL: application differs from native Electron 42" + tail -n 40 "$workDir/application.diff" + failures=$((failures + 1)) +fi +if grep -q -E 'WARNING|CRITICAL' "$workDir/publisher.log"; then + echo "FAIL: publisher warnings" + grep -E 'WARNING|CRITICAL' "$workDir/publisher.log" | head -n 10 + failures=$((failures + 1)) +else + echo "PASS: no publisher warnings" +fi +[[ "$failures" -eq 0 ]] diff --git a/tests/browser/worker_driver.py b/tests/browser/worker_driver.py new file mode 100755 index 0000000..7eed1e4 --- /dev/null +++ b/tests/browser/worker_driver.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python3 +"""Drive ia2_worker.exe against the Electron fixture and check its protocol. + +Run inside the same X display and wineserver as Electron (worker_session.sh +does this). Prints PASS/FAIL lines and exits non-zero on any failure. +""" + +import json +import queue +import subprocess +import sys +import threading +import time + +TITLE = "Wine Access Electron Test" +SECRET = "Zq7secret" # typed into the password field; must never appear in output + +failures = 0 +allLines = [] + + +def check(name, condition, detail=""): + global failures + if condition: + print(f"PASS: {name}", flush=True) + else: + failures += 1 + print(f"FAIL: {name} {detail}", flush=True) + + +class Worker: + def __init__(self, command): + self.process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, + stderr=open("worker.stderr.log", "wb")) + self.messages = queue.Queue() + self.nextRequestId = 1 + threading.Thread(target=self._read, daemon=True).start() + + def _read(self): + for raw in self.process.stdout: + allLines.append(raw) + try: + self.messages.put(json.loads(raw)) + except json.JSONDecodeError: + self.messages.put({"type": "invalid-json", "raw": raw[:200]}) + self.messages.put({"type": "eof"}) + + def receive(self, seconds): + """All messages that arrive within the time limit.""" + deadline = time.monotonic() + seconds + received = [] + while time.monotonic() < deadline: + try: + received.append(self.messages.get(timeout=max(0.01, deadline - time.monotonic()))) + except queue.Empty: + break + return received + + def wait_for(self, predicate, seconds): + deadline = time.monotonic() + seconds + seen = [] + while time.monotonic() < deadline: + try: + message = self.messages.get(timeout=max(0.01, deadline - time.monotonic())) + except queue.Empty: + break + seen.append(message) + if predicate(message): + return message, seen + return None, seen + + def request(self, op, **fields): + requestId = self.nextRequestId + self.nextRequestId += 1 + message = {"type": "request", "requestId": requestId, "op": op, **fields} + self.process.stdin.write((json.dumps(message, separators=(",", ":")) + "\n").encode()) + self.process.stdin.flush() + reply, seen = self.wait_for(lambda m: m.get("type") == "reply" and m.get("requestId") == requestId, 10) + return reply, seen + + +def walk(node): + yield node + for child in node.get("children", []): + yield from walk(child) + + +def find(root, predicate): + return next((node for node in walk(root) if predicate(node)), None) + + +def xdotool(*arguments): + subprocess.run(["xdotool", *arguments], check=False, capture_output=True) + + +def main(): + worker = Worker(sys.argv[1:]) + hello, _ = worker.wait_for(lambda m: m.get("type") == "hello", 40) + check("hello received", hello is not None and hello.get("protocol") == 1, str(hello)) + check("hello reports an X11 window", bool(hello and hello.get("x11Window")), str(hello)) + tree, _ = worker.wait_for(lambda m: m.get("type") == "tree", 40) + check("tree received", tree is not None) + if tree is None: + return 1 + root = tree["root"] + nodeCount = sum(1 for _ in walk(root)) + check("tree has web content", nodeCount > 60, f"nodes={nodeCount}") + ids = [node.get("id") for node in walk(root)] + check("uniqueIDs are unique and non-zero", len(ids) == len(set(ids)) and 0 not in ids) + + userName = find(root, lambda n: n.get("msaaRole") == 42 and n.get("name") == "User name") + password = find(root, lambda n: n.get("msaaRole") == 42 and n.get("name") == "Password") + checkbox = find(root, lambda n: n.get("msaaRole") == 44) + addButton = find(root, lambda n: n.get("msaaRole") == 43 and n.get("name") == "Add item") + table = find(root, lambda n: n.get("msaaRole") == 24) + emoji = find(root, lambda n: "Emoji" in (n.get("text") or "") and n.get("hyperlinks")) + check("fixture objects found", all([userName, password, checkbox, addButton, table, emoji])) + check("password node carries no text or value", password is not None and "text" not in password + and "value" not in password) + + reply, _ = worker.request("boundary", id=emoji["id"], offset=0, granularity=1) + check("word boundary at 0 is 0-6", reply and reply["ok"] and (reply["start"], reply["end"]) == (0, 6), str(reply)) + reply, _ = worker.request("boundary", id=password["id"], offset=0, granularity=1) + check("boundary on password is refused", reply and not reply["ok"], str(reply)) + reply, _ = worker.request("extents", id=table["id"]) + check("table extents returned", reply and reply["ok"] and len(reply["extents"]) == 4, str(reply)) + reply, _ = worker.request("extents", id=123456789) + check("unknown id reports gone", reply and not reply["ok"] and reply.get("gone"), str(reply)) + + reply, seen = worker.request("focus", id=userName["id"]) + check("focus request succeeds", reply and reply["ok"], str(reply)) + focus, more = worker.wait_for(lambda m: m.get("type") == "focus" and m.get("id") == userName["id"], 5) + check("focus message names the input", focus and focus["id"] == userName["id"], str(focus)) + + xdotool("search", "--name", TITLE, "windowactivate", "--sync") + xdotool("search", "--name", TITLE, "windowfocus", "--sync") + xdotool("type", "--delay", "80", "abc") + _, seen = worker.wait_for(lambda m: m.get("type") == "node" and m["node"].get("id") == userName["id"] + and m["node"].get("text") == "abc", 8) + typed = [m for m in seen if m.get("type") == "node" and m["node"].get("id") == userName["id"]] + check("typing produced node updates ending in 'abc'", typed and typed[-1]["node"].get("text") == "abc", + str([m["node"].get("text") for m in typed])) + carets = [m for m in seen if m.get("type") == "caret" and m.get("id") == userName["id"]] + extra = worker.receive(0.5) + carets += [m for m in extra if m.get("type") == "caret" and m.get("id") == userName["id"]] + check("caret messages end at 3", carets and carets[-1]["caret"] == 3, str(carets[-3:])) + + reply, seen = worker.request("setCaret", id=userName["id"], offset=1) + caret, _ = worker.wait_for(lambda m: m.get("type") == "caret" and m.get("id") == userName["id"], 3) + check("setCaret moves the caret to 1", reply and reply["ok"] and caret and caret["caret"] == 1, str(caret)) + reply, _ = worker.request("setSelection", id=userName["id"], start=0, end=2) + selection, _ = worker.wait_for(lambda m: m.get("type") in ("caret", "selection") and m.get("id") == userName["id"] + and m.get("selection") == [0, 2], 3) + check("setSelection selects 0-2", reply and reply["ok"] and selection is not None, str(reply)) + + reply, _ = worker.request("action", id=checkbox["id"], index=0) + update, _ = worker.wait_for(lambda m: m.get("type") == "node" and m["node"].get("id") == checkbox["id"] + and m["node"]["msaaStates"] & 0x10, 5) + check("checkbox action checks it", reply and reply["ok"] and update is not None, str(reply)) + + reply, _ = worker.request("action", id=addButton["id"], index=0) + _, seen = worker.wait_for(lambda m: m.get("type") == "subtree" and any( + (n.get("name") or "").startswith("Item 2") for n in walk(m["node"])), 5) + check("add item produces a subtree containing the new item", + any(m.get("type") == "subtree" and any((n.get("name") or "").startswith("Item 2") for n in walk(m["node"])) + for m in seen), str([m.get("type") for m in seen])) + + reply, _ = worker.request("scrollTo", id=table["id"], scrollType=2) + layout, _ = worker.wait_for(lambda m: m.get("type") == "layout", 3) + check("scrollTo produces a layout message", reply and reply["ok"] and layout is not None, str(reply)) + + reply, _ = worker.request("focus", id=password["id"]) + worker.wait_for(lambda m: m.get("type") == "focus" and m.get("id") == password["id"], 5) + xdotool("type", "--delay", "80", SECRET) + seen = worker.receive(3) + passwordUpdates = [m for m in seen if m.get("type") == "node" and m["node"].get("id") == password["id"]] + check("typing into the password produces updates", len(passwordUpdates) > 0, str(len(passwordUpdates))) + check("password updates report length only", passwordUpdates and all( + "text" not in m["node"] and "value" not in m["node"] for m in passwordUpdates)) + check("password length tracks typing", passwordUpdates and passwordUpdates[-1]["node"].get("textLength") + == len(SECRET), str(passwordUpdates[-1]["node"].get("textLength") if passwordUpdates else None)) + + worker.process.stdin.close() + try: + worker.process.wait(timeout=10) + check("worker exits when its input closes", True) + except subprocess.TimeoutExpired: + worker.process.kill() + check("worker exits when its input closes", False) + leaked = [line for line in allLines if SECRET.encode() in line] + check("secret never appears in worker output", not leaked, f"{len(leaked)} lines") + invalid = [line for line in allLines if not line.strip().startswith(b"{")] + check("every output line is a JSON object", not invalid, str(invalid[:2])) + with open("worker.stderr.log", "rb") as stderrFile: + check("secret never appears in worker diagnostics", SECRET.encode() not in stderrFile.read()) + print(f"messages={len(allLines)}") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/third_party/ia2/Accessible2.idl b/third_party/ia2/Accessible2.idl new file mode 100644 index 0000000..60566e2 --- /dev/null +++ b/third_party/ia2/Accessible2.idl @@ -0,0 +1,696 @@ +/************************************************************************* + * + * File Name (Accessible2.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +/** @mainpage + + @section _interfaces Interfaces + IAccessible2\n + IAccessible2_2\n + IAccessible2_3 [Deprecated]\n + IAccessibleAction\n + IAccessibleApplication\n + IAccessibleComponent\n + IAccessibleDocument\n + IAccessibleEditableText\n + IAccessibleHypertext\n + IAccessibleHypertext2\n + IAccessibleHyperlink\n + IAccessibleImage\n + IAccessibleRelation\n + IAccessibleTable [Deprecated]\n + IAccessibleTable2\n + IAccessibleTableCell\n + IAccessibleText\n + IAccessibleText2\n + IAccessibleTextSelectionContainer\n + IAccessibleValue + + @section _structs Structs + IA2Locale\n + IA2Range\n + IA2TableModelChange\n + IA2TextSegment\n + IA2TextSelection + + @section _enums Enums + ::IA2Actions values are predefined actions for use when implementing support for HTML5 media.\n + ::IA2CoordinateType values define the requested coordinate type (screen or parent window).\n + ::IA2EventID values identify events.\n + ::IA2Role values defines roles which are in addition to the existing MSAA roles.\n + ::IA2ScrollType values define where to place an object or substring on the screen.\n + ::IA2States values define states which are in addition to the existing MSAA states.\n + ::IA2TableModelChangeType values describe the kinds of changes made to a table (insert, delete, update).\n + ::IA2TextBoundaryType values define the requested text unit (character, word, sentence, line, paragraph).\n + ::IA2TextSpecialOffsets values define special offsets for use in the text interfaces. + + @section _constants Constants + @ref grpRelations + + @section _misc Miscellaneous + @ref _licensePage "BSD License"\n + @ref _generalInfo "General Information"\n + + @page _licensePage BSD License + %IAccessible2 IDL Specification + + Copyright (c) 2007, 2013 Linux Foundation\n + Copyright (c) 2006 IBM Corporation\n + Copyright (c) 2000, 2006 Sun Microsystems, Inc.\n + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + + 3. Neither the name of the Linux Foundation nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This BSD License conforms to the Open Source Initiative "Simplified + BSD License" as published at: + http://www.opensource.org/licenses/bsd-license.php + + %IAccessible2 is a trademark of the Linux Foundation. The %IAccessible2 + mark may be used in accordance with the + + Linux Foundation Trademark Policy to indicate compliance with the %IAccessible2 specification. + + @page _generalInfo General Information + The following information is applicable to two or more interfaces. + + @ref _errors\n + @ref _memory\n +   @ref _arrayConsideration\n + @ref _indexes\n + @ref _enums\n + @ref _specialOffsets\n + @ref _dicoveringInterfaces\n + @ref _changingInterfaces\n + @ref _applicationInfo\n + @ref _childIDs\n + @ref _variants\n + @ref _iaaction-iahyperlink\n + @ref _trademark + + @section _errors Error Handling + HRESULT values are defined by the Microsoft® Win32® API. For more information, refer to + + Interpreting HRESULT Values in MSDN®. + + Note that the S_FALSE return value is considered a non-error value and the + SUCCEEDED macro will return TRUE. S_FALSE is used when there is no failure + but there was nothing valid to return, e.g. in IAccessible2::attributes when + there are no attributes. When S_FALSE is returned [out] pointer types should + be NULL and [out] longs should generally be 0, but sometimes -1 is used such + as IAccessible2::indexInParent, IAccessibleText::caretOffset, and + IAccessibleHypertext::hyperlinkIndex. + + Note that for BSTR [out] variables common COM practice is that the server does + the SysAllocString and the client does the SysFreeString. Also note that when + NULL is returned there is no need for the client to call SysFreeString. Please + refer to the documentation for each method for more details regarding error handling. + + @section _memory Memory Management + The following memory management issues should be considered: + @li Although [out] BSTR variables are declared by the client, their space is + allocated by the server. They need to be freed with SysFreeString by the + client at end of life; the same is true when BSTRs are used in structs or + arrays which are passed to the server. + @li If there is no valid [out] BSTR to return, the server should return S_FALSE and + assign NULL to the output, e.g. *theOutBSTR = NULL;. + @li COM interfaces need to be referenced with AddRef when used and dereferenced + with Release at end of life. + @li Single [out] longs, HWNDs, booleans, and structs are declared by the caller + and passed by reference. The marshaller does all the memory management. + + The following articles may be helpful for understanding memory management issues: + @li An article by Don Box in a + Q & A section + of the November 1996 edition of the Microsoft Systems Journal. + @li A posting to a CodeGuru forum, + Windows SDK + String: What are the rules for BSTR allocation and deallocation? + + @subsection _arrayConsideration Special Consideration when using Arrays + There are several methods which return arrays. In the case of IAccessible2::relations + and IAccessibleRelation::targets the client must allocate and free the arrays. + + For the remaining methods which return arrays, the server must allocate the array + and the client must free the array when no longer needed. These methods are + IAccessible2::extendedStates, IAccessible2::localizedExtendedStates, + IAccessible2_2::relationTargetsOfType, IAccessibleAction::keyBinding, + IAccessibleHypertext2::hyperlinks, IAccessibleTable::selectedChildren, + IAccessibleTable::selectedColumns, IAccessibleTable::selectedRows, + IAccessibleTable2::selectedCells, IAccessibleTable2::selectedColumns, + IAccessibleTable2::selectedRows, IAccessibleTableCell::columnHeaderCells, + and IAccessibleTableCell::rowHeaderCells. + For those methods, the server must allocate both the top level array and any storage + associated with it, e.g. for BSTRs. The server must allocate the arrays with + CoTaskMemAlloc and any BSTRs with SysAllocString. The client must use CoTaskMemFree + to free the array and any BSTRs must be freed with SysFreeString. + + Also, the IDL for IAccessible2::extendedStates, IAccessible2::localizedExtendedStates, + IAccessibleAction::keyBinding, IAccessibleTable::selectedChildren, + IAccessibleTable::selectedColumns, and IAccessibleTable::selectedRows includes an + extraneous [in] parameter for the caller to specify the max size of the array. + This parameter will be ignored by the COM server. + + @section _indexes Zero and One Based Indexes + Unless otherwise specified all offsets and indexes are 0 based. + + @section _enums Enums + Note that enums start at 0. + + @section _specialOffsets Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods + IAccessibleText and IAccessibleEditableText can use one or more of the following + special offset values. They are defined in the ::IA2TextSpecialOffsets enum. + @li Using ::IA2_TEXT_OFFSET_LENGTH (-1) as an offset in any of the IAccessibleText or + IAccessibleEditableText methods is the same as specifying the length of the string. + @li Using ::IA2_TEXT_OFFSET_CARET (-2) as an offset for IAccessibleText::textBeforeOffset, + IAccessibleText::textAtOffset, and IAccessibleText::textAfterOffset indicates that the + text related to the physical location of the caret should be used. This is needed for + applications that consider the character offset of the end of one line (as reached by + pressing the End key) the same as the offset of the first character on the next line. + Since the same offset is associated with two different lines a special means is needed + to fetch text from the line where the caret is physically located. + + @section _dicoveringInterfaces Discovery of Interfaces + In general AT (Assistive Technology) should try IAccessible2 interfaces, followed by using + the MSAA (Microsoft® Active Accessibility®) interfaces. (In cases where the an application + is known to have custom interfaces which provide information not supplied by IAccessible2 + or MSAA, then those custom interfaces can be used.) The AT can then, by default, support + unknown IAccessible2/MSAA applications, without the application developers having to request + AT vendors for support on an individual application by application basis. + + When you have a reference to an IAccessible and require a reference to an IAccessible2 use + QueryService as follows: + @code + // pAcc is a reference to the accessible object's IAccessible interface. + IServiceProvider *pService = NULL; + hr = pAcc->QueryInterface(IID_IServiceProvider, (void **)&pService); + if(SUCCEEDED(hr)) { + IAccessible2 *pIA2 = NULL; + hr = pService->QueryService(IID_IAccessible, IID_IAccessible2, (void**)&pIA2); + if (SUCCEEDED(hr) && pIA2) { + // The control supports IAccessible2. + // pIA2 is the reference to the accessible object's IAccessible2 interface. + } + } + @endcode + + @section _changingInterfaces Changing between Accessible Interfaces + Note that developers must always implement MSAA's IAccessible and, if needed, some + of the interfaces in the set of IAccessible2 interfaces. Although the IAccessible2 + IDL is coded such that IAccessible2 is a subclass of MSAA's IAccessible, none of + MSAA's IAccessible methods are redefined by IAccessible2. + + QueryService must be used to switch from a reference to an MSAA IAccessible interface + to another interface. This has been + + documented and the pertinent facts have been extracted below: + + @par + Why use QueryService instead of just using QueryInterface to get IAccessibleEx + directly? The reason is that since MSAA 2.0, clients don't talk to a server's + IAccessible interface directly; instead they talk to an intermediate MSAA-provided + wrapper that calls through to the original IAccessible. This wrapper provides services + such as implementing IDispatch, supplying information from MSAA 2.0's Dynamic Annotation + service, and scaling locations when running on Windows Vista with DPI scaling enabled. + QueryService is the supported way to expose additional interfaces from an existing + IAccessible and was originally used by MSHTML to expose IHTMLElement objects corresponding + to IAccessibles. QueryService is often more convenient for servers to implement than + QueryInterface because it does not have the same requirements for preserving object + identity or symmetry/transitivity as QueryInterface, so QueryService allows servers to + easily implement the interface on the same object or a separate object. The latter is + often hard to do with QueryInterface unless the original object supports aggregation. + + Two related references in MSDN® are: + @li + "Using QueryService to expose a native object model interface for an IAccessible object" + @li + "Accessing the Internet Explorer Object Associated with an Accessible Object" + + Based on this information from Microsoft, QueryService must be used to switch back and forth + between a reference to an MSAA IAccessible interface and any of the IAccessible2 interfaces. + + Regarding switching between any of the IAccessible2 interfaces, applications implementing + IAccessible2 should implement the IAccessible2 interfaces on a single object since ATs + will be using QueryInterface to switch between the IAccessilbe2 interfaces. Implementing + the IAccessible2 interfaces on separate objects would require the use of QueryService. + There is one exception, IAccessibleApplication can be implemented on a separate object so + its common code doesn't have to be included in each accessible object. ATs should use + QueryService to access IAccessibleApplication. + + @section _applicationInfo Access to Information about the Application + Servers implementing IAccessible2 should provide access to the IAccessibleApplication + interface via QueryService from any object so that ATs can easily determine specific + information about the application such as its name or version. + + @section _childIDs Child IDs + The IAccessible2 interfaces do not support child IDs, i.e. simple child elements. + Full accessible objects must be created for each object that supports IAccessible2. + Therefore MSAA's get_accChild should never return a child ID (other than CHILDID_SELF) + for an object that implements any of the IAccessible2 interfaces. + + Microsoft's UI Automation specification has the same limitation and this was resolved + in the UI Automation Express specification by adding IAccessibleEx::GetObjectForChild + and IAccessibleEx::GetIAccessiblePair. These methods allow mapping back and forth + between an IAccessibleEx and an {IAccessible, Child ID} pair. A future version of + IAccessible2 may include similar methods to map back and forth between an IAccessible2 + and an {IAccessible, Child ID} pair. + + @section _variants VARIANTs + Some methods return a VARIANT. Implementers need to make sure that the return type is + specified, i.e. VT_I4, VT_IDISPATCH, etc. The methods that return VARIANTs are + IAccessibleHyperlink::anchor, IAccessibleHyperlink::anchorTarget, IAccessibleValue::currentValue, + IAccessibleValue::maximumValue, IAccessibleValue::minimumValue. + + @section _iaaction-iahyperlink IAccessibleHyperlink as subclass of IAccessibleAction + In this version of the IDL, IAccessibleHyperlink is a subclass of IAccessibleAction. + However, there is no practical need for that inheritance and in some cases, such as + an image map of smart tags, it doesn't make sense because such an image map doesn't + have actionable objects; it's the secondary smart tags that are actionable. As a + result, implementations should not rely on the inheritance as it may be removed in + a later version of the IDL. + + @section _trademark Trademark Attribution + The names of actual companies and products mentioned herein may be the trademarks of + their respective owners. In particular, Active Accessibility, Microsoft, MSDN, and Win32 + are trademarks of the Microsoft group of companies in the U.S.A. and/or other countries. + +**/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "AccessibleRelation.idl"; +import "AccessibleStates.idl"; +import "IA2CommonTypes.idl"; + +/** A structure defining the locale of an accessible object. + +IAccessible2::locale returns this struct. +*/ +typedef struct IA2Locale { + BSTR language; ///< ISO 639-1 Alpha-2 two character language code + BSTR country; ///< ISO 3166-1 Alpha-2 two character country code + BSTR variant; ///< Application specific variant of the locale +} IA2Locale; + +/** @brief This interface exposes the primary set of information about an + IAccessible2 enabled accessible object. + + This interface must always be provided for objects that support some + portion of the collection of the %IAccessible2 interfaces. + + Please refer to @ref _changingInterfaces "Changing between Accessible Interfaces" + for special considerations related to use of the MSAA IAccessible interface and + the set of %IAccessible2 interfaces. + */ +[object, uuid(E89F726E-C4F4-4c19-BB19-B647D7FA8478)] +interface IAccessible2 : IAccessible +{ + + /** @brief Returns the number of accessible relations for this object. + @param [out] nRelations + @retval S_OK + */ + [propget] HRESULT nRelations + ( + [out, retval] long *nRelations + ); + + /** @brief Returns one accessible relation for this object. + @param [in] relationIndex + 0 based + @param [out] relation + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT relation + ( + [in] long relationIndex, + [out, retval] IAccessibleRelation **relation + ); + + /** @brief Returns multiple accessible relations for this object. + @param [in] maxRelations + maximum size of the array allocated by the client + @param [out] relations + The array of accessible relation objects. Note that this array is to be + allocated by the client and freed when no longer needed. Refer to @ref + _arrayConsideration "Special Consideration when using Arrays" for more details. + @param [out] nRelations + actual number of relations in the returned array (not more than maxRelations) + @retval S_OK + @retval S_FALSE if there are no relations, nRelations is set to 0 + @note As a performant alternative, client code should consider using IAccessible2_2::relationTargetsOfType. + */ + [propget] HRESULT relations + ( + [in] long maxRelations, + [out, size_is(maxRelations), length_is(*nRelations)] + IAccessibleRelation **relations, + [out, retval] long *nRelations + ); + + /** @brief Returns the role of an %IAccessible2 object. + @param [out] role + The role of an %IAccessible2 object. + @retval S_OK + @note + @li For convenience MSAA roles are also passed through this method so the + AT doesn't have to also fetch roles through MSAA's get_accRole. + @li %IAccessible2 roles should not be passed through MSAA's get_accRole. + @li For compatibility with non IAccessible2 enabled ATs, IAccessible2 + applications should also add support to get_accRole to return the closest + MSAA role or ROLE_SYSTEM_CLIENT (the MSAA defined default role) if there + is not a good match. + @li This method is missing a [propget] prefix in the IDL. The result is the + method is named role in generated C++ code instead of get_role. + */ + HRESULT role + ( + [out, retval] long *role + ); + + /** @brief Makes an object visible on the screen. + @param [in] scrollType + Defines where the object should be placed on the screen. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT scrollTo + ( + [in] enum IA2ScrollType scrollType + ); + + /** @brief Moves the top left of an object to a specified location. + + @param [in] coordinateType + Specifies whether the coordinates are relative to the screen or the parent object. + @param [in] x + Defines the x coordinate. + @param [in] y + Defines the y coordinate. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT scrollToPoint + ( + [in] enum IA2CoordinateType coordinateType, + [in] long x, + [in] long y + ); + + /** @brief Returns grouping information. + + Used for tree items, list items, tab panel labels, radio buttons, etc. + Also used for collections of non-text objects. + + @param [out] groupLevel + 1 based, 0 indicates that this value is not applicable + @param [out] similarItemsInGroup + 1 based, 0 indicates that this value is not applicable + @param [out] positionInGroup + 1 based, 0 indicates that this value is not applicable. This is an index + into the objects in the current group, not an index into all the objects + at the same group level. + @retval S_OK if at least one value is valid + @retval S_FALSE if no values are valid, [out] values are 0s + @note This method is meant to describe the nature of an object's containment + structure. It's exposed by trees, tree grids, nested lists, nested menus, + but not headings, which uses the level object attribute. It is also exposed + by radio buttons (with groupLevel == 0). + @note This is normally not implemented on a combo box to describe the nature + of its contents. Normally an AT will get that information from its child list + object. However, in some cases when non-edit combo boxes are not able to be structured + such that the list is a child of the combo box, this method is implemented on + the combo box itself. ATs can use this interface if a child list is not found. + */ + [propget] HRESULT groupPosition + ( + [out] long *groupLevel, + [out] long *similarItemsInGroup, + [out, retval] long *positionInGroup + ); + + /** @brief Returns the bit strip containing any IAccessible2 states. + + The IAccessible2 states are in addition to the MSAA states and are defined in + the IA2States enum. + + @param [out] states + @retval S_OK + */ + [propget] HRESULT states + ( + [out, retval] AccessibleStates *states + ); + + /** @brief Returns the extended role. + + An extended role is a role which is dynamically generated by the application. + It is not predefined by the %IAccessible2 specification. + + @param [out] extendedRole + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT extendedRole + ( + [out, retval] BSTR *extendedRole + ); + + /** @brief Returns the localized extended role. + @param [out] localizedExtendedRole + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT localizedExtendedRole + ( + [out, retval] BSTR *localizedExtendedRole + ); + + /** @brief Returns the number of extended states. + @param [out] nExtendedStates + @retval S_OK + */ + [propget] HRESULT nExtendedStates + ( + [out, retval] long *nExtendedStates + ); + + /** @brief Returns the extended states (array of strings). + + An extended state is a state which is dynamically generated by the application. + It is not predefined by the %IAccessible2 specification. + + @param [in] maxExtendedStates + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] extendedStates + This array is allocated by the server. The client must free it with CoTaskMemFree. + @param [out] nExtendedStates + The number of extended states returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are no states, [out] values are NULL and 0 respectively + */ + [propget] HRESULT extendedStates + ( + [in] long maxExtendedStates, + [out, size_is(,maxExtendedStates), length_is(,*nExtendedStates)] BSTR **extendedStates, + [out, retval] long *nExtendedStates + ); + + /** @brief Returns the localized extended states (array of strings). + + @param [in] maxLocalizedExtendedStates + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] localizedExtendedStates + This array is allocated by the server. The client must free it with CoTaskMemFree. + @param [out] nLocalizedExtendedStates + The number of localized extended states returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are no states, [out] values are NULL and 0 respectively + */ + [propget] HRESULT localizedExtendedStates + ( + [in] long maxLocalizedExtendedStates, + [out, size_is(,maxLocalizedExtendedStates), length_is(,*nLocalizedExtendedStates)] BSTR **localizedExtendedStates, + [out, retval] long *nLocalizedExtendedStates + ); + + /** @brief Returns the unique ID. + + The uniqueID is an identifier for this object, is unique within the + current window, and remains the same for the lifetime of the accessible + object. + + The uniqueID is not related to: + - the MSAA objectID which is used by the server to disambiguate between + IAccessibles per HWND or + - the MSAA childID which is used to disambiguate between children being + managed by an IAccessible. + + This value is provided so the AT can have access to a unique runtime persistent + identifier even when not handling an event for the object. + + An example of when this value is useful is if the AT wants to build a cache. + The AT could cache the uniqueIDs in addition to other data being cached. + When an event is fired the AT could map the uniqueID to its internal model. + Thus, if there's a REORDER/SHOW/HIDE event the AT knows which part of the + internal structure has been invalidated and can refetch just that part. + + This value can also be used by an AT to determine when the current control + has changed. If the role is the same for two controls that are adjacent in + the tab order, this can be used to detect the new control. + + Another use of this value by an AT is to identify when a grouping object has + changed, e.g. when moving from a radio button in one group to a radio button in a + different group. + + One means of implementing this would be to create a factory with a 32 bit number + generator and a reuse pool. The number generator would emit numbers starting + at 1. Each time an object's life cycle ended, its number would be saved into a + reuse pool. The number generator would be used whenever the reuse pool was empty. + + Another way to create a unique ID is to generate it from a pointer value, e.g. an + object's address. That would be unique because no two active objects can use the + same allocated memory space. + + @param [out] uniqueID + @retval S_OK + */ + [propget] HRESULT uniqueID + ( + [out, retval] long *uniqueID + ); + + /** @brief Returns the window handle for the parent window which contains this object. + + This is the same window handle which will be passed for any events that occur on the + object, but is cached in the accessible object for use when it would be helpful to + access the window handle in cases where an event isn't fired on this object. + + A use case is when a screen reader is grabbing an entire web page on a page load. + Without the availability of windowHandle, the AT would have to get the window handle + by using WindowFromAccessibleObject on each IAccessible, which is slow because it's + implemented by oleacc.dll as a loop which crawls up the ancestor chain and looks for + a ROLE_WINDOW object, mapping that back to a window handle. + + @param [out] windowHandle + @retval S_OK + */ + [propget] HRESULT windowHandle + ( + [out, retval] HWND *windowHandle + ); + + /** @brief Returns the index of this object in its parent object. + @param [out] indexInParent + 0 based; -1 indicates there is no parent; the upper bound is the value + returned by the parent's IAccessible::get_accChildCount. + @retval S_OK + @retval S_FALSE if no parent, [out] value is -1 + */ + [propget] HRESULT indexInParent + ( + [out, retval] long *indexInParent + ); + + /** @brief Returns the IA2Locale of the accessible object. + @param [out] locale + @retval S_OK + */ + [propget] HRESULT locale + ( + [out, retval] IA2Locale *locale + ); + + /** @brief Returns the attributes specific to this object, such as a cell's formula. + @param [out] attributes + @retval S_OK + @retval S_FALSE returned if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT attributes + ( + [out, retval] BSTR *attributes + ); + +} + diff --git a/third_party/ia2/Accessible2_2.idl b/third_party/ia2/Accessible2_2.idl new file mode 100644 index 0000000..3ce89c6 --- /dev/null +++ b/third_party/ia2/Accessible2_2.idl @@ -0,0 +1,123 @@ +/************************************************************************* + * + * File Name (Accessible2_2.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "Accessible2.idl"; + +/** @brief This interface exposes the primary set of information about an + IAccessible2 enabled accessible object. + + This interface must always be provided for objects that support some + portion of the collection of the %IAccessible2 interfaces. + + Please refer to @ref _changingInterfaces "Changing between Accessible Interfaces" + for special considerations related to use of the MSAA IAccessible interface and + the set of %IAccessible2 interfaces. + */ +[object, uuid(6C9430E9-299D-4E6F-BD01-A82A1E88D3FF)] +interface IAccessible2_2 : IAccessible2 +{ + /** @brief Returns the attribute value of a specified attribute specific to this object. + @param [in] name + @param [out] attribute + @retval S_OK + @retval S_FALSE returned if there is nothing to return, [out] value is NULL. + @retval E_INVALIDARG if bad [in] passed. + @note The output value is a VARIANT. Typically it will be a VT_BSTR, but there + are some cases where it will be a VT_I4 or VT_BOOL. Refer to the + Object Attributes specification for more information. + */ + [propget] HRESULT attribute + ( + [in] BSTR name, + [out, retval] VARIANT *attribute + ); + + /** @brief Returns the deepest hypertext accessible in the subtree of this object, and the caret offset within it. + @param [out] accessible + @param [out] caretOffset + @retval S_OK + @retval S_FALSE returned if there is no caret in any of the objects in the subtree, [out] accessible is NULL and [out] caretOffset is -1. + */ + [propget] HRESULT accessibleWithCaret + ( + [out] IUnknown **accessible, + [out, retval] long *caretOffset + ); + + /** @brief Returns relation targets for a specified target type. + @param [in] type + The requested @ref grpRelations "relation type". + @param [in] maxTargets + The number of targets requested. 0 indicates that all targets should be returned. + @param [out] targets + This array is allocated by the server. The client must free it with CoTaskMemFree. + @param [out] nTargets + The number of targets returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are no targets, [out] values are NULL and 0 respectively. + @retval E_INVALIDARG if bad [in] passed. + */ + [propget] HRESULT relationTargetsOfType + ( + [in] BSTR type, + [in] long maxTargets, + [out, size_is(,*nTargets)] IUnknown ***targets, + [out, retval] long *nTargets + ); + +} + diff --git a/third_party/ia2/Accessible2_3.idl b/third_party/ia2/Accessible2_3.idl new file mode 100644 index 0000000..f3a9b18 --- /dev/null +++ b/third_party/ia2/Accessible2_3.idl @@ -0,0 +1,50 @@ +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "Accessible2_2.idl"; + +/** + * This structure represents a directional range of the content. It is defined + * by two points in the content, where each one is defined by an accessible + * object and an offset relative to it. A typical case of a range point is + * a text accessible and text offset within it. + * + * The "anchor" is one point of the range and typically remains constant. + * The other point is the "active" point, which typically corresponds to + * the user's focus or point of interest. The user moves the active point to + * expand or collapse the range. In most cases, anchor is the start of the range + * and active is the end. However, in case of selection, when selecting + * backwards (e.g. pressing shift+left arrow in a text field), the start of + * the range is the active point, as the user moves this to manipulate + * the selection. + */ +typedef struct IA2Range { + IUnknown* anchor; + long anchorOffset; + IUnknown* active; + long activeOffset; +} IA2Range; + +/** + * @brief This interface is an extension of IAccessible2_2 and IAccessible2 + * interfaces. + */ +[object, uuid(5BE18059-762E-4E73-9476-ABA294FED411)] +interface IAccessible2_3 : IAccessible2_2 +{ + /** + * @brief Returns an array of ranges for selections within the accessible. + * @param [out] ranges + The array of selection ranges, allocated by the server. The client must + free it with CoTaskMemFree. + * @param [out] nRanges + the array length + * @retval S_OK + * @retval S_FALSE returned if there is no selection within the accessible + */ + [propget] HRESULT selectionRanges + ( + [out, size_is(,*nRanges)] IA2Range **ranges, + [out, retval] long *nRanges + ); +} diff --git a/third_party/ia2/AccessibleAction.idl b/third_party/ia2/AccessibleAction.idl new file mode 100644 index 0000000..7366f69 --- /dev/null +++ b/third_party/ia2/AccessibleAction.idl @@ -0,0 +1,220 @@ +/************************************************************************* + * + * File Name (AccessibleAction.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** This enum defines values which are predefined actions for use when implementing + support for media. + + This enum is used when specifying an action for IAccessibleAction::doAction. +*/ + +enum IA2Actions { + IA2_ACTION_OPEN = -1, /**< Used to inform the server that the client will + signal via IA2_ACTION_COMPLETE when it has consumed + the content provided by the object. This action + allows the object's server to wait for all clients + to signal their readiness for additional content. + Any form of content generation that requires + synchronization with an AT would require use of this + action. One example is the generation of text describing + visual content not obvious from a video's sound track. + In this scenario the Text to Speech or Braille output + may take more time than the related length of silence + in the video's sound track. */ + IA2_ACTION_COMPLETE = -2, /**< Used by the client to inform the server that it has + consumed the most recent content provided by this object. */ + IA2_ACTION_CLOSE = -3 /**< Used to inform the server that the client no longer + requires synchronization. */ +}; + +/** @brief This interface gives access to actions that can be executed + for accessible objects. + + Every accessible object that can be manipulated via the native GUI beyond the + methods available either in the MSAA IAccessible interface or in the set of + IAccessible2 interfaces (other than this IAccessibleAction interface) should + support the IAccessibleAction interface in order to provide Assistive Technology + access to all the actions that can be performed by the object. Each action can + be performed or queried for a name, description or associated key bindings. + Actions are needed more for ATs that assist the mobility impaired, such as + on-screen keyboards and voice command software. By providing actions directly, + the AT can present them to the user without the user having to perform the extra + steps to navigate a context menu. + + The first action should be equivalent to the MSAA default action. If there is + only one action, %IAccessibleAction should also be implemented. +*/ +[object, uuid(B70D9F59-3B5A-4dba-AB9E-22012F607DF5)] +interface IAccessibleAction : IUnknown +{ + + /** @brief Returns the number of accessible actions available in this object. + + If there are more than one, the first one is considered the + "default" action of the object. + @param [out] nActions + The returned value of the number of actions is zero if there are + no actions. + @retval S_OK + @note This method is missing a [propget] prefix in the IDL. The result is the + method is named nActions in generated C++ code instead of get_nActions. + */ + HRESULT nActions + ( + [out,retval] long* nActions + ); + + /** @brief Performs the specified Action on the object. + @param [in] actionIndex + 0 based index specifying the action to perform. If it lies outside + the valid range no action is performed. + @retval S_OK + @retval S_FALSE if action could not be performed + @retval E_INVALIDARG if bad [in] passed + @note If implementing support for media, refer to the predefined constants in the ::IA2Actions enum. + */ + HRESULT doAction + ( + [in] long actionIndex + ); + + /** @brief Returns a description of the specified action of the object. + @param [in] actionIndex + 0 based index specifying which action's description to return. + If it lies outside the valid range an empty string is returned. + @param [out] description + The returned value is a localized string of the specified action. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT description + ( + [in] long actionIndex, + [out, retval] BSTR *description + ); + + /** @brief Returns an array of BSTRs describing one or more key bindings, if + there are any, associated with the specified action. + + The returned strings are the localized human readable key sequences to be + used to activate each action, e.g. "Ctrl+Shift+D". Since these key + sequences are to be used when the object has focus, they are like + mnemonics (access keys), and not like shortcut (accelerator) keys. + + There is no need to implement this method for single action controls since + that would be redundant with the standard MSAA programming practice of + getting the mnemonic from get_accKeyboardShortcut. + + An AT such as an On Screen Keyboard might not expose these bindings but + provide alternative means of activation. + + Note: the client allocates and passes in an array of pointers. The server + allocates the BSTRs and passes back one or more pointers to these BSTRs into + the array of pointers allocated by the client. The client is responsible + for deallocating the BSTRs. + + @param [in] actionIndex + 0 based index specifying which action's key bindings should be returned. + @param [in] nMaxBindings + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] keyBindings + An array of BSTRs, allocated by the server, one for each key binding. + The client must free it with CoTaskMemFree. + @param [out] nBindings + The number of key bindings returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are no key bindings, [out] values are NULL and 0 respectively + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT keyBinding + ( + [in] long actionIndex, + [in] long nMaxBindings, + [out, size_is(,nMaxBindings), length_is(,*nBindings)] BSTR **keyBindings, + [out, retval] long *nBindings + ); + + /** @brief Returns the non-localized name of specified action. + @param [in] actionIndex + 0 based index specifying which action's non-localized name should be returned. + @param [out] name + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT name + ( + [in] long actionIndex, + [out, retval] BSTR *name + ); + + /** @brief Returns the localized name of specified action. + @param [in] actionIndex + 0 based index specifying which action's localized name should be returned. + @param [out] localizedName + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT localizedName + ( + [in] long actionIndex, + [out, retval] BSTR *localizedName + ); + +} diff --git a/third_party/ia2/AccessibleApplication.idl b/third_party/ia2/AccessibleApplication.idl new file mode 100644 index 0000000..2586334 --- /dev/null +++ b/third_party/ia2/AccessibleApplication.idl @@ -0,0 +1,121 @@ +/************************************************************************* + * + * File Name (AccessibleApplication.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** @brief This interface gives access to the application's name and version information. + + This interface provides the AT with the information it needs to differentiate + this application from other applications, from other versions of this + application, or from other versions of this application running on different + versions of an accessibility bridge or accessibility toolkit. + + Servers implementing IAccessible2 should provide access to the %IAccessibleApplication + interface via QueryService from any object so that ATs can easily determine specific + information about the application such as its name or version. +*/ +[object, uuid(D49DED83-5B25-43F4-9B95-93B44595979E)] +interface IAccessibleApplication : IUnknown +{ + + /** @brief Returns the application name. + @param [out] name + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT appName + ( + [out, retval] BSTR *name + ); + + /** @brief Returns the application version. + @param [out] version + The version string must not contain levels when it is know beforehand that + this information will never require a change in a client's behavior. + For example, use "3.6.0" rather than "3.6.0.v201005131500". + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT appVersion + ( + [out, retval] BSTR *version + ); + + /** @brief Returns the toolkit/bridge name. + @param [out] name + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT toolkitName + ( + [out, retval] BSTR *name + ); + + /** @brief Returns the toolkit/bridge version. + @param [out] version + The version string must not contain levels when it is know beforehand that + this information will never require a change in a client's behavior. + For example, use "3.6.0" rather than "3.6.0.v201005131500". + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT toolkitVersion + ( + [out, retval] BSTR *version + ); + +} + diff --git a/third_party/ia2/AccessibleComponent.idl b/third_party/ia2/AccessibleComponent.idl new file mode 100644 index 0000000..568997d --- /dev/null +++ b/third_party/ia2/AccessibleComponent.idl @@ -0,0 +1,124 @@ +/************************************************************************* + * + * File Name (AccessibleComponent.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** A value specifying a color in ARGB format, where each 8 bit color component +specifies alpha, red, green, and blue respectively. The alpha value is optional. +*/ +typedef long IA2Color; + +/** @brief This interface is implemented by any object that can be rendered + on the screen. + + This interface provides the standard mechanism for an assistive technology + to retrieve information concerning the graphical representation of an object. + Coordinates used by the functions of this interface are specified in + different coordinate systems. Their scale is the same and is equal to + that of the screen coordinate system. In other words all coordinates + are measured in pixels. They differ in their respective origin: +
    +
  • The screen coordinate system has its origin in the upper left + corner of the current screen.
  • +
  • The origin of the parent coordinate system is the upper left corner + of the parent's bounding box. With no parent the screen coordinate + system is used instead.
  • +
+*/ +[object, uuid(1546D4B0-4C98-4bda-89AE-9A64748BDDE4)] +interface IAccessibleComponent : IUnknown +{ + + /** @brief Returns the location of the upper left corner of the object's + bounding box relative to the immediate parent object. + + The coordinates of the bounding box are given relative to the parent's + coordinate system. The coordinates of the returned position are relative + to this object's parent or relative to the screen on which this object + is rendered if it has no parent. If the object is not on any screen + the returned position is (0,0). + + @param [out] x + @param [out] y + @retval S_OK + */ + [propget] HRESULT locationInParent + ( + [out] long *x, + [out, retval] long *y + ); + + /** @brief Returns the foreground color of this object. + @param [out] foreground + The returned color is the foreground color of this object or, if + that is not supported, the default foreground color. + @retval S_OK + */ + [propget] HRESULT foreground + ( + [out, retval] IA2Color *foreground + ); + + /** @brief Returns the background color of this object. + @param [out] background + The returned color is the background color of this object or, if + that is not supported, the default background color. + @retval S_OK + */ + [propget] HRESULT background + ( + [out, retval] IA2Color *background + ); +} diff --git a/third_party/ia2/AccessibleDocument.idl b/third_party/ia2/AccessibleDocument.idl new file mode 100644 index 0000000..3968f7c --- /dev/null +++ b/third_party/ia2/AccessibleDocument.idl @@ -0,0 +1,78 @@ +/************************************************************************* + * + * File Name (AccessibleDocument.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2013 Linux Foundation + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** @brief This interface represents documents. + + This interface is used for a representation of documents. +*/ +[object, uuid(C48C7FCF-4AB5-4056-AFA6-902D6E1D1149)] +interface IAccessibleDocument : IUnknown +{ + /** @brief Returns the most recently used anchor target within a document. + + A document's most recently targeted in-page anchor is returned. A typical use + of this method is to fetch the anchor target within an HTML document. In this + case anchor targets are those which has been defined with the tag. + + @param [out] accessible + @retval S_OK + @retval S_FALSE if there are no existing valid anchor targets, [out] value is NULL. + */ + [propget] HRESULT anchorTarget + ( + [out, retval] IUnknown **accessible + ); + +} diff --git a/third_party/ia2/AccessibleEditableText.idl b/third_party/ia2/AccessibleEditableText.idl new file mode 100644 index 0000000..08fcbcd --- /dev/null +++ b/third_party/ia2/AccessibleEditableText.idl @@ -0,0 +1,262 @@ +/************************************************************************* + * + * File Name (AccessibleEditableText.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2012 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "IA2CommonTypes.idl"; + +/** @brief This interface provides clipboard capability to text objects. + + This interface is typically used in conjunction with the IAccessibleText + interface and complements that interface with the additional capability of + clipboard operations. Note that even a read only text object can support + the copy capability so this interface is not limited to editable objects. + + The substrings used with this interface are specified as follows: + If startOffset is less than endOffset, the substring starts with the + character at startOffset and ends with the character just before endOffset. + If endOffset is lower than startOffset, the result is the same as a call + with the two arguments exchanged. The whole text can be defined by passing + the indices zero and IAccessibleText::nCharacters. If both indices have the + same value, an empty string is defined. + + Refer to the @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about a special offset constant that can be used in %IAccessibleEditableText methods. +*/ +[object, uuid(A59AA09A-7011-4b65-939D-32B1FB5547E3)] +interface IAccessibleEditableText : IUnknown +{ + + /** @brief Copies the text range into the clipboard. + + The selection is set to the specified offsets and then selection is copied into + the system clipboard. + + @param [in] startOffset + Start index of the text to moved into the clipboard. + The valid range is 0..length. + @param [in] endOffset + End index of the text to moved into the clipboard. + The valid range is 0..length. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + @deprecated This function is available via the application's GUI. + */ + HRESULT copyText + ( + [in] long startOffset, + [in] long endOffset + ); + + /** @brief Deletes a range of text. + + The text between and including the two given indices is deleted + from the text represented by this object. + + @param [in] startOffset + Start index of the text to be deleted. + The valid range is 0..length. + @param [in] endOffset + End index of the text to be deleted. + The valid range is 0..length. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + */ + HRESULT deleteText + ( + [in] long startOffset, + [in] long endOffset + ); + + /** @brief Inserts text at the specified position. + + The specified string is inserted at the given index into the text + represented by this object. + + @param [in] offset + Index at which to insert the text. + The valid range is 0..length. + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + @param [in] text + Text that is inserted. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT insertText + ( + [in] long offset, + [in] BSTR *text + ); + + /** @brief Deletes a range of text and copies it to the clipboard. + + The selection is set to the specified offsets, the selection is then copied into + the system clipboard, and then the selection is deleted. + + @param [in] startOffset + Start index of the text to be deleted. + The valid range is 0..length. + @param [in] endOffset + End index of the text to be deleted. + The valid range is 0..length. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + @deprecated This function is available via the application's GUI. + */ + HRESULT cutText + ( + [in] long startOffset, + [in] long endOffset + ); + + /** @brief Pastes content from the clipboard. + + Any existing selection is removed, the clipboard content is then pasted into + this object's text at the given offset. This method is similar to the insertText + method. If the index is not valid the system clipboard content is not inserted. The + behavior is the same as when Ctrl+V is used, i.e. the pasted contents are not + necessarily plain text. + + @param [in] offset + Index at which to insert the content from the system clipboard into + the text represented by this object. + The valid range is 0..length. + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @deprecated This function is available via the application's GUI. + */ + HRESULT pasteText + ( + [in] long offset + ); + + /** @brief Replaces text. + + The text between the two given indices is replaced by the specified + replacement string. This method is equivalent to calling first + IAccessibleEditableText::deleteText with the two indices and then + calling IAccessibleEditableText::insertText with the replacement text + at the start index. + + @param [in] startOffset + Start index of the text to be replaced. + The valid range is 0..length. + @param [in] endOffset + End index of the text to be replaced. + The valid range is 0..length. + @param [in] text + The Text that replaces the text between the given indices. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + */ + HRESULT replaceText + ( + [in] long startOffset, + [in] long endOffset, + [in] BSTR *text + ); + + /** @brief Replaces the attributes of a text range by the given set of attributes. + + Sets the attributes for the text between the two given indices. The old + attributes are replaced by the new list of attributes. + + @param [in] startOffset + Start index of the text whose attributes are modified. + The valid range is 0..length. + @param [in] endOffset + End index of the text whose attributes are modified. + The valid range is 0..length. + @param [in] attributes + Set of attributes that replaces the old list of attributes of + the specified text portion. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleEditableText + methods. + */ + HRESULT setAttributes + ( + [in] long startOffset, + [in] long endOffset, + [in] BSTR *attributes + ); +} + diff --git a/third_party/ia2/AccessibleEventID.idl b/third_party/ia2/AccessibleEventID.idl new file mode 100644 index 0000000..62a98a9 --- /dev/null +++ b/third_party/ia2/AccessibleEventID.idl @@ -0,0 +1,235 @@ +/************************************************************************* + * + * File Name (AccessibleEventID.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +/** %IAccessible2 specific event constants + + This enum defines the event IDs fired by %IAccessible2 objects. The event IDs + are in addition to those used by MSAA. +*/ +enum IA2EventID { + + /** The change of the number or attributes of actions of an accessible + object is signaled by events of this type. + */ + IA2_EVENT_ACTION_CHANGED = 0x101, + + /** Deprecated. The active descendant of a component has changed. + + Note: This event constant is misspelled and thus is deprecated and will be + removed in a later version. Please use the correctly spelled version which + follows. + */ + IA2_EVENT_ACTIVE_DECENDENT_CHANGED, + + /** The active descendant of a component has changed. The active descendant + is used in objects with transient children. + + Note: Due to the fact that MSAA's WinEvents don't allow the active child index + to be passed on the IA2_EVENT_ACTIVE_DESCENDANT_CHANGED event the manages + descendants scheme can't be used. Instead the active child object has to fire + MSAA's EVENT_OBJECT_FOCUS. In a future release a new event mechanism may be + added to provide for event specific data to be passed with the event. At that + time the IA2_EVENT_ACTIVE_DECENDENT_CHANGED event and + IA2_STATE_MANAGES_DESCENDANTS state would be useful. + */ + IA2_EVENT_ACTIVE_DESCENDANT_CHANGED = IA2_EVENT_ACTIVE_DECENDENT_CHANGED, + + /** The document wide attributes of the document object have changed. + */ + IA2_EVENT_DOCUMENT_ATTRIBUTE_CHANGED, + + /** The contents of the document have changed. + */ + IA2_EVENT_DOCUMENT_CONTENT_CHANGED, + + /** The loading of the document has completed. + */ + IA2_EVENT_DOCUMENT_LOAD_COMPLETE, + + /** The loading of the document was interrupted. + */ + IA2_EVENT_DOCUMENT_LOAD_STOPPED, + + /** The document contents are being reloaded. + */ + IA2_EVENT_DOCUMENT_RELOAD, + + /** The ending index of this link within the containing string has changed. + */ + IA2_EVENT_HYPERLINK_END_INDEX_CHANGED, + + /** The number of anchors associated with this hyperlink object has changed. + */ + IA2_EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED, + + /** The hyperlink selected state changed from selected to unselected or + from unselected to selected. + */ + IA2_EVENT_HYPERLINK_SELECTED_LINK_CHANGED, + + /** One of the links associated with the hypertext object has been activated. + */ + IA2_EVENT_HYPERTEXT_LINK_ACTIVATED, + + /** One of the links associated with the hypertext object has been selected. + */ + IA2_EVENT_HYPERTEXT_LINK_SELECTED, + + /** The starting index of this link within the containing string has changed. + */ + IA2_EVENT_HYPERLINK_START_INDEX_CHANGED, + + /** Focus has changed from one hypertext object to another, or focus moved + from a non-hypertext object to a hypertext object, or focus moved from a + hypertext object to a non-hypertext object. + */ + IA2_EVENT_HYPERTEXT_CHANGED, + + /** The number of hyperlinks associated with a hypertext object changed + */ + IA2_EVENT_HYPERTEXT_NLINKS_CHANGED, + + /** An object's attributes changed. + Also see ::IA2_EVENT_TEXT_ATTRIBUTE_CHANGED. + */ + IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED, + + /** A slide changed in a presentation document or a page boundary was + crossed in a word processing document. + */ + IA2_EVENT_PAGE_CHANGED, + + /** The caret moved from one section to the next. + */ + IA2_EVENT_SECTION_CHANGED, + + /** A table caption changed. + */ + IA2_EVENT_TABLE_CAPTION_CHANGED, + + /** A table's column description changed. + */ + IA2_EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED, + + /** A table's column header changed. + */ + IA2_EVENT_TABLE_COLUMN_HEADER_CHANGED, + + /** A table's data changed. + */ + IA2_EVENT_TABLE_MODEL_CHANGED, + + /** A table's row description changed. + */ + IA2_EVENT_TABLE_ROW_DESCRIPTION_CHANGED, + + /** A table's row header changed. + */ + IA2_EVENT_TABLE_ROW_HEADER_CHANGED, + + /** A table's summary changed. + */ + IA2_EVENT_TABLE_SUMMARY_CHANGED, + + /** A text object's attributes changed. + Also see ::IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED. + */ + IA2_EVENT_TEXT_ATTRIBUTE_CHANGED, + + /** The caret has moved to a new position. + */ + IA2_EVENT_TEXT_CARET_MOVED, + + /** Deprecated. This event is equivalent to ::IA2_EVENT_TEXT_UPDATED. + */ + IA2_EVENT_TEXT_CHANGED, + + /** The caret moved from one column to the next. + */ + IA2_EVENT_TEXT_COLUMN_CHANGED, + + /** Text was inserted. + */ + IA2_EVENT_TEXT_INSERTED, + + /** Text was removed. + */ + IA2_EVENT_TEXT_REMOVED, + + /** This event indicates general text changes, i.e. changes to text that are + exposed through the IAccessibleText interface. For compatibility with ATK/AT-SPI + which does not have an equivalent event, servers can alternatively fire + ::IA2_EVENT_TEXT_REMOVED and ::IA2_EVENT_TEXT_INSERTED. + */ + IA2_EVENT_TEXT_UPDATED, + + /** The text selection changed. Later versions of Microsoft development environments + have an equivalent event identified, EVENT_OBJECT_TEXTSELECTIONCHANGED. Servers + should use that if it is available and use IA2_EVENT_TEXT_SELECTION_CHANGED otherwise. + Clients should be prepared to respond to either event. + + */ + IA2_EVENT_TEXT_SELECTION_CHANGED, + + /** A visible data event indicates the change of the visual appearance + of an accessible object. This includes for example most of the + attributes available via the IAccessibleComponent interface. + */ + IA2_EVENT_VISIBLE_DATA_CHANGED, + + /** The role changed. This should only be used if the interfaces supported by the object + did not also change. If the interfaces need to change, the object should be destroyed + and a new object created. + */ + IA2_EVENT_ROLE_CHANGED +}; diff --git a/third_party/ia2/AccessibleHyperlink.idl b/third_party/ia2/AccessibleHyperlink.idl new file mode 100644 index 0000000..76b8acd --- /dev/null +++ b/third_party/ia2/AccessibleHyperlink.idl @@ -0,0 +1,187 @@ +/************************************************************************* + * + * File Name (AccessibleHyperlink.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "AccessibleAction.idl"; + +/** @brief This interface represents hyperlinks. + + This interface represents a hyperlink associated with a single substring + of text or single non-text object. Non-text objects can have either a + single link or a collection of links such as when the non-text object is + an image map. + + Linked objects and anchors are implementation dependent. This interface is derived + from IAccessibleAction. IAccessibleAction::nActions is one greater than the + maximum value for the indices used with the methods of this interface. + + Furthermore, the object that implements this interface has to be connected + implicitly or explicitly with an object that implements IAccessibleText. + IAccessibleHyperlink::startIndex and IAccessibleHyperlink::endIndex are + indices with respect to the text exposed by IAccessibleText. + + This interface provides access to a single object which can have multiple actions. + An example is an image map which is an image with multiple links each of which is + associated with a separate non-overlapping area of the image. This interface could + also be applied to other kinds of objects with multiple actions such as "smart tags" + which are objects, typically strings, which have multiple actions such as + "Activate URI", "Bookmark URI", etc. + + An interesting use case is an image map where each area is associated with multiple + actions, e.g. an image map of smart tags. In this case you would have to implement + two levels of accessible hyperlinks. The first level hyperlinks would only implement + anchor and anchorTarget. The anchors would all reference the image object. The + anchorTargets would reference the second level accessible hyperlink objects. None + of the IAccessibleAction methods would be implemented on the first level hyperlink + objects. The second level hyperlink objects would implement the IAccessibleAction + methods. Their anchors would also reference the image object and their anchorTargets + would reference URLs or the objects that would be activated. + + This use case demonstrates that in some cases there is no need for IAccessibleHyperlink + to derive from IAccessibleAction. As a result it may be removed in a later version of + the IDL and it is suggested that implementations should not rely on the inheritance. + +*/ +[object, uuid(01C20F2B-3DD2-400f-949F-AD00BDAB1D41)] +interface IAccessibleHyperlink : IAccessibleAction +{ + + /** @brief Returns an object that represents the link anchor, as appropriate + for the link at the specified index. + @param [in] index + A 0 based index identifies the anchor when, as in the case of an image map, + there is more than one link represented by this object. The valid maximal + index is indicated by IAccessibleAction::nActions. + @param [out] anchor + This is an implementation dependent value. For example, for a text link this + method could return the substring of the containing string where the substring + is overridden with link behavior, and for an image link this method could return + an IUnknown VARIANT for IAccessibleImage. See the section about + @ref _variants "VARIANTs" for additional information. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT anchor + ( + [in] long index, + [out, retval] VARIANT *anchor + ); + + /** @brief Returns an object representing the target of the link, as appropriate + for the link at the specified index. + @param [in] index + A 0 based index identifies the anchor when, as in the case of an image map, + there is more than one link represented by this object. The valid maximal + index is indicated by IAccessibleAction::nActions. + @param [out] anchorTarget + This is an implementation dependent value. For example this method could + return a BSTR VARIANT of the URI. Alternatively this method could return an + IUnknown VARIANT of a COM interface representing a target object to be + activated when the link is activated. See the section about + @ref _variants "VARIANTs" for additional information. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT anchorTarget + ( + [in] long index, + [out, retval] VARIANT *anchorTarget + ); + + /** @brief Returns the 0 based character offset at which the textual representation of the hyperlink starts. + + The returned value is related to the IAccessibleText interface of the object that + owns this hyperlink. + @param [out] index + @retval S_OK + */ + [propget] HRESULT startIndex + ( + [out, retval] long *index + ); + + /** @brief Returns the 0 based character offset at which the textual representation of the hyperlink ends. + + The returned value is related to the IAccessibleText interface of the object that + owns this hyperlink. The character at the index is not part of the hypertext. + @param [out] index + @retval S_OK + */ + [propget] HRESULT endIndex + ( + [out, retval] long *index + ); + + /** @brief Returns whether the target object referenced by this link is still valid. + + This is a volatile state that may change without sending an appropriate event. + Returns TRUE if the referenced target is still valid and FALSE otherwise. + + This has also been used to indicate whether or not the URI of the anchorTarget + is malformed. + + @param [out] valid + If false, one or more of the object's links are invalid. + If true, all of the object's links are valid. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is FALSE + @note This method is not being used, is deprecated, and should not be implemented or + used. It is likely that this method will be removed in a later version of the IDL. + */ + [propget] HRESULT valid + ( + [out, retval] boolean *valid + ); +} diff --git a/third_party/ia2/AccessibleHypertext.idl b/third_party/ia2/AccessibleHypertext.idl new file mode 100644 index 0000000..03afe5b --- /dev/null +++ b/third_party/ia2/AccessibleHypertext.idl @@ -0,0 +1,123 @@ +/************************************************************************* + * + * File Name (AccessibleHypertext.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "AccessibleText.idl"; +import "AccessibleHyperlink.idl"; + +/** @brief This interface exposes information about hypertext in a document. + + The %IAccessibleHypertext interface is the main interface to expose + hyperlinks in a document, typically a text document, that are used + to reference other documents. A typical implementation is to implement + this interface on the smallest text object such as a paragraph of text. +*/ +[object, uuid(6B4F8BBF-F1F2-418a-B35E-A195BC4103B9)] +interface IAccessibleHypertext : IAccessibleText +{ + + /** @brief Returns the number of links and link groups contained within this hypertext + paragraph. + @param [out] hyperlinkCount + The number of links and link groups within this hypertext paragraph. + Returns 0 if there is no link. + @retval S_OK + */ + [propget] HRESULT nHyperlinks + ( + [out, retval] long *hyperlinkCount + ); + + /** @brief Returns the specified link. + + The returned IAccessibleHyperlink object encapsulates the hyperlink and + provides several kinds of information describing it. + @param [in] index + This 0 based index specifies the hyperlink to return. + @param [out] hyperlink + If the given index is valid, i.e. lies in the interval from 0 to the number + of links minus one, a reference to the specified hyperlink object is returned. + If the index is invalid then a NULL pointer is returned. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT hyperlink + ( + [in] long index, + [out, retval] IAccessibleHyperlink **hyperlink + ); + + /** @brief Returns the index of the hyperlink that is associated with this character index. + + This is the case when a link spans the given character index. + @param [in] charIndex + A 0 based index of the character for which to return the link index. If + IAccessibleText is used to represent the text containing the link, then the + character index is only valid if it is greater than or equal to zero and + lower than the number of characters in the text. + @param [out] hyperlinkIndex + Returns the 0 based index of the hyperlink that is associated with this + character index, or -1 if charIndex is not on a link. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is -1 + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT hyperlinkIndex + ( + [in] long charIndex, + [out, retval] long *hyperlinkIndex + ); + +} diff --git a/third_party/ia2/AccessibleHypertext2.idl b/third_party/ia2/AccessibleHypertext2.idl new file mode 100644 index 0000000..50bface --- /dev/null +++ b/third_party/ia2/AccessibleHypertext2.idl @@ -0,0 +1,87 @@ +/************************************************************************* + * + * File Name (AccessibleHypertext2.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "AccessibleHypertext.idl"; +import "AccessibleHyperlink.idl"; + +/** @brief This interface exposes information about hypertext in a document. + + The %IAccessibleHypertext2 interface extends the functionality of the + %IAccessibleHypertext interface. +*/ +[object, uuid(CF64D89F-8287-4B44-8501-A827453A6077)] +interface IAccessibleHypertext2 : IAccessibleHypertext +{ + + /** @brief Returns the links for this object. + + The returned IAccessibleHyperlink objects encapsulate the hyperlink and + provides several kinds of information describing it. + + @param [out] hyperlinks + This array is allocated by the server. The client must free it with CoTaskMemFree. + @param [out] nHyperlinks + The number of links returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are no links, [out] values are NULL and 0 respectively + */ + [propget] HRESULT hyperlinks + ( + [out, size_is(,*nHyperlinks)] IAccessibleHyperlink ***hyperlinks, + [out, retval] long *nHyperlinks + ); + +} diff --git a/third_party/ia2/AccessibleImage.idl b/third_party/ia2/AccessibleImage.idl new file mode 100644 index 0000000..21fe098 --- /dev/null +++ b/third_party/ia2/AccessibleImage.idl @@ -0,0 +1,111 @@ +/************************************************************************* + * + * File Name (AccessibleImage.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "IA2CommonTypes.idl"; + +/** @brief This interface represents images and icons. + + This interface is used for a representation of images like icons on buttons. + %IAccessibleImage only needs to be implemented in certain situations. Some + examples are: +
    +
  1. The accessible name and description are not enough to fully + describe the image, e.g. when the accessible description is used to define the + behavior of an actionable image and the image itself conveys semantically + significant information. +
  2. The user can edit the content that includes an + image and therefore the user needs to be able to review the image's position. +
+*/ +[object, uuid(FE5ABB3D-615E-4f7b-909F-5F0EDA9E8DDE)] +interface IAccessibleImage : IUnknown +{ + /** @brief Returns the localized description of the image. + @param [out] description + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT description + ( + [out, retval] BSTR *description + ); + + /** @brief Returns the coordinates of the image. + @param [in] coordinateType + Specifies whether the returned coordinates should be relative to the screen or the parent object. + @param [out] x + @param [out] y + @retval S_OK + */ + [propget] HRESULT imagePosition + ( + [in] enum IA2CoordinateType coordinateType, + [out] long *x, + [out, retval] long *y + ); + + /** @brief Returns the size of the image in units specified by parent's coordinate system. + @param [out] height + @param [out] width + @retval S_OK + */ + + [propget] HRESULT imageSize + ( + [out] long *height, + [out, retval] long *width + ); +} diff --git a/third_party/ia2/AccessibleRelation.idl b/third_party/ia2/AccessibleRelation.idl new file mode 100644 index 0000000..ddb6e7c --- /dev/null +++ b/third_party/ia2/AccessibleRelation.idl @@ -0,0 +1,245 @@ +/************************************************************************* + * + * File Name (AccessibleRelation.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** @defgroup grpRelations Relations + Use the following constants to compare against the BSTRs returned by + IAccessibleRelation::relationType. +*/ +///@{ + +/** The target object is the containing application object. */ +const WCHAR *const IA2_RELATION_CONTAINING_APPLICATION = L"containingApplication"; + +/** The target object is the containing document object. The target object implements + the IAccessibleDocument interface. +*/ +const WCHAR *const IA2_RELATION_CONTAINING_DOCUMENT = L"containingDocument"; + +/** The target object is the containing tab pane object. */ +const WCHAR *const IA2_RELATION_CONTAINING_TAB_PANE = L"containingTabPane"; + +/** The target object is the containing window object. */ +const WCHAR *const IA2_RELATION_CONTAINING_WINDOW = L"containingWindow"; + +/** Some attribute of this object is affected by a target object. */ +const WCHAR *const IA2_RELATION_CONTROLLED_BY = L"controlledBy"; + +/** This object is interactive and controls some attribute of a target object. */ +const WCHAR *const IA2_RELATION_CONTROLLER_FOR = L"controllerFor"; + +/** This object is described by the target object. */ +const WCHAR *const IA2_RELATION_DESCRIBED_BY = L"describedBy"; + +/** This object is describes the target object. */ +const WCHAR *const IA2_RELATION_DESCRIPTION_FOR = L"descriptionFor"; + +/** This object is embedded by a target object. */ +const WCHAR *const IA2_RELATION_EMBEDDED_BY = L"embeddedBy"; + +/** This object embeds a target object. This relation can be used on the + OBJID_CLIENT accessible for a top level window to show where the content + areas are. +*/ +const WCHAR *const IA2_RELATION_EMBEDS = L"embeds"; + +/** Content flows to this object from a target object. + This relation and IA2_RELATION_FLOWS_TO are useful to tie text and non-text + objects together in order to allow assistive technology to follow the + intended reading order. +*/ +const WCHAR *const IA2_RELATION_FLOWS_FROM = L"flowsFrom"; + +/** Content flows from this object to a target object. */ +const WCHAR *const IA2_RELATION_FLOWS_TO = L"flowsTo"; + +/** This object is label for a target object. */ +const WCHAR *const IA2_RELATION_LABEL_FOR = L"labelFor"; + +/** This object is labelled by a target object. Note that the double L spelling + which follows is preferred. Please use it instead. This single L version may + be removed in a later version. +*/ +const WCHAR *const IA2_RELATION_LABELED_BY = L"labelledBy"; + +/** This object is labelled by a target object. */ +const WCHAR *const IA2_RELATION_LABELLED_BY = L"labelledBy"; + +/** This object is a member of a group of one or more objects. When + there is more than one object in the group each member may have one and the + same target, e.g. a grouping object. It is also possible that each member has + multiple additional targets, e.g. one for every other member in the group. +*/ +const WCHAR *const IA2_RELATION_MEMBER_OF = L"memberOf"; + +/** The target object is the next object in the tab order. */ +const WCHAR *const IA2_RELATION_NEXT_TABBABLE = L"nextTabbable"; + +/** This object is a logical child of a target object. This relation is the reciprocal + of the IA2_RELATION_NODE_PARENT_OF relation. In some cases an application's accessible + tree is such that objects can be in a logical parent-child relationship which is + different from the hierarchy of the accessible tree. */ +const WCHAR *const IA2_RELATION_NODE_CHILD_OF = L"nodeChildOf"; + +/** This object is a logical parent of a target object. This relation is the reciprocal + of the IA2_RELATION_NODE_CHILD_OF relation. In some cases an application's accessible + tree is such that objects can be in a logical parent-child relationship which is + different from the hierarchy of the accessible tree. */ +const WCHAR *const IA2_RELATION_NODE_PARENT_OF = L"nodeParentOf"; + +/** This object is a parent window of the target object. */ +const WCHAR *const IA2_RELATION_PARENT_WINDOW_OF = L"parentWindowOf"; + +/** This object is a transient component related to the target object. + When this object is activated the target object doesn't lose focus. +*/ +const WCHAR *const IA2_RELATION_POPUP_FOR = L"popupFor"; + +/** The target object is the previous object in the tab order. */ +const WCHAR *const IA2_RELATION_PREVIOUS_TABBABLE = L"previousTabbable"; + +/** This object is a sub window of a target object. */ +const WCHAR *const IA2_RELATION_SUBWINDOW_OF = L"subwindowOf"; + +/** The target object provides the detailed, extended description for this + object. It provides more detailed information than would normally be provided + using the IA2_RELATION_DESCRIBED_BY relation. A common use for this relation is + in digital publishing where an extended description needs to be conveyed in + a book that requires structural markup or the embedding of other technology to + provide illustrative content. */ +const WCHAR *const IA2_RELATION_DETAILS = L"details"; + +/** This object provides the detailed, extended description for the target + object. See IA2_RELATION_DETAILS. */ +const WCHAR *const IA2_RELATION_DETAILS_FOR = L"detailsFor"; + +/** The target object is the error message for this object. */ +const WCHAR *const IA2_RELATION_ERROR = L"error"; + +/** This object is the error message for the target object. */ +const WCHAR *const IA2_RELATION_ERROR_FOR = L"errorFor"; + +///@} + +/** This interface gives access to an object's set of relations. +*/ +[object, uuid(7CDF86EE-C3DA-496a-BDA4-281B336E1FDC)] +interface IAccessibleRelation : IUnknown +{ + /** @brief Returns the type of the relation. + @param [out] relationType + The strings returned are defined @ref grpRelations "in this section of the documentation". + @retval S_OK + */ + [propget] HRESULT relationType + ( + [out, retval] BSTR *relationType + ); + + /** @brief Returns a localized version of the relation type. + @param [out] localizedRelationType + @retval S_OK + */ + [propget] HRESULT localizedRelationType + ( + [out, retval] BSTR *localizedRelationType + ); + + /** @brief Returns the number of targets for this relation. + @param [out] nTargets + @retval S_OK + */ + [propget] HRESULT nTargets + ( + [out, retval] long *nTargets + ); + + /** @brief Returns one accessible relation target. + @param [in] targetIndex + 0 based index + @param [out] target + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Use QueryInterface to get IAccessible2. + */ + [propget] HRESULT target + ( + [in] long targetIndex, + [out, retval] IUnknown **target + ); + + /** @brief Returns multiple accessible relation targets + @param [in] maxTargets + maximum size of the array allocated by the client + @param [out] targets + The array of target objects. Note that this array is to be allocated by the + client and freed when no longer needed. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. You will need to use + QueryInterface on the IUnknown to get the IAccessible2. + @param [out] nTargets + actual number of targets in the returned array (not more than maxTargets) + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, e.g. a negative value + */ + [propget] HRESULT targets + ( + [in] long maxTargets, + [out, size_is(maxTargets), length_is(*nTargets)] + IUnknown **targets, + [out, retval] long *nTargets + ); + +} diff --git a/third_party/ia2/AccessibleRole.idl b/third_party/ia2/AccessibleRole.idl new file mode 100644 index 0000000..c259a2d --- /dev/null +++ b/third_party/ia2/AccessibleRole.idl @@ -0,0 +1,348 @@ +/************************************************************************* + * + * File Name (AccessibleRole.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007-2018 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; + +/** Collection of roles + + This enumerator defines an extended set of accessible roles of objects implementing + the %IAccessible2 interface. These roles are in addition to the MSAA roles obtained + through the MSAA get_accRole method. Examples are 'footnote', 'heading', and + 'label'. You obtain an object's %IAccessible2 roles by calling IAccessible2::role. +*/ +enum IA2Role { + + /** Unknown role. The object contains some Accessible information, but its + role is not known. + */ + IA2_ROLE_UNKNOWN = 0, + + /** An object that can be drawn into and to manage events from the objects + drawn into it. Also refer to ::IA2_ROLE_FRAME, + ::IA2_ROLE_GLASS_PANE, and ::IA2_ROLE_LAYERED_PANE. + */ + IA2_ROLE_CANVAS = 0x401, + + /// A caption describing another object. + IA2_ROLE_CAPTION, + + /// Used for check buttons that are menu items. + IA2_ROLE_CHECK_MENU_ITEM, + + /// A specialized dialog that lets the user choose a color. + IA2_ROLE_COLOR_CHOOSER, + + /// A date editor. + IA2_ROLE_DATE_EDITOR, + + /** An iconified internal frame in an ::IA2_ROLE_DESKTOP_PANE. + Also refer to ::IA2_ROLE_INTERNAL_FRAME. + */ + IA2_ROLE_DESKTOP_ICON, + + /** A desktop pane. A pane that supports internal frames and iconified + versions of those internal frames. Also refer to ::IA2_ROLE_INTERNAL_FRAME. + */ + IA2_ROLE_DESKTOP_PANE, + + /** A directory pane. A pane that allows the user to navigate through + and select the contents of a directory. May be used by a file chooser. + Also refer to ::IA2_ROLE_FILE_CHOOSER. + */ + IA2_ROLE_DIRECTORY_PANE, + + /** An editable text object in a toolbar. Deprecated. + The edit bar role was meant for a text area in a tool bar. However, to detect + a text area in a tool bar the AT can query the parent. + */ + IA2_ROLE_EDITBAR, + + /// Embedded (OLE) object. + IA2_ROLE_EMBEDDED_OBJECT, + + /// Text that is used as an endnote (footnote at the end of a chapter or section). + IA2_ROLE_ENDNOTE, + + /** A file chooser. A specialized dialog that displays the files in the + directory and lets the user select a file, browse a different directory, + or specify a filename. May use the directory pane to show the contents of + a directory. + Also refer to ::IA2_ROLE_DIRECTORY_PANE. + */ + IA2_ROLE_FILE_CHOOSER, + + /** A font chooser. A font chooser is a component that lets the user pick + various attributes for fonts. + */ + IA2_ROLE_FONT_CHOOSER, + + /** Footer of a document page. + Also refer to ::IA2_ROLE_HEADER. + */ + IA2_ROLE_FOOTER, + + /// Text that is used as a footnote. Also refer to ::IA2_ROLE_ENDNOTE. + IA2_ROLE_FOOTNOTE, + + /** A container of form controls. An example of the use of this role is to + represent an HTML FORM tag. + */ + IA2_ROLE_FORM, + + /** Frame role. A top level window with a title bar, border, menu bar, etc. + It is often used as the primary window for an application. Also refer to + ::IA2_ROLE_CANVAS and the MSAA roles of dialog and window. + */ + IA2_ROLE_FRAME, + + /** A glass pane. A pane that is guaranteed to be painted on top of all panes + beneath it. Also refer to ::IA2_ROLE_CANVAS, ::IA2_ROLE_INTERNAL_FRAME, and + ::IA2_ROLE_ROOT_PANE. + */ + IA2_ROLE_GLASS_PANE, + + /** Header of a document page. + Also refer to ::IA2_ROLE_FOOTER. + */ + IA2_ROLE_HEADER, + + /// Heading. Use the IAccessible2::attributes level attribute to determine the heading level. + IA2_ROLE_HEADING, + + /// A small fixed size picture, typically used to decorate components. + IA2_ROLE_ICON, + + /** An image map object. Usually a graphic with multiple hotspots, where + each hotspot can be activated resulting in the loading of another document + or section of a document. + */ + IA2_ROLE_IMAGE_MAP, + + /** An object which is used to allow input of characters not found on a keyboard, + such as the input of Chinese characters on a Western keyboard. + */ + IA2_ROLE_INPUT_METHOD_WINDOW, + + /** An internal frame. A frame-like object that is clipped by a desktop pane. + The desktop pane, internal frame, and desktop icon objects are often used to + create multiple document interfaces within an application. + Also refer to ::IA2_ROLE_DESKTOP_ICON, ::IA2_ROLE_DESKTOP_PANE, and ::IA2_ROLE_FRAME. + */ + IA2_ROLE_INTERNAL_FRAME, + + /// An object used to present an icon or short string in an interface. + IA2_ROLE_LABEL, + + /** A layered pane. A specialized pane that allows its children to be drawn + in layers, providing a form of stacking order. This is usually the pane that + holds the menu bar as well as the pane that contains most of the visual + components in a window. + Also refer to ::IA2_ROLE_CANVAS, ::IA2_ROLE_GLASS_PANE, and ::IA2_ROLE_ROOT_PANE. + */ + IA2_ROLE_LAYERED_PANE, + + /** A section whose content is parenthetic or ancillary to the main content + of the resource. + */ + IA2_ROLE_NOTE, + + /** A specialized pane whose primary use is inside a dialog. + Also refer to MSAA's dialog role. + */ + IA2_ROLE_OPTION_PANE, + + /** An object representing a page of document content. It is used in documents + which are accessed by the user on a page by page basis. + */ + IA2_ROLE_PAGE, + + /// A paragraph of text. + IA2_ROLE_PARAGRAPH, + + /** A radio button that is a menu item. + Also refer to MSAA's button and menu item roles. + */ + IA2_ROLE_RADIO_MENU_ITEM, + + /** An object which is redundant with another object in the accessible hierarchy. + ATs typically ignore objects with this role. + */ + IA2_ROLE_REDUNDANT_OBJECT, + + /** A root pane. A specialized pane that has a glass pane and a layered pane + as its children. + Also refer to ::IA2_ROLE_GLASS_PANE and ::IA2_ROLE_LAYERED_PANE + */ + IA2_ROLE_ROOT_PANE, + + /** A ruler such as those used in word processors. + */ + IA2_ROLE_RULER, + + /** A scroll pane. An object that allows a user to incrementally view a large + amount of information. Its children can include scroll bars and a viewport. + Also refer to ::IA2_ROLE_VIEW_PORT and MSAA's scroll bar role. + */ + IA2_ROLE_SCROLL_PANE, + + /** A container of document content. An example of the use of this role is to + represent an HTML DIV tag. A section may be used as a region. A region is a + group of elements that together form a perceivable unit. A region does not + necessarily follow the logical structure of the content, but follows the + perceivable structure of the page. A region may have an attribute in the set + of IAccessible2::attributes which indicates that it is "live". A live region + is content that is likely to change in response to a timed change, a user + event, or some other programmed logic or event. + */ + IA2_ROLE_SECTION, + + /// Object with graphical representation used to represent content on draw pages. + IA2_ROLE_SHAPE, + + /** A split pane. A specialized panel that presents two other panels at the + same time. Between the two panels is a divider the user can manipulate to make + one panel larger and the other panel smaller. + */ + IA2_ROLE_SPLIT_PANE, + + /** An object that forms part of a menu system but which can be "undocked" + from or "torn off" the menu system to exist as a separate window. + */ + IA2_ROLE_TEAR_OFF_MENU, + + /// An object used as a terminal emulator. + IA2_ROLE_TERMINAL, + + /// Collection of objects that constitute a logical text entity. + IA2_ROLE_TEXT_FRAME, + + /** A toggle button. A specialized push button that can be checked or unchecked, + but does not provide a separate indicator for the current state. + Also refer to MSAA's roles of push button, check box, and radio button. +
Note: IA2_ROLE_TOGGLE_BUTTON should not be used. Instead, use MSAA's + ROLE_SYSTEM_PUSHBUTTON and STATE_SYSTEM_PRESSED. + */ + IA2_ROLE_TOGGLE_BUTTON, + + /** A viewport. An object usually used in a scroll pane. It represents the + portion of the entire data that the user can see. As the user manipulates + the scroll bars, the contents of the viewport can change. + Also refer to ::IA2_ROLE_SCROLL_PANE. + */ + IA2_ROLE_VIEW_PORT, + + /** An object containing content which is complementary to the main content of + a document, but remains meaningful when separated from the main content. There + are various types of content that would appropriately have this role. For example, + in the case where content is delivered via a web portal to a web browser, this may + include but not be limited to show times, current weather, related articles, or + stocks to watch. The complementary role indicates that contained content is relevant + to the main content. If the complementary content is completely separable main + content, it may be appropriate to use a more general role. + */ + IA2_ROLE_COMPLEMENTARY_CONTENT, + + /** An object representing a navigational landmark, a region on a page to + which the user may want quick access, such as a navigation area, a search + facility or the main content of a page. + */ + IA2_ROLE_LANDMARK, + + /** + * A bar that serves as a level indicator to, for instance, show + * the strength of a password or the charge of a battery. + */ + IA2_ROLE_LEVEL_BAR, + + /** Content previously deleted or proposed for deletion, e.g. in revision + history or a content view providing suggestions from reviewers. + */ + IA2_ROLE_CONTENT_DELETION, + + /** Content previously inserted or proposed for insertion, e.g. in revision + history or a content view providing suggestions from reviewers. + */ + IA2_ROLE_CONTENT_INSERTION, + + /// A section of content that is quoted from another source. + IA2_ROLE_BLOCK_QUOTE, + + /** A run of content that is marked or highlighted, such as for reference + purposes, or to call it out as having a special purpose that is clear from + context. If the mark is used in conjunction with a related content section + in the document, then IA2_RELATION_DETAILS should be used to link the + related content (and the reverse relation IA2_RELATION_DETAILS_FOR should + link back to the IA2_ROLE_MARK object). If the mark has related information + in a tooltip, or as hidden text, then accDescription should be used to + provide this information. + */ + IA2_ROLE_MARK, + + /** A grouping for content that is called out as a proposed change from the + current version of the document, such as by a reviewer of the content. + Should include as children one or both of: + IA2_ROLE_CONTENT_DELETION and IA2_ROLE_CONTENT_INSERTION, in any order, + to indicate what the actual change is. + If the suggestion is accepted, the implementation should change the role to + a generic one such as IA2_ROLE_SECTION or IA2_ROLE_TEXT_FRAME. + */ + IA2_ROLE_SUGGESTION, + + /** A single comment, typically user-generated content. Supports reply + hierarchies via descendant structure, e.g. a child comment is a reply + to the parent comment. Supports groupPosition() method to determine + reply level (top comment is 1), as well as set size and position in set + within that level. + */ + IA2_ROLE_COMMENT +}; diff --git a/third_party/ia2/AccessibleStates.idl b/third_party/ia2/AccessibleStates.idl new file mode 100644 index 0000000..768b6f3 --- /dev/null +++ b/third_party/ia2/AccessibleStates.idl @@ -0,0 +1,209 @@ +/************************************************************************* + * + * File Name (AccessibleStates.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; + +typedef long AccessibleStates; + +/** %IAccessible2 specific state bit constants + + This enum defines the state bits returned by IAccessible2::states. The + %IAccessible2 state bits are in addition to those returned by MSAA. +*/ +enum IA2States { + +/** Indicates a window is currently the active window, or is an active subelement + within a container or table. + + This state can be used to indicate the current active item in a container, even + if the container itself is not currently active. In other words this would indicate + the item that will get focus if you tab to the container. + + This information is important for knowing what to report for trees and potentially + other containers in a virtual buffer. + + Also, see ::IA2_STATE_MANAGES_DESCENDANTS for more information. +*/ +IA2_STATE_ACTIVE = 0x1, + +/** Indicates that the object is armed. + + Used to indicate that the control is "pressed" and will be invoked when the + actuator, e.g. a mouse button, is "released". An AT which either monitors the + mouse or synthesizes mouse events might need to know that, and possibly a talking + interface would even let the user know about it. It could also potentially be + useful to on screen keyboards or test tools since the information does indicate + something about the state of the interface, for example, code operating asynchronously + might need to wait for the armed state to change before doing something else. + +*/ +IA2_STATE_ARMED = 0x2, + +/** Indicates the user interface object corresponding to this object no longer exists. */ +IA2_STATE_DEFUNCT = 0x4, + +/** An object with this state has a caret and implements the IAccessibleText interface. + + Such fields may be read-only, so STATE_SYSTEM_READONLY is valid in combination + with IA2_STATE_EDITABLE. + +*/ +IA2_STATE_EDITABLE = 0x8, + +/** Indicates the orientation of this object is horizontal. */ +IA2_STATE_HORIZONTAL = 0x10, + +/** Indicates this object is minimized and is represented only by an icon. */ +IA2_STATE_ICONIFIED = 0x20, + +/** Indicates an input validation failure. */ +IA2_STATE_INVALID_ENTRY = 0x40, + +/** Indicates that this object manages its children. + + Note: Due to the fact that MSAA's WinEvents don't allow the active child index + to be passed on the IA2_EVENT_ACTIVE_DESCENDANT_CHANGED event, the manages + descendants scheme can't be used. Instead the active child object has to fire + MSAA's EVENT_OBJECT_FOCUS. In a future release a new event mechanism may be + added to provide for event specific data to be passed with the event. At that + time the IA2_EVENT_ACTIVE_DECENDENT_CHANGED event and + IA2_STATE_MANAGES_DESCENDANTS state would be useful. +*/ +IA2_STATE_MANAGES_DESCENDANTS = 0x80, + +/** Indicates that an object is modal. + + Modal objects have the behavior that something must be done with the object + before the user can interact with an object in a different window. +*/ +IA2_STATE_MODAL = 0x100, + +/** Indicates this text object can contain multiple lines of text. */ +IA2_STATE_MULTI_LINE = 0x200, + +/** Indicates this object paints every pixel within its rectangular region. */ +IA2_STATE_OPAQUE = 0x400, + +/** Indicates that user interaction is required. + + An example of when this state is used is when a field in a form must be filled + before a form can be processed. +*/ +IA2_STATE_REQUIRED = 0x800, + +/** Indicates an object which supports text selection. + + Note: This is different than MSAA STATE_SYSTEM_SELECTABLE. +*/ +IA2_STATE_SELECTABLE_TEXT = 0x1000, + +/** Indicates that this text object can contain only a single line of text. */ +IA2_STATE_SINGLE_LINE = 0x2000, + +/** Indicates that the accessible object is stale. + + This state is used when the accessible object no longer accurately + represents the state of the object which it is representing such as when an + object is transient or when an object has been or is in the process of being + destroyed or when the object's index in its parent has changed. +*/ +IA2_STATE_STALE = 0x4000, + +/** Indicates that the object implements autocompletion. + + This state indicates that a text control will respond to the input of + one or more characters and cause a sub-item to become selected. The + selection may also result in events fired on the parent object. +*/ +IA2_STATE_SUPPORTS_AUTOCOMPLETION = 0x8000, + +/** Indicates this object is transient. + + An object has this state when its parent object has the state ::IA2_STATE_MANAGES_DESCENDANTS. + For example, a list item object may be managed by its parent list object and may only + exist as long as the object is actually rendered. Similarly a table cell's accessible + object may exist only while the cell has focus. However, from the perspective of an + assistive technology a transient object behaves like a non-transient object. As a + result it is likely that this state is not of use to an assistive technology, but it + is provided in case an assistive technology determines that knowledge of the transient + nature of the object is useful and also for harmony with the Linux accessibility API. + + Also, see ::IA2_STATE_MANAGES_DESCENDANTS for more information. + */ +IA2_STATE_TRANSIENT = 0x10000, + +/** Indicates the orientation of this object is vertical. */ +IA2_STATE_VERTICAL = 0x20000, + +/** Indicates this object is checkable. + + The standard checkable objects are check boxes, radio buttons, check box menu + items, radio menu items, and toggle buttons. Since assistive technology will + determine that these objects are checkable via the object's role the checkable + state is not required. However, this state is necessary in those cases where + an object has a role which is not one of the previously mentioned roles. An + example is a table cell which indicates whether or not an email has an attachment, + whether or not an mail is considered spam, and whether or not an email has been read. + */ +IA2_STATE_CHECKABLE = 0x40000, + +/** Indicates this object is pinned. + + This state indicates that an object is fixed at a certain location. One example + is a browser tab that when pinned cannot be moved until unpinned. Another example + is a movable or floating object that when pinned remains in its pinned location + until being unpinned. + */ +IA2_STATE_PINNED = 0x80000 + +}; diff --git a/third_party/ia2/AccessibleTable.idl b/third_party/ia2/AccessibleTable.idl new file mode 100644 index 0000000..24df659 --- /dev/null +++ b/third_party/ia2/AccessibleTable.idl @@ -0,0 +1,551 @@ +/************************************************************************* + * + * File Name (AccessibleTable.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "Accessible2.idl"; +import "IA2CommonTypes.idl"; + +/** @brief This interface gives access to a two-dimensional table. + + Typically all accessible objects that represent cells or cell-clusters of a table + will be at the same time children of the table. In this case IAccessible2::indexInParent + will return the child index which then can be used when calling IAccessibleTable::rowIndex + and IAccessibleTable::columnIndex. + + However, in some cases that kind of implementation will not be possible. When + the table cells are not direct children of a table, the object representing + the cell can define a "table-cell-index" object attribute identifying the 0 + based table cell index. This object attribute is obtained by parsing the + attribute string returned by IAccessible2::attributes. The "table-cell-index" + attribute can be used just like a child index of the typical case. ATs should + first test for the presence of the "table-cell-index" attribute and if it is not + present then IAccessible2::indexInParent can be used as in the typical case + where cells are direct children of the table. + + The range of valid coordinates for this interface are implementation dependent. + However, that range includes at least the intervals from the from the first row + or column with the index 0 up to the last (but not including) used row or column + as returned by IAccessibleTable::nRows and IAccessibleTable::nColumns. + + Note that newer implementations are now using IAccessibleTable2 and IAccessibleTableCell + rather than this interface. +*/ +[object, uuid(35AD8070-C20C-4fb4-B094-F4F7275DD469)] +interface IAccessibleTable : IUnknown +{ + + /** @brief Returns the accessible object at the specified row and column in + the table. This object could be an IAccessible or an IAccessible2. + @param [in] row + The 0 based row index for which to retrieve the cell. + @param [in] column + The 0 based column index for which to retrieve the cell. + @param [out] accessible + If both row and column index are valid then the corresponding accessible + object is returned that represents the requested cell regardless of whether + the cell is currently visible (on the screen). + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is NULL + */ + [propget] HRESULT accessibleAt + ( + [in] long row, + [in] long column, + [out, retval] IUnknown **accessible + ); + + /** @brief Returns the caption for the table. The returned object could be + an IAccessible or an IAccessible2. + @param [out] accessible + If the table has a caption then a reference to it is returned, else a NULL + pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT caption + ( + [out, retval] IUnknown **accessible + ); + + /** @brief Translates the given row and column indexes into the corresponding cell index. + @param [in] rowIndex + 0 based row index for the cell. + @param [in] columnIndex + 0 based column index for the cell. + @param [out] cellIndex + Returns the 0 based index of the cell at the specified row and column indexes. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is 0 + @note The returned value is not necessarily a child index of the immediate parent. + In cases where the table cells are not direct children of the table the index + is actually the cell index, i.e. conceptually it's an index into a one dimensional + array of cells laid out in row order. + */ + [propget] HRESULT childIndex + ( + [in] long rowIndex, + [in] long columnIndex, + [out, retval] long *cellIndex + ); + + /** @brief Returns the description text of the specified column in the table. + @param [in] column + The 0 based index of the column for which to retrieve the description. + @param [out] description + Returns the description text of the specified column in the table if such a + description exists. Otherwise a NULL pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed, [out] value is NULL + */ + [propget] HRESULT columnDescription + ( + [in] long column, + [out, retval] BSTR *description + ); + + /** @brief Returns the number of columns occupied by the accessible object + at the specified row and column in the table. + + The result is greater than 1 if the specified cell spans multiple columns. + @param [in] row + 0 based row index of the accessible for which to return the column extent. + @param [in] column + 0 based column index of the accessible for which to return the column extent. + @param [out] nColumnsSpanned + Returns the 1 based column extent of the specified cell. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is 0 + */ + [propget] HRESULT columnExtentAt + ( + [in] long row, + [in] long column, + [out, retval] long *nColumnsSpanned + ); + + /** @brief Returns the column headers as an %IAccessibleTable object. + + Content and size of the returned table are implementation dependent. + @param [out] accessibleTable + The column header + @param [out] startingRowIndex + The 0 based row index where the header starts, usually 0. + @retval S_OK + @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively + */ + [propget] HRESULT columnHeader + ( + [out] IAccessibleTable **accessibleTable, + [out, retval] long *startingRowIndex + ); + + /** @brief Translates the given cell index into the corresponding column index. + @param [in] cellIndex + 0 based index of the cell in the parent or closest ancestor table. Typically this + is the value returned from IAccessible2::indexInParent, but in the case where the + table cells are not direct children of the table this is the cell index specified + by the "table-cell-index" object attribute obtained from parsing the attributes + string returned by calling IAccessible2::attributes on the cell object. + @param [out] columnIndex + Returns the 0 based column index of the cell of the specified child or the index of + the first column if the child spans multiple columns. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is 0 + */ + [propget] HRESULT columnIndex + ( + [in] long cellIndex, + [out, retval] long *columnIndex + ); + + /** @brief Returns the total number of columns in table + @param [out] columnCount + Number of columns in table (including columns outside the current viewport) + @retval S_OK + */ + [propget] HRESULT nColumns + ( + [out, retval] long *columnCount + ); + + /** @brief Returns the total number of rows in table + @param [out] rowCount + Number of rows in table (including rows outside the current viewport) + @retval S_OK + */ + [propget] HRESULT nRows + ( + [out, retval] long *rowCount + ); + + /** @brief Returns the total number of selected cells + @param [out] cellCount + Number of cells currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedChildren + ( + [out, retval] long *cellCount + ); + + /** @brief Returns the total number of selected columns + @param [out] columnCount + Number of columns currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedColumns + ( + [out, retval] long *columnCount + ); + + /** @brief Returns the total number of selected rows + @param [out] rowCount + Number of rows currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedRows + ( + [out, retval] long *rowCount + ); + + /** @brief Returns the description text of the specified row in the table. + @param [in] row + The 0 based index of the row for which to retrieve the description. + @param [out] description + Returns the description text of the specified row in the table if such a + description exists. Otherwise a NULL pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed, [out] value is NULL + */ + [propget] HRESULT rowDescription + ( + [in] long row, + [out, retval] BSTR *description + ); + + /** @brief Returns the number of rows occupied by the accessible object + at the specified row and column in the table. + + The result is greater than 1 if the specified cell spans multiple rows. + @param [in] row + 0 based row index of the accessible for which to return the row extent. + @param [in] column + 0 based column index of the accessible for which to return the row extent. + @param [out] nRowsSpanned + Returns the row extent of the specified cell. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is 0 + */ + [propget] HRESULT rowExtentAt + ( + [in] long row, + [in] long column, + [out, retval] long *nRowsSpanned + ); + + /** @brief Returns the row headers as an %IAccessibleTable object. + + Content and size of the returned table are implementation dependent. + @param [out] accessibleTable + The row header. + @param [out] startingColumnIndex + The 0 based column index where the header starts, usually 0. + @retval S_OK + @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively + */ + [propget] HRESULT rowHeader + ( + [out] IAccessibleTable **accessibleTable, + [out, retval] long *startingColumnIndex + ); + + /** @brief Translates the given cell index into a row index. + @param [in] cellIndex + 0 based index of the cell in the parent or closest ancestor table. Typically this + is the value returned from IAccessible2::indexInParent, but in the case where the + table cells are not direct children of the table this is the cell index specified + by the "table-cell-index" object attribute obtained from parsing the attributes + string returned by calling IAccessible2::attributes on the cell object. + @param [out] rowIndex + 0 based row index + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is 0 + */ + [propget] HRESULT rowIndex + ( + [in] long cellIndex, + [out, retval] long *rowIndex + ); + + /** @brief Returns a list of cell indexes currently selected (0 based). + @param [in] maxChildren + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] children + An array of cell indexes of selected cells (each index is 0 based), + allocated by the server. The client must free it with CoTaskMemFree. + @param [out] nChildren + The number of cell indexes returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedChildren + ( + [in] long maxChildren, + [out, size_is(,maxChildren), length_is(,*nChildren)] long **children, + [out, retval] long *nChildren + ); + + /** @brief Returns a list of column indexes currently selected (0 based). + @param [in] maxColumns + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] columns + An array of column indexes of selected columns (each index is 0 based), allocated + by the server. The client must free it with CoTaskMemFree. + @param [out] nColumns + The number of column indexes returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedColumns + ( + [in] long maxColumns, + [out, size_is(,maxColumns), length_is(,*nColumns)] long **columns, + [out, retval] long *nColumns + ); + + /** @brief Returns a list of row indexes currently selected (0 based). + @param [in] maxRows + This parameter is ignored. Refer to @ref _arrayConsideration + "Special Consideration when using Arrays" for more details. + @param [out] rows + An array of row indexes of selected rows (each index is 0 based), allocated + by the server. The client must free it with CoTaskMemFree. + @param [out] nRows + The number of row indexes returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedRows + ( + [in] long maxRows, + [out, size_is(,maxRows), length_is(,*nRows)] long **rows, + [out, retval] long *nRows + ); + + /** @brief Returns the summary description of the table. The returned object could be + an IAccessible or an IAccessible2. + @param [out] accessible + Returns a reference to an implementation dependent accessible object + representing the table's summary or a NULL pointer if the table + does not support a summary. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT summary + ( + [out, retval] IUnknown **accessible + ); + + /** @brief Returns a boolean value indicating whether the specified column is + completely selected. + @param [in] column + 0 based index of the column for which to determine whether it is selected. + @param [out] isSelected + Returns TRUE if the specified column is selected completely and FALSE otherwise. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE + */ + [propget] HRESULT isColumnSelected + ( + [in] long column, + [out, retval] boolean *isSelected + ); + + /** @brief Returns a boolean value indicating whether the specified row is completely + selected. + @param [in] row + 0 based index of the row for which to determine whether it is selected. + @param [out] isSelected + Returns TRUE if the specified row is selected completely and FALSE otherwise. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE + */ + [propget] HRESULT isRowSelected + ( + [in] long row, + [out, retval] boolean *isSelected + ); + + /** @brief Returns a boolean value indicating whether the specified cell is selected. + @param [in] row + 0 based index of the row for the cell to determine whether it is selected. + @param [in] column + 0 based index of the column for the cell to determine whether it is selected. + @param [out] isSelected + Returns TRUE if the specified cell is selected and FALSE otherwise. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] value is FALSE + */ + [propget] HRESULT isSelected + ( + [in] long row, + [in] long column, + [out, retval] boolean *isSelected + ); + + /** @brief Selects a row and unselects all previously selected rows. + @param [in] row + 0 based index of the row to be selected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT selectRow + ( + [in] long row + ); + + /** @brief Selects a column and unselects all previously selected columns. + @param [in] column + 0 based index of the column to be selected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT selectColumn + ( + [in] long column + ); + + /** @brief Unselects one row, leaving other selected rows selected (if any). + @param [in] row + 0 based index of the row to be unselected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT unselectRow + ( + [in] long row + ); + + /** @brief Unselects one column, leaving other selected columns selected (if any). + @param [in] column + 0 based index of the column to be unselected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT unselectColumn + ( + [in] long column + ); + + /** @brief Given a cell index, gets the row and column indexes and extents of a cell + and whether or not it is selected. + + This is a convenience function. It is not mandatory to implement it. + @param [in] index + 0 based index of this cell in the table. + @param [out] row + 0 based row index. + @param [out] column + 0 based column index. + @param [out] rowExtents + Number of cells spanned by this cell in this row. + @param [out] columnExtents + Number of cells spanned by this cell in this column. + @param [out] isSelected + Indicates if the specified cell is selected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed, [out] values are 0s and FALSE respectively + */ + [propget] HRESULT rowColumnExtentsAtIndex + ( + [in] long index, + [out] long *row, + [out] long *column, + [out] long *rowExtents, + [out] long *columnExtents, + [out, retval] boolean *isSelected + ); + + /** @brief Returns the type and extents describing how a table changed. + + Provided for use by the IA2_EVENT_TABLE_MODEL_CHANGED event handler. + + This data is only guaranteed to be valid while the thread notifying the event + continues. Once the handler has returned, the validity of the data depends on + how the server manages the life cycle of its objects. Also, note that the server + may have different life cycle management strategies for controls depending on + whether or not a control manages its children. Lists, trees, and tables can have + a large number of children and thus it's possible that the child objects for those + controls would only be created as needed. Servers should document their life cycle + strategy as this will be of interest to assistive technology or script engines + accessing data out of process or from other threads. Servers only need to save the + most recent row and column values associated with the change and a scope of the + entire application is adequate. + + @param [out] modelChange + A struct of (type(insert, delete, update), firstRow, lastRow, firstColumn, lastColumn). + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT modelChange + ( + [out, retval] IA2TableModelChange *modelChange + ); + +} diff --git a/third_party/ia2/AccessibleTable2.idl b/third_party/ia2/AccessibleTable2.idl new file mode 100644 index 0000000..d362929 --- /dev/null +++ b/third_party/ia2/AccessibleTable2.idl @@ -0,0 +1,377 @@ +/************************************************************************* + * + * File Name (AccessibleTable2.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2012 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "Accessible2.idl"; +import "IA2CommonTypes.idl"; + +/** @brief This interface gives access to a two-dimensional table. + + Please also refer to the IAccessibleTableCell interface. + + If you want to support older applications you should also support the + IAccessibleTable interface. +*/ +[object, uuid(6167f295-06f0-4cdd-a1fa-02e25153d869)] +interface IAccessibleTable2 : IUnknown +{ + + /** @brief Returns the accessible object at the specified row and column in + the table. This object could be an IAccessible or an IAccessible2. + @param [in] row + The 0 based row index for which to retrieve the cell. + @param [in] column + The 0 based column index for which to retrieve the cell. + @param [out] cell + If both row and column index are valid then the corresponding accessible + object is returned that represents the requested cell regardless of whether + the cell is currently visible (on the screen). + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT cellAt + ( + [in] long row, + [in] long column, + [out, retval] IUnknown **cell + ); + + /** @brief Returns the caption for the table. The returned object could be + an IAccessible or an IAccessible2. + @param [out] accessible + If the table has a caption then a reference to it is returned, else a NULL + pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @deprecated use a describedBy relation + */ + [propget] HRESULT caption + ( + [out, retval] IUnknown **accessible + ); + + /** @brief Returns the description text of the specified column in the table. + @param [in] column + The 0 based index of the column for which to retrieve the description. + @param [out] description + Returns the description text of the specified column in the table if such a + description exists. Otherwise a NULL pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT columnDescription + ( + [in] long column, + [out, retval] BSTR *description + ); + + + /** @brief Returns the total number of columns in table + @param [out] columnCount + Number of columns in table (including columns outside the current viewport) + @retval S_OK + */ + [propget] HRESULT nColumns + ( + [out, retval] long *columnCount + ); + + /** @brief Returns the total number of rows in table + @param [out] rowCount + Number of rows in table (including rows outside the current viewport) + @retval S_OK + */ + [propget] HRESULT nRows + ( + [out, retval] long *rowCount + ); + + /** @brief Returns the total number of selected cells + @param [out] cellCount + Number of cells currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedCells + ( + [out, retval] long *cellCount + ); + + /** @brief Returns the total number of selected columns + @param [out] columnCount + Number of columns currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedColumns + ( + [out, retval] long *columnCount + ); + + /** @brief Returns the total number of selected rows + @param [out] rowCount + Number of rows currently selected + @retval S_OK + */ + [propget] HRESULT nSelectedRows + ( + [out, retval] long *rowCount + ); + + /** @brief Returns the description text of the specified row in the table. + @param [in] row + The 0 based index of the row for which to retrieve the description. + @param [out] description + Returns the description text of the specified row in the table if such a + description exists. Otherwise a NULL pointer is returned. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT rowDescription + ( + [in] long row, + [out, retval] BSTR *description + ); + + /** @brief Returns a list of accessibles currently selected. + @param [out] cells + Pointer to an array of references to selected accessibles. The array is + allocated by the server with CoTaskMemAlloc and freed by the client with + CoTaskMemFree. + @param [out] nSelectedCells + The number of accessibles returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedCells + ( + [out, size_is(,*nSelectedCells)] IUnknown ***cells, + [out, retval] long *nSelectedCells + ); + + /** @brief Returns a list of column indexes currently selected (0 based). + @param [out] selectedColumns + A pointer to an array of column indexes of selected columns (each index is + 0 based). The array is allocated by the server with CoTaskMemAlloc and + freed by the client with CoTaskMemFree. + @param [out] nColumns + The number of column indexes returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedColumns + ( + [out, size_is(,*nColumns)] long **selectedColumns, + [out, retval] long *nColumns + ); + + /** @brief Returns a list of row indexes currently selected (0 based). + @param [out] selectedRows + An array of row indexes of selected rows (each index is 0 based). The array + is allocated by the server with CoTaskMemAlloc and freed by the client with + CoTaskMemFree. + @param [out] nRows + The number of row indexes returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there are none, [out] values are NULL and 0 respectively + */ + [propget] HRESULT selectedRows + ( + [out, size_is(,*nRows)] long **selectedRows, + [out, retval] long *nRows + ); + + /** @brief Returns the summary description of the table. The returned object could be + an IAccessible or an IAccessible2. + @param [out] accessible + Returns a reference to an implementation dependent accessible object + representing the table's summary or a NULL pointer if the table + does not support a summary. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + @deprecated Use the labeledBy relation + */ + [propget] HRESULT summary + ( + [out, retval] IUnknown **accessible + ); + + /** @brief Returns a boolean value indicating whether the specified column is + completely selected. + @param [in] column + 0 based index of the column for which to determine whether it is selected. + @param [out] isSelected + Returns TRUE if the specified column is selected completely and FALSE otherwise. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT isColumnSelected + ( + [in] long column, + [out, retval] boolean *isSelected + ); + + /** @brief Returns a boolean value indicating whether the specified row is completely + selected. + @param [in] row + 0 based index of the row for which to determine whether it is selected. + @param [out] isSelected + Returns TRUE if the specified row is selected completely and FALSE otherwise. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT isRowSelected + ( + [in] long row, + [out, retval] boolean *isSelected + ); + + /** @brief Selects a row and unselects all previously selected rows. + + The behavior should mimic that of the application, but for those applications + which do not have a means in the GUI to select a full row of cells the behavior + should be as follows: First any selected rows in the table are unselected. Then + the entire row of cells for the specified row is selected. If any of the + cells in the selected row span additional rows, the cells in those rows + are also selected. + @param [in] row + 0 based index of the row to be selected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT selectRow + ( + [in] long row + ); + + /** @brief Selects a column and unselects all previously selected columns. + + The behavior should mimic that of the application, but for those applications + which do not have a means in the GUI to select a full column of cells the behavior + should be as follows: First any selected columns in the table are unselected. Then + the entire column of cells for the specified column is selected. If any of the + cells in the selected column span additional columns, the cells in those columns + are also selected. + @param [in] column + 0 based index of the column to be selected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT selectColumn + ( + [in] long column + ); + + /** @brief Unselects one row, leaving other selected rows selected (if any). + + The behavior should mimic that of the application, but for those applications + which do not have a means in the GUI to unselect a full row of cells the + behavior should be as follows: The entire row of cells for the specified + row is unselected. If any of the cells in the selected row span additional + rows, the cells in those rows are also unselected. + @param [in] row + 0 based index of the row to be unselected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT unselectRow + ( + [in] long row + ); + + /** @brief Unselects one column, leaving other selected columns selected (if any). + + The behavior should mimic that of the application, but for those applications + which do not have a means in the GUI to unselect a full column of cells the + behavior should be as follows: The entire column of cells for the specified + column is unselected. If any of the cells in the selected column span additional + columns, the cells in those columns are also unselected. + @param [in] column + 0 based index of the column to be unselected. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT unselectColumn + ( + [in] long column + ); + + /** @brief Returns the type and extents describing how a table changed. + + Provided for use by the IA2_EVENT_TABLE_MODEL_CHANGED event handler. + + This data is only guaranteed to be valid while the thread notifying the event + continues. Once the handler has returned, the validity of the data depends on + how the server manages the life cycle of its objects. Also, note that the server + may have different life cycle management strategies for controls depending on + whether or not a control manages its children. Lists, trees, and tables can have + a large number of children and thus it's possible that the child objects for those + controls would only be created as needed. Servers should document their life cycle + strategy as this will be of interest to assistive technology or script engines + accessing data out of process or from other threads. Servers only need to save the + most recent row and column values associated with the change and a scope of the + entire application is adequate. + + @param [out] modelChange + A struct of (type(insert, delete, update), firstRow, lastRow, firstColumn, lastColumn). + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is NULL + */ + [propget] HRESULT modelChange + ( + [out, retval] IA2TableModelChange *modelChange + ); + +} diff --git a/third_party/ia2/AccessibleTableCell.idl b/third_party/ia2/AccessibleTableCell.idl new file mode 100644 index 0000000..022f524 --- /dev/null +++ b/third_party/ia2/AccessibleTableCell.idl @@ -0,0 +1,194 @@ +/************************************************************************* + * + * File Name (AccessibleTableCell.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "Accessible2.idl"; + +/** @brief This interface gives access to the cells of a two-dimensional table. + + Please also refer to the IAccessibleTable2 interface. + +*/ +[object, uuid(594116B1-C99F-4847-AD06-0A7A86ECE645)] +interface IAccessibleTableCell : IUnknown +{ + + /** @brief Returns the number of columns occupied by this cell accessible. + + The result is greater than 1 if the specified cell spans multiple columns. + @param [out] nColumnsSpanned + Returns the 1 based column extent of the specified cell. + @retval S_OK + */ + [propget] HRESULT columnExtent + ( + [out, retval] long *nColumnsSpanned + ); + + /** @brief Returns the column headers as an array of cell accessibles. + + @param [out] cellAccessibles + Pointer to an array of references to cell accessibles. The array is allocated + by the server. The client must free it with CoTaskMemFree. + @param [out] nColumnHeaderCells + The number of accessibles returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively + */ + [propget] HRESULT columnHeaderCells + ( + [out, size_is(,*nColumnHeaderCells)] IUnknown ***cellAccessibles, + [out, retval] long *nColumnHeaderCells + ); + + /** @brief Translates this cell accessible into the corresponding column index. + + @param [out] columnIndex + Returns the 0 based column index of the cell of the specified cell or the index of + the first column if the cell spans multiple columns. + @retval S_OK + */ + [propget] HRESULT columnIndex + ( + [out, retval] long *columnIndex + ); + + /** @brief Returns the number of rows occupied by this cell accessible. + + @param [out] nRowsSpanned + Returns the row extent of the specified cell. + @retval S_OK + */ + [propget] HRESULT rowExtent + ( + [out, retval] long *nRowsSpanned + ); + + /** @brief Returns the row headers as an array of cell accessibles. + + @param [out] cellAccessibles + Pointer to an array of references to cell accessibles. The array is allocated + by the server. The client must free it with CoTaskMemFree. + @param [out] nRowHeaderCells + The number of accessibles returned; the size of the returned array. + @retval S_OK + @retval S_FALSE if there is no header, [out] values are NULL and 0 respectively + */ + [propget] HRESULT rowHeaderCells + ( + [out, size_is(,*nRowHeaderCells)] IUnknown ***cellAccessibles, + [out, retval] long *nRowHeaderCells + ); + + /** @brief Translates this cell accessible into the corresponding row index. + + @param [out] rowIndex + Returns the 0 based row index of the specified cell or the index of + the first row if the cell spans multiple rows. + @retval S_OK + */ + [propget] HRESULT rowIndex + ( + [out, retval] long *rowIndex + ); + + /** @brief Returns a boolean value indicating whether this cell is selected. + + @param [out] isSelected + Returns TRUE if the specified cell is selected and FALSE otherwise. + @retval S_OK + */ + [propget] HRESULT isSelected + ( + [out, retval] boolean *isSelected + ); + + /** @brief Gets the row and column indexes and extents of this cell accessible + and whether or not it is selected. + + This is a convenience function. It is not mandatory to implement it. + @param [out] row + 0 based row index. + @param [out] column + 0 based column index. + @param [out] rowExtents + Number of cells spanned by this cell in this row. + @param [out] columnExtents + Number of cells spanned by this cell in this column. + @param [out] isSelected + Indicates if the specified cell is selected. + @retval S_OK + */ + [propget] HRESULT rowColumnExtents + ( + [out] long *row, + [out] long *column, + [out] long *rowExtents, + [out] long *columnExtents, + [out, retval] boolean *isSelected + ); + + /** @brief Returns a reference to the accessible of the containing table. + + @param [out] table + Returns a reference to the IUnknown of the containing table. + @retval S_OK + */ + [propget] HRESULT table + ( + [out, retval] IUnknown **table + ); + +} diff --git a/third_party/ia2/AccessibleText.idl b/third_party/ia2/AccessibleText.idl new file mode 100644 index 0000000..6b10e24 --- /dev/null +++ b/third_party/ia2/AccessibleText.idl @@ -0,0 +1,701 @@ +/************************************************************************* + * + * File Name (AccessibleText.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "IA2CommonTypes.idl"; + +/** A structure containing a substring and the start and end offsets in the enclosing string. + + IAccessibleText::newText and IAccessibleText::oldText return this struct. +*/ +typedef struct IA2TextSegment { + BSTR text; ///< A copy of a segment of text taken from an enclosing paragraph. + long start; ///< Index of the first character of the segment in the enclosing text. + long end; ///< Index of the character following the last character of the segment in the enclosing text. +} IA2TextSegment; + +/** This enum defines values which specify a text boundary type. + + IA2_TEXT_BOUNDARY_SENTENCE is optional. When a method doesn't implement this + method it must return S_FALSE. Typically this feature would not be implemented + by an application. However, if the application developer was not satisfied with + how screen readers have handled the reading of sentences this boundary type + could be implemented and screen readers could use the application's version of a + sentence rather than the screen reader's. + + The rest of the boundary types must be supported. + + This enum is used in IAccessibleText::textBeforeOffset, IAccessibleText::textAtOffset, + and IAccessibleText::textAfterOffset. +*/ + +enum IA2TextBoundaryType { + /** Typically, a single character is returned. In some cases more than one + character is returned, for example, when a document contains field data such + as a field containing a date, time, or footnote reference. In this case + the caret can move over several characters in one movement of the caret. + Note, that after the caret moves, the caret offset changes by the number of + characters in the field, e.g. by 8 characters in the following date: 03/26/07. + */ + IA2_TEXT_BOUNDARY_CHAR, + + /** The range provided matches the range observed when the application + processes the Ctrl + left arrow and Ctrl + right arrow key sequences. + Typically this is from the start of one word to the start of the next, but + various applications are inconsistent in the handling of the end of a line. + */ + IA2_TEXT_BOUNDARY_WORD, + + /** Range is from start of one sentence to the start of another sentence. + */ + IA2_TEXT_BOUNDARY_SENTENCE, + + /** Range is from start of one paragraph to the start of another paragraph. + */ + IA2_TEXT_BOUNDARY_PARAGRAPH, + + /** Range is from start of one line to the start of another line. This often + means that an end-of-line character will appear at the end of the range. + However in the case of some applications an end-of-line character indicates + the end of a paragraph and the lines composing the paragraph, other than + the last line, do not contain an end of line character. + */ + IA2_TEXT_BOUNDARY_LINE, + + /** Deprecated. Using this value will cause all text to be returned. + Note: IAccessibleText::text should be used instead. + */ + IA2_TEXT_BOUNDARY_ALL +}; + +/** @brief This interface gives read-only access to text. + + The %IAccessibleText interface should be implemented by all components + that present textual information on the display like buttons, + text entry fields, or text portions of the document window. The interface + provides access to the text's content, attributes, and spatial location. + However, text can not be modified with this interface. That is the task + of the IAccessibleEditableText interface. + + The text length, i.e. the number of characters in the text, is + returned by IAccessibleText::nCharacters. All methods that operate + on particular characters (e.g. IAccessibleText::textAtOffset) use character + indices from 0 to length-1. All methods that operate on character positions + (e.g. IAccessibleText::text) use indices from 0 to length. + + Please note that accessible text does not necessarily support selection. + In this case it should behave as if there where no selection. An empty + selection is used for example to express the current cursor position. + + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + + E_FAIL is returned in the following cases + @li endOffset < startOffset + @li endoffset > length +*/ +[object, uuid(24FD2FFB-3AAD-4a08-8335-A3AD89C0FB4B)] +interface IAccessibleText : IUnknown +{ + + /** @brief Adds a text selection + @param [in] startOffset + Starting offset ( 0 based). + @param [in] endOffset + Offset of first character after new selection (0 based). + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + */ + HRESULT addSelection + ( + [in] long startOffset, + [in] long endOffset + ); + + /** @brief Returns text attributes. + @param [in] offset + Text offset (0 based). Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @param [out] startOffset + The starting offset of the character range over which all text attributes match + those of offset. (0 based) + @param [out] endOffset + The offset of the first character past the character range over which all text + attributes match those of offset. (0 based) + @param [out] textAttributes + A string of attributes describing the text. The attributes are described in the +
+ text attributes specification. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] values are 0s and NULL respectively + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT attributes + ( + [in] long offset, + [out] long *startOffset, + [out] long *endOffset, + [out, retval] BSTR *textAttributes + ); + + /** @brief Returns the position of the caret. + + Returns the 0-based offset of the caret within the text. If the text is + implemented as a tree of text objects with embed characters in higher levels + representing substrings of child text objects and the caret is in one of the + child text objects, then the offset in the higher level text object would be + at the embed character representing child text object that contains the caret. + + For example, if the string "one two three" is implemented as a two text objects, + with a top level text object containing an embed character "one ? three" and a + child text object containing "two" and if the caret is in the descendant object + just before the 'o' in "two", then: +
    +
  • the caretOffset for the "one ? three" object would be 4, matching the embed character
  • +
  • the caretOffset for "two" would be 2, matching the "o"
  • +
+ The caret position/offset is that of the character logically following it, e.g. + to the right of it in a left to right language, or to the left of it in a right + to left language. + @param [out] offset + The returned offset is relative to the text represented by this object. + @retval S_OK + @retval S_FALSE if the caret is not currently active on this object, i.e. the + caret is located on some other object. The returned offset value will be -1. + @note S_FALSE (and an offset of -1) will not be returned if the caret is somewhere + in the text object or one of its descendants. + */ + [propget] HRESULT caretOffset + ( + [out, retval] long *offset + ); + + + /** @brief Returns the bounding box of the specified position. + + The virtual character after the last character of the represented + text, i.e. the one at position length is a special case. It represents the + current input position and will therefore typically be queried by AT more + often than other positions. Because it does not represent an existing character + its bounding box is defined in relation to preceding characters. It should be + roughly equivalent to the bounding box of some character when inserted at the + end of the text. Its height typically being the maximal height of all the + characters in the text or the height of the preceding character, its width being + at least one pixel so that the bounding box is not degenerate. + + Note that the index 'length' is not always valid. Whether it is or not is + implementation dependent. It typically is when text is editable or otherwise + when on the screen the caret can be placed behind the text. You can be sure + that the index is valid after you have received a ::IA2_EVENT_TEXT_CARET_MOVED + event for this index. + @param [in] offset + Index of the character for which to return its bounding box. The valid range + is 0..length. Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @param [in] coordType + Specifies if the coordinates are relative to the screen or to the parent window. + @param [out] x + X coordinate of the top left corner of the bounding box of the referenced character. + @param [out] y + Y coordinate of the top left corner of the bounding box of the referenced character. + @param [out] width + Width of the bounding box of the referenced character. + @param [out] height + Height of the bounding box of the referenced character. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT characterExtents + ( + [in] long offset, + [in] enum IA2CoordinateType coordType, + [out] long *x, + [out] long *y, + [out] long *width, + [out, retval] long *height + ); + + + /** @brief Returns the number of active non-contiguous selections + @param [out] nSelections + @retval S_OK + */ + [propget] HRESULT nSelections + ( + [out, retval] long *nSelections + ); + + /** @brief Returns the text position for the specified screen position. + + Given a point return the zero-based index of the character under that + point. The same functionality could be achieved by using the bounding + boxes for each character as returned by IAccessibleText::characterExtents. + The method IAccessibleText::offsetAtPoint, however, can be implemented + more efficiently. + + @param [in] x + The position's x value for which to look up the index of the character that + is rendered on to the display at that point. + @param [in] y + The position's y value for which to look up the index of the character that + is rendered on to the display at that point. + @param [in] coordType + Screen coordinates or window coordinates. + @param [out] offset + Index of the character under the given point or -1 if the point + is invalid or there is no character under the point. + @retval S_OK + @retval S_FALSE if nothing to return, [out] value is -1 + + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT offsetAtPoint + ( + [in] long x, + [in] long y, + [in] enum IA2CoordinateType coordType, + [out, retval] long *offset + ); + + /** @brief Returns the character offsets of Nth active text selection + + Returns the 0-based starting and ending offsets of the Nth selection. If the + text is implemented as a tree of text objects with embed characters in higher + levels representing substrings of child text objects, consider the following. + If the starting selection offset is in one of the child text objects, then the + starting offset in the higher level text object would be at the embed character + representing the child text object that contains the starting selection offset. + If the ending selection offset is in one of the child text objects, then the + ending offset in the higher level text object would be just after the embed + character representing the child text object that contains the ending selection + offset. + + For example, if the string "one two three" is implemented as a two text objects, + with a top level text object containing an embed character "one ? three" and a + child text object containing "two" and if the selection is the string "two" then: +
    +
  • the startOffset for the "one ? three" object would be 4, matching the embed character and the endOffset would be 5.
  • +
  • the startOffset for the "two" object would be 0, and the endOffset would be 3
  • +
+ Selection offsets are that of the character logically following it, e.g. + to the right of it in a left to right language or to the left of it in a right to left language. + @param [in] selectionIndex + Index of selection (0 based). + @param [out] startOffset + 0 based offset of first selected character + @param [out] endOffset + 0 based offset of one past the last selected character. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT selection + ( + [in] long selectionIndex, + [out] long *startOffset, + [out, retval] long *endOffset + ); + + /** @brief Returns the substring between the two given indices. + + The substring starts with the character at startOffset (inclusive) and up to + the character at endOffset (exclusive), if startOffset is less or equal + endOffset. If endOffset is lower than startOffset, the result is the same + as a call with the two arguments being exchanged. + + The whole text can be requested by passing the indices zero and + IAccessibleText::nCharacters. If both indices have the same value, an empty + string is returned. + @param [in] startOffset + Index of the first character to include in the returned string. The valid range + is 0..length. + @param [in] endOffset + Index of the last character to exclude in the returned string. The valid range + is 0..length. + @param [out] text + Returns the substring starting with the character at startOffset (inclusive) + and up to the character at endOffset (exclusive), if startOffset is less than + or equal to endOffset. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note + @li The returned string may be longer than endOffset-startOffset bytes if text + contains multi-byte characters. + @li Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + */ + [propget] HRESULT text + ( + [in] long startOffset, + [in] long endOffset, + [out, retval] BSTR *text + ); + + /** @brief Returns a text portion before the given position. + + Returns the substring of the specified text type that is located before the + given character and does not include it. The result of this method should be + same as a result for IAccessibleText::textAtOffset with a suitably decreased + index value. + + For example, if text type is ::IA2_TEXT_BOUNDARY_WORD, then the complete + word that is closest to and located before offset is returned. + + If the index is valid, but no text is found, S_FALSE is returned along with out + values of 0, 0, and a NULL pointer. This would happen for boundary types other + than character when the text consists entirely of whitespace. + + @param [in] offset + Index of the character for which to return the text part before it. The index + character will not be part of the returned string. The valid range is 0..length. + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @param [in] boundaryType + The type of the text portion to return. See ::IA2TextBoundaryType for the + complete list. + @param [out] startOffset + 0 based offset of first character. + @param [out] endOffset + 0 based offset of one past the last character. + @param [out] text + Returns the requested text portion. This portion may be empty or invalid when + no appropriate text portion is found or text type is invalid. + @retval S_OK + @retval S_FALSE if the requested boundary type is not implemented, such as + ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; + [out] values are 0s and NULL respectively + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT textBeforeOffset + ( + [in] long offset, + [in] enum IA2TextBoundaryType boundaryType, + [out] long *startOffset, + [out] long *endOffset, + [out, retval] BSTR *text + ); + + /** @brief Returns a text portion after the given position. + + Returns the substring of the specified text type that is located after the + given character and does not include it. The result of this method should be + same as a result for IAccessibleText::textAtOffset with a suitably increased + index value. + + For example, if text type is ::IA2_TEXT_BOUNDARY_WORD, then the complete + word that is closest to and located after offset is returned. + + If the index is valid, but no text is found, S_FALSE is returned along with out + values of 0, 0, and a NULL pointer. This would happen for boundary types other + than character when the text consists entirely of whitespace. + + @param [in] offset + Index of the character for which to return the text part after it. The index + character will not be part of the returned string. The valid range is 0..length. + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @param [in] boundaryType + The type of the text portion to return. See ::IA2TextBoundaryType for the complete + list. + @param [out] startOffset + 0 based offset of first character. + @param [out] endOffset + 0 based offset of one past the last character. + @param [out] text + Returns the requested text portion. This portion may be empty or invalid when + no appropriate text portion is found or text type is invalid. + @retval S_OK + @retval S_FALSE if the requested boundary type is not implemented, such as + ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; + [out] values are 0s and NULL respectively + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT textAfterOffset + ( + [in] long offset, + [in] enum IA2TextBoundaryType boundaryType, + [out] long *startOffset, + [out] long *endOffset, + [out, retval] BSTR *text + ); + + /** @brief Returns a text portion that spans the given position. + + Returns the substring defined by the specified boundary type at the specified + offset. Refer to IA2TextBoundaryType for more details. + + For the word boundary type the returned string will contain the word at the + offset if the offset is inside a word and will contain the word before the + offset if the offset is not inside a word. All offsets from the first to the + last characters of a word are considered inside the word. Boundary types of + sentence and paragraph should exhibit similar behavior. + + If the index is valid, but no text is found, S_FALSE is returned along with out + values of 0, 0, and a NULL pointer. This would happen for boundary types other + than character when the text consists entirely of whitespace. + + @param [in] offset + Index of the character for which to return the text part it belongs to. The valid + range is 0..length. + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @param [in] boundaryType + The type of the text portion to return. See ::IA2TextBoundaryType for the complete + list. + @param [out] startOffset + 0 based offset of first character. + @param [out] endOffset + 0 based offset of one past the last character. + @param [out] text + Returns the requested text portion. This portion may be empty or invalid when + no appropriate text portion is found or text type is invalid. + @retval S_OK + @retval S_FALSE if the requested boundary type is not implemented, such as + ::IA2_TEXT_BOUNDARY_SENTENCE, or if there is nothing to return; + [out] values are 0s and NULL respectively + @retval E_INVALIDARG if bad [in] passed + */ + [propget] HRESULT textAtOffset + ( + [in] long offset, + [in] enum IA2TextBoundaryType boundaryType, + [out] long *startOffset, + [out] long *endOffset, + [out, retval] BSTR *text + ); + + /** @brief Unselects a range of text. + @param [in] selectionIndex + Index of selection to remove (0 based). + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT removeSelection + ( + [in] long selectionIndex + ); + + /** @brief Sets the position of the caret. + + The caret position/offset is that of the character logically following it, + e.g. to the right of it in a left to right language. + + Setting the caret position may or may not alter the current selection. A + change of the selection is notified to the accessibility event listeners with + an ::IA2_EVENT_TEXT_SELECTION_CHANGED event. + + When the new caret position differs from the old one (which, of course, is the + standard case) this is notified to the accessibility event listeners with an + ::IA2_EVENT_TEXT_CARET_MOVED event. + @param [in] offset + The new index of the caret. This caret is actually placed to the left side of + the character with that index. An index of 0 places the caret so that the next + insertion goes before the first character. An index of IAccessibleText::nCharacters + leads to insertion after the last character. Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + @retval S_OK + @retval E_FAIL if the caret cannot be set + @retval E_INVALIDARG if bad [in] passed + */ + HRESULT setCaretOffset + ( + [in] long offset + ); + + /** @brief Changes the bounds of an existing selection. + @param [in] selectionIndex + Index of selection to change (0 based) + @param [in] startOffset + New starting offset (0 based) + @param [in] endOffset + New ending offset (0 based) - the offset of the character just past the last character of the selection. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + */ + HRESULT setSelection + ( + [in] long selectionIndex, + [in] long startOffset, + [in] long endOffset + ); + + /** @brief Returns total number of characters. + + Note that this may be different than the total number of bytes required to store the + text, if the text contains multi-byte characters. + @param [out] nCharacters + @retval S_OK + */ + [propget] HRESULT nCharacters + ( + [out, retval] long *nCharacters + ); + + /** @brief Makes a specific part of string visible on screen. + @param [in] startIndex + 0 based character offset. + @param [in] endIndex + 0 based character offset - the offset of the character just past the last character of the string. + @param [in] scrollType + Defines where the object should be placed on the screen. + @retval S_OK + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + */ + HRESULT scrollSubstringTo + ( + [in] long startIndex, + [in] long endIndex, + [in] enum IA2ScrollType scrollType + ); + + /** @brief Moves the top left of a substring to a specified location. + + @param [in] startIndex + 0 based character offset. + @param [in] endIndex + 0 based character offset - the offset of the character just past the last character of the string. + @param [in] coordinateType + Specifies whether the coordinates are relative to the screen or the parent object. + @param [in] x + Defines the x coordinate. + @param [in] y + Defines the y coordinate. + @retval S_OK + @retval S_FALSE if the object is already at the specified location. + @retval E_INVALIDARG if bad [in] passed + @note Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for information about special offsets that can be used in %IAccessibleText methods. + */ + HRESULT scrollSubstringToPoint + ( + [in] long startIndex, + [in] long endIndex, + [in] enum IA2CoordinateType coordinateType, + [in] long x, + [in] long y + ); + + /** @brief Returns any inserted text. + + Provided for use by the ::IA2_EVENT_TEXT_INSERTED and ::IA2_EVENT_TEXT_UPDATED + event handlers. + + This data is only guaranteed to be valid while the thread notifying the event + continues. Once the handler has returned, the validity of the data depends on + how the server manages the life cycle of its objects. Also, note that the server + may have different life cycle management strategies for controls depending on + whether or not a control manages its children. Lists, trees, and tables can have + a large number of children and thus it's possible that the child objects for those + controls would only be created as needed. Servers should document their life cycle + strategy as this will be of interest to assistive technology or script engines + accessing data out of process or from other threads. Servers only need to save the + last inserted block of text and a scope of the entire application is adequate. + + @param [out] newText + The text that was just inserted. + @retval S_OK + @retval S_FALSE If there is nothing to return, the values of IA2TextSegment + struct are set as follows: text = NULL, start = 0, end = 0. + + */ + [propget] HRESULT newText + ( + [out, retval] IA2TextSegment *newText + ); + + /** @brief Returns any removed text. + + Provided for use by the IA2_EVENT_TEXT_REMOVED/UPDATED event handlers. + + This data is only guaranteed to be valid while the thread notifying the event + continues. Once the handler has returned, the validity of the data depends on + how the server manages the life cycle of its objects. Also, note that the server + may have different life cycle management strategies for controls depending on + whether or not a control manages its children. Lists, trees, and tables can have + a large number of children and thus it's possible that the child objects for those + controls would only be created as needed. Servers should document their life cycle + strategy as this will be of interest to assistive technology or script engines + accessing data out of process or from other threads. Servers only need to save the + last removed block of text and a scope of the entire application is adequate. + + @param [out] oldText + The text that was just removed. + @retval S_OK + @retval S_FALSE If there is nothing to return, the values of IA2TextSegment + struct are set as follows: text = NULL, start = 0, end = 0. + */ + [propget] HRESULT oldText + ( + [out, retval] IA2TextSegment *oldText + ); + +} diff --git a/third_party/ia2/AccessibleText2.idl b/third_party/ia2/AccessibleText2.idl new file mode 100644 index 0000000..bc75cdd --- /dev/null +++ b/third_party/ia2/AccessibleText2.idl @@ -0,0 +1,98 @@ +/************************************************************************* + * + * File Name (AccessibleText2.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2013 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "IA2CommonTypes.idl"; +import "AccessibleText.idl"; + +/** @brief This interface gives read-only access to text. + + The %IAccessibleText2 interface extends the functionality of the + %IAccessibleText interface. +*/ +[object, uuid(9690A9CC-5C80-4DF5-852E-2D5AE4189A54)] +interface IAccessibleText2 : IAccessibleText +{ + + /** @brief Returns the range and of the specified set of attributes. + + Return the range (start and end offsets) and text attributes that correspond + to the given attributes filter at the given offset. + + @param [in] offset + The offset at which to search for the attributes specified in the filter. + @param [in] filter + The requested attribute names. The filter format is "attribute1, attribute2". + @param [out] startOffset + The starting (0-based) offset of the text containing the specified attributes. + @param [out] endOffset + The (0-based) offset one past the last character of the text containing the + specified attributes. + @param [out] attributeValues + The values of the requested attributes. + @retval S_OK + @retval S_FALSE if nothing to return, [out] values are -1, -1, NULL respectively. + @retval E_INVALIDARG if bad [in] passed. + */ + [propget] HRESULT attributeRange + ( + [in] long offset, + [in] BSTR filter, + [out] long *startOffset, + [out] long *endOffset, + [out, retval] BSTR *attributeValues + ); + +} diff --git a/third_party/ia2/AccessibleTextSelectionContainer.idl b/third_party/ia2/AccessibleTextSelectionContainer.idl new file mode 100644 index 0000000..2f27c34 --- /dev/null +++ b/third_party/ia2/AccessibleTextSelectionContainer.idl @@ -0,0 +1,139 @@ +/************************************************************************* + * + * File Name (accessibleTextSelectionContainer.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2022 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; +import "AccessibleText.idl"; + +/** + This structure represents a single text selection within an accessibility + subtree. This could be within a document, or the subtree of a document. This + selection is defined by two points in the content, where each one is defined by + an accessible object supporting the IAccessibleTextInterface and an + IAccessibleText character offset relative to it. + + The end object must appear after the start object in the accessibility tree, + i.e. the end object must be reachable from the start object by navigating + forward (next, first child etc). + + This struct also contains a `startIsActive` boolean, to communicate if the + start of the selection is the active point or not. + + The active point corresponds to the user's focus or point of interest. The user + moves the active point to expand or collapse the range. The anchor point is + the other point of the range and typically remains constant. In most cases, + anchor is the start of the range and active is the end. However, when selecting + backwards (e.g. pressing shift+left arrow in a text field), the start of the + range is the active point, as the user moves this to manipulate the selection. + */ +typedef struct IA2TextSelection { + IAccessibleText* startObj; + long startOffset; + IAccessibleText* endObj; + long endOffset; + boolean startIsActive; +} IA2TextSelection; + +/** + @brief an interface to get and set text selections in a document. + this interface can be supported on any object that also supports the + IAccessibleText and/or IAccessibleHypertext interfaces. This could be a + document, any subtree of a document, or a text input control. +*/ +[object, uuid(2118B599-733F-43D0-A569-0B31D125ED9A)] +interface IAccessibleTextSelectionContainer : IUnknown +{ + /** + @brief Returns an array of selections within this subtree. + @param [out] selections + The array of selections, allocated by the server. The client must free it + with CoTaskMemFree. The selections returned will be cropped to fit entirely + within this subtree, i.e. to only reference descendant objects, even if the + physical selection may reach outside of this subtree. In the case where the + physical selection is entirely outside the subtree, an empty array will be + returned. + @param [out] nSelections + the array length + @retval S_OK + @retval S_FALSE returned if there are no selections within this subtree, or + the physical selection is entirely outside of this subtree. + */ + [propget] HRESULT selections + ( + [out, size_is(,*nSelections)] IA2TextSelection **selections, + [out, retval] long *nSelections + ); + + /** + @brief makes 1 or more selections within this subtree denoted by the given + array of IA2TextSelections. + Any existing physical selection (inside or outside this subtree) is replaced + by the new selections. All objects within the given selection ranges must be + descendants of this subtree, otherwise E_INVALIDARG will be returned. + @param [in] nSelections + The length of the array containing the selection ranges. + @param [in] selections + The array of selection ranges. + @retval S_OK Returned if the selections were made successfully. + @retval S_FALSE Returned if the selections could not be made. + @retval E_INVALIDARG Returned if any of the input arguments are invalid, or + any of the objects in the given ranges are outside of this subtree. + */ + HRESULT setSelections + ( + [in] long nSelections, + [in, size_is(nSelections)] IA2TextSelection* selections + ); + +} diff --git a/third_party/ia2/AccessibleValue.idl b/third_party/ia2/AccessibleValue.idl new file mode 100644 index 0000000..c8b4b69 --- /dev/null +++ b/third_party/ia2/AccessibleValue.idl @@ -0,0 +1,136 @@ +/************************************************************************* + * + * File Name (AccessibleValue.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + +import "objidl.idl"; +import "oaidl.idl"; +import "oleacc.idl"; + +/** @brief This interface gives access to a single numerical value. + + The %IAccessibleValue interface represents a single numerical value and should + be implemented by any class that supports numerical value like progress bars + and spin boxes. This interface lets you access the value and its upper and + lower bounds. +*/ +[object, uuid(35855B5B-C566-4fd0-A7B1-E65465600394)] +interface IAccessibleValue : IUnknown +{ + + /** @brief Returns the value of this object as a number. + + The exact return type is implementation dependent. Typical types are long and + double. + @param [out] currentValue + Returns the current value represented by this object. See the section about + @ref _variants "VARIANTs" for additional information. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY + */ + [propget] HRESULT currentValue + ( + [out, retval] VARIANT *currentValue + ); + + /** @brief Sets the value of this object to the given number. + + The argument is clipped to the valid interval whose upper and lower + bounds are returned by the methods IAccessibleValue::maximumValue and + IAccessibleValue::minimumValue, i.e. if it is lower than the minimum + value the new value will be the minimum and if it is greater than the + maximum then the new value will be the maximum. + + @param [in] value + The new value represented by this object. The set of admissible types for + this argument is implementation dependent. + @retval S_OK + */ + HRESULT setCurrentValue + ( + [in] VARIANT value + ); + + /** @brief Returns the maximal value that can be represented by this object. + + The type of the returned value is implementation dependent. It does not have + to be the same type as that returned by method IAccessibleValue::currentValue. + + @param [out] maximumValue + Returns the maximal value in an implementation dependent type. If this object + has no upper bound then an empty object is returned. See the section about + @ref _variants "VARIANTs" for additional information. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY + */ + [propget] HRESULT maximumValue + ( + [out, retval] VARIANT *maximumValue + ); + + /** @brief Returns the minimal value that can be represented by this object. + + The type of the returned value is implementation dependent. It does not have + to be the same type as that returned by method IAccessibleValue::currentValue. + + @param [out] minimumValue + Returns the minimal value in an implementation dependent type. If this object + has no lower bound then an empty object is returned. See the section about + @ref _variants "VARIANTs" for additional information. + @retval S_OK + @retval S_FALSE if there is nothing to return, [out] value is a VARIANT with vt = VT_EMPTY + */ + [propget] HRESULT minimumValue + ( + [out, retval] VARIANT *minimumValue + ); + +}; diff --git a/third_party/ia2/IA2CommonTypes.idl b/third_party/ia2/IA2CommonTypes.idl new file mode 100644 index 0000000..2ed7129 --- /dev/null +++ b/third_party/ia2/IA2CommonTypes.idl @@ -0,0 +1,191 @@ +/************************************************************************* + * + * File Name (IA2CommonTypes.idl) + * + * IAccessible2 IDL Specification + * + * Copyright (c) 2007, 2010 Linux Foundation + * Copyright (c) 2006 IBM Corporation + * Copyright (c) 2000, 2006 Sun Microsystems, Inc. + * All rights reserved. + * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the Linux Foundation nor the names of its + * contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This BSD License conforms to the Open Source Initiative "Simplified + * BSD License" as published at: + * http://www.opensource.org/licenses/bsd-license.php + * + * IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 + * mark may be used in accordance with the Linux Foundation Trademark + * Policy to indicate compliance with the IAccessible2 specification. + * + ************************************************************************/ + + /** These constants control the scrolling of an object or substring into a window. + + This enum is used in IAccessible2::scrollTo and IAccessibleText::scrollSubstringTo. +*/ +enum IA2ScrollType { + + /** Scroll the top left corner of the object or substring such that the top left + corner (and as much as possible of the rest of the object or substring) is within + the top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_TOP_LEFT, + + /** Scroll the bottom right corner of the object or substring such that the bottom right + corner (and as much as possible of the rest of the object or substring) is within + the top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_BOTTOM_RIGHT, + + /** Scroll the top edge of the object or substring such that the top edge + (and as much as possible of the rest of the object or substring) is within the + top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_TOP_EDGE, + + /** Scroll the bottom edge of the object or substring such that the bottom edge + (and as much as possible of the rest of the object or substring) is within the + top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_BOTTOM_EDGE, + + /** Scroll the left edge of the object or substring such that the left edge + (and as much as possible of the rest of the object or substring) is within the + top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_LEFT_EDGE, + + /** Scroll the right edge of the object or substring such that the right edge + (and as much as possible of the rest of the object or substring) is within the + top level window. In cases where the entire object or substring fits within + the top level window, the placement of the object or substring is dependent on + the application. For example, the object or substring may be scrolled to the + closest edge, the furthest edge, or midway between those two edges. In cases + where there is a hierarchy of nested scrollable controls, more than one control + may have to be scrolled. + */ + IA2_SCROLL_TYPE_RIGHT_EDGE, + + /** Scroll the object or substring such that as much as possible of the + object or substring is within the top level window. The placement of + the object is dependent on the application. For example, the object or + substring may be scrolled to the closest edge, the furthest edge, or midway + between those two edges. + */ + IA2_SCROLL_TYPE_ANYWHERE +}; + +/** These constants define which coordinate system a point is located in. + + This enum is used in IAccessible2::scrollToPoint, IAccessibleImage::imagePosition, + IAccessibleText::characterExtents, and IAccessibleText::offsetAtPoint, and + IAccessibleText::scrollSubstringToPoint. +*/ +enum IA2CoordinateType { + + /// The coordinates are relative to the screen. + IA2_COORDTYPE_SCREEN_RELATIVE, + + /** The coordinates are relative to the upper left corner of the bounding box + of the immediate parent. + */ + IA2_COORDTYPE_PARENT_RELATIVE + +}; + +/** Special offsets for use in IAccessibleText and IAccessibleEditableText methods + + Refer to @ref _specialOffsets + "Special Offsets for use in the IAccessibleText and IAccessibleEditableText Methods" + for more information. +*/ +enum IA2TextSpecialOffsets { + IA2_TEXT_OFFSET_LENGTH = -1, /**< This offset is equivalent to the length of the string. It eliminates + the need to call IAccessibleText::nCharacters. */ + IA2_TEXT_OFFSET_CARET = -2 /**< This offset signifies that the text related to the physical location + of the caret should be used. */ +}; + +/** These constants specify the kind of change made to a table. + + This enum is used in the IA2TableModelChange struct which in turn is used by + IAccessibleTable::modelChange and IAccessibleTable2::modelChange. +*/ +enum IA2TableModelChangeType { + IA2_TABLE_MODEL_CHANGE_INSERT, // = 0; + IA2_TABLE_MODEL_CHANGE_DELETE, + IA2_TABLE_MODEL_CHANGE_UPDATE +}; + +/** A structure defining the type of and extents of changes made to a table + + IAccessibleTable::modelChange and IAccessibleTable2::modelChange return this struct. + In the case of an insertion or change the row and column offsets define the boundaries + of the inserted or changed subtable after the operation. In the case of a deletion + the row and column offsets define the boundaries of the subtable being removed before + the removal. +*/ +typedef struct IA2TableModelChange { + enum IA2TableModelChangeType type; // insert, delete, update + long firstRow; ///< 0 based, inclusive + long lastRow; ///< 0 based, inclusive + long firstColumn; ///< 0 based, inclusive + long lastColumn; ///< 0 based, inclusive +} IA2TableModelChange; diff --git a/third_party/ia2/README.md b/third_party/ia2/README.md new file mode 100644 index 0000000..e77c455 --- /dev/null +++ b/third_party/ia2/README.md @@ -0,0 +1,13 @@ +# IAccessible2 interface definitions + +These IDL files define the IAccessible2 1.3 interfaces used by +`browser_worker.cpp`. They are unmodified copies of the `api/` directory of +the IAccessible2 specification, taken from NVDA's `include/ia2` checkout at +revision `250802a2772676581195fd6674fcb0dec6e5aaab` (upstream: +). `IA2TypeLibrary.idl` and +`api_all_headers.idl` are omitted because the build generates one header per +interface instead. + +Each file carries its BSD-style license from the Linux Foundation, IBM and Sun +Microsystems; that license is compatible with this project's LGPL. The build +runs `widl` on these files; no generated output is committed.