1
0
Fork 0

Another rewrite

This commit is contained in:
Duncan Ogilvie 2026-07-21 12:39:24 +02:00
parent 8ab705c574
commit 8b918baf24
18 changed files with 612 additions and 73 deletions

View File

@ -23,9 +23,10 @@ The script activates every minidump tab and covers every interface supplied by
| Disassembly | `AccessibleDisassembly` |
| Registers | `AccessibleRegistersView` |
This also exercises `AccessibleAbstractTableView`, its virtual data cells and
column headers, native parent/child navigation, names, bounds, focus, selection,
and model resets caused by scrolling. The Threads `QTableWidget` is captured as
This also exercises `AccessibleAbstractTableView`, its virtual data cells,
column headers, dedicated hidden row headers, native parent/child navigation,
names, bounds, focus, selection, register visual order, and model resets caused
by scrolling. The Threads `QTableWidget` is captured as
a native Qt-table comparison.
The first runs intentionally produce rich platform-specific captures. Use
@ -132,7 +133,9 @@ The output directory contains:
- `minidump.stdout.log` and `minidump.stderr.log`.
xa11y currently normalizes Qt/UIA DataItem cells as `table_row` on Windows.
Linux exposes the corresponding objects directly as `table_cell`; macOS exposes
The action check recognizes those native DataItems so this known normalization
bug does not prevent testing real cell selection. Linux exposes the
corresponding objects directly as `table_cell`; macOS exposes
`AXRow` containers with nested `AXCell`/`table_cell` objects. The underlying
x64dbg child layout deliberately follows Qt's native accessible table contract;
the capture records both normalized roles and native `raw` fields so these

View File

@ -32,6 +32,7 @@ class ControlSpec:
expected_names: tuple[str, ...]
minimum_children: int
minimum_named_children: int = 1
expected_order: tuple[str, ...] = ()
exercise_scroll: bool = False
exercise_selection: bool = False
@ -99,6 +100,16 @@ TAB_SPECS = (
"list[name='Registers']",
("RAX", "RSP", "RIP"),
10,
expected_order=(
"RAX",
"RBX",
"RCX",
"RDX",
"RBP",
"RSP",
"RSI",
"RDI",
),
exercise_selection=True,
),
),
@ -426,8 +437,16 @@ def selectable_descendants(element: Any, depth: int = 2) -> list[Any]:
following = []
for parent in current:
for child in parent.children():
# xa11y 0.11.0 normalizes Windows UIA DataItem controls as
# table_row even when GridItem/TableItem identify them as cells.
# Accept that known backend role here so selection remains an
# end-to-end action test instead of duplicating the role bug.
is_selectable_item = child.role in ("table_cell", "list_item") or (
child.role == "table_row"
and child.raw.get("control_type_id") == 50029
)
if (
child.role in ("table_cell", "list_item")
is_selectable_item
and child.visible
and child.bounds is not None
and child.bounds.width > 0
@ -700,6 +719,33 @@ def main() -> int:
else:
add_check(checks, found, message, args.strict)
if control_spec.expected_order:
try:
direct_names = [
child.name or "" for child in element.children()
]
except Exception:
direct_names = []
expected_positions = [
next(
(
index
for index, name in enumerate(direct_names)
if name == expected
or name.startswith(expected + " =")
),
-1,
)
for expected in control_spec.expected_order
]
add_check(
checks,
all(position >= 0 for position in expected_positions)
and expected_positions == sorted(expected_positions),
f"{control_spec.selector} exposes registers in visual order",
args.strict,
)
bounds = snapshot.get("bounds")
add_check(
checks,

View File

@ -4,6 +4,7 @@
#include "AccessibleAbstractTableViewCell.h"
#include "AccessibleAbstractTableViewCellTitle.h"
#include <algorithm>
#include <exception>
AccessibleAbstractTableView::AccessibleAbstractTableView(QWidget* w)
: QAccessibleWidget(w, QAccessible::Table, dynamic_cast<AbstractTableView*>(w)->accessibleName())
@ -29,20 +30,40 @@ AbstractTableView* AccessibleAbstractTableView::getTable() const
return m_tableView;
}
std::vector<QAccessible::Id> AccessibleAbstractTableView::takeChildInterfaces()
{
std::vector<QAccessible::Id> result;
result.reserve(1
+ columnTitleInterfaces.size()
+ rowTitleInterfaces.size()
+ cellInterfaces.size());
result.push_back(cornerInterface);
result.insert(result.end(), columnTitleInterfaces.begin(), columnTitleInterfaces.end());
result.insert(result.end(), rowTitleInterfaces.begin(), rowTitleInterfaces.end());
result.insert(result.end(), cellInterfaces.begin(), cellInterfaces.end());
// Detach every old ID before deletion. Qt 6.11+ emits synchronous
// ObjectDestroyed notifications for objectless interfaces, so callbacks
// must observe an empty/current cache rather than IDs being torn down.
cornerInterface = 0;
columnTitleInterfaces.clear();
rowTitleInterfaces.clear();
cellInterfaces.clear();
return result;
}
void AccessibleAbstractTableView::deleteChildInterfaces(const std::vector<QAccessible::Id>& ids)
{
for(const auto id : ids)
{
if(id != 0)
QAccessible::deleteAccessibleInterface(id);
}
}
void AccessibleAbstractTableView::clearChildInterfaces()
{
for(const auto id : columnTitleInterfaces)
{
if(id != 0)
QAccessible::deleteAccessibleInterface(id);
}
for(const auto id : cellInterfaces)
{
if(id != 0)
QAccessible::deleteAccessibleInterface(id);
}
columnTitleInterfaces.clear();
cellInterfaces.clear();
deleteChildInterfaces(takeChildInterfaces());
}
std::vector<duint> AccessibleAbstractTableView::visibleColumns() const
@ -122,7 +143,44 @@ QAccessibleInterface* AccessibleAbstractTableView::columnHeaderInterface(int col
if(id == 0)
{
id = QAccessible::registerAccessibleInterface(
new AccessibleAbstractTableViewCellTitle(m_tableView, column, modelRevision));
new AccessibleAbstractTableViewCellTitle(
m_tableView,
AccessibleAbstractTableViewCellTitle::HeaderType::Column,
column,
modelRevision));
}
return QAccessible::accessibleInterface(id);
}
QAccessibleInterface* AccessibleAbstractTableView::rowHeaderInterface(int row) const
{
if(row < 0 || row >= rows)
return nullptr;
auto & id = const_cast<std::vector<QAccessible::Id>&>(rowTitleInterfaces).at(row);
if(id == 0)
{
id = QAccessible::registerAccessibleInterface(
new AccessibleAbstractTableViewCellTitle(
m_tableView,
AccessibleAbstractTableViewCellTitle::HeaderType::Row,
row,
modelRevision));
}
return QAccessible::accessibleInterface(id);
}
QAccessibleInterface* AccessibleAbstractTableView::cornerHeaderInterface() const
{
auto & id = const_cast<QAccessible::Id &>(cornerInterface);
if(id == 0)
{
id = QAccessible::registerAccessibleInterface(
new AccessibleAbstractTableViewCellTitle(
m_tableView,
AccessibleAbstractTableViewCellTitle::HeaderType::Corner,
-1,
modelRevision));
}
return QAccessible::accessibleInterface(id);
}
@ -130,21 +188,27 @@ QAccessibleInterface* AccessibleAbstractTableView::columnHeaderInterface(int col
int AccessibleAbstractTableView::childCount() const
{
ensureModelUpToDate();
return cols + static_cast<int>(cellInterfaces.size());
return (rows + 1) * (cols + 1);
}
QAccessibleInterface* AccessibleAbstractTableView::child(int index) const
{
ensureModelUpToDate();
if(index < 0)
if(index < 0 || index >= (rows + 1) * (cols + 1))
return nullptr;
if(index < cols)
return columnHeaderInterface(index);
const int cellIndex = index - cols;
if(cellIndex < 0 || cellIndex >= static_cast<int>(cellInterfaces.size()) || cols == 0)
return nullptr;
return cellInterface(cellIndex / cols, cellIndex % cols);
const int stride = cols + 1;
const int structuralRow = index / stride;
const int structuralColumn = index % stride;
if(structuralRow == 0)
{
if(structuralColumn == 0)
return cornerHeaderInterface();
return columnHeaderInterface(structuralColumn - 1);
}
if(structuralColumn == 0)
return rowHeaderInterface(structuralRow - 1);
return cellInterface(structuralRow - 1, structuralColumn - 1);
}
QAccessibleInterface* AccessibleAbstractTableView::childAt(int x, int y) const
@ -243,6 +307,11 @@ QAccessibleInterface* AccessibleAbstractTableView::caption() const
QAccessibleInterface* AccessibleAbstractTableView::cellAt(int row, int column) const
{
ensureModelUpToDate();
// Match QAccessibleTable's header extension to the public data-cell API.
if(row == -1)
return column == -1 ? cornerHeaderInterface() : columnHeaderInterface(column);
if(column == -1)
return rowHeaderInterface(row);
return cellInterface(row, column);
}
@ -278,10 +347,12 @@ void AccessibleAbstractTableView::modelChange(QAccessibleTableModelChangeEvent*
{
Q_UNUSED(event);
// Every event emitted by AbstractTableView is a model reset. Clear virtual
// interfaces even when the dimensions did not change: after scrolling the
// same viewport coordinate represents a different logical row.
clearChildInterfaces();
// Every event emitted by AbstractTableView is a model reset. Visible
// coordinates have new identity after scrolling even if dimensions match.
// Publish the new generation and empty cache before deleting old IDs: Qt
// 6.11+ synchronously dispatches ObjectDestroyed for virtual interfaces,
// and Cocoa may re-query this adapter from that callback.
const auto oldInterfaces = takeChildInterfaces();
modelRevision = m_tableView ? m_tableView->accessibilityModelRevision : 0;
tableOffset = m_tableView ? m_tableView->getTableOffset() : 0;
rows = visibleRowCount();
@ -289,6 +360,9 @@ void AccessibleAbstractTableView::modelChange(QAccessibleTableModelChangeEvent*
cols = static_cast<int>(m_visibleColumns.size());
cellInterfaces.assign(static_cast<size_t>(rows) * cols, 0);
columnTitleInterfaces.assign(cols, 0);
rowTitleInterfaces.assign(rows, 0);
cornerInterface = 0;
deleteChildInterfaces(oldInterfaces);
}
int AccessibleAbstractTableView::rowCount() const
@ -299,9 +373,17 @@ int AccessibleAbstractTableView::rowCount() const
QString AccessibleAbstractTableView::rowDescription(int row) const
{
Q_UNUSED(row);
// AbstractTableView has no visual row headers.
return QString();
ensureModelUpToDate();
if(row < 0 || row >= rows || !m_tableView || m_tableView->getColumnCount() == 0)
return QString();
try
{
return getCellContent(row, 0);
}
catch(const std::exception &)
{
return QString();
}
}
bool AccessibleAbstractTableView::selectColumn(int column)
@ -388,6 +470,16 @@ bool AccessibleAbstractTableView::headerIsValid(int column) const
return isValid() && modelIsCurrent() && column >= 0 && column < cols;
}
bool AccessibleAbstractTableView::rowHeaderIsValid(int row) const
{
return isValid() && modelIsCurrent() && row >= 0 && row < rows;
}
bool AccessibleAbstractTableView::cornerIsValid() const
{
return isValid() && modelIsCurrent();
}
QRect AccessibleAbstractTableView::elementRect(int row, int column, bool header) const
{
if((header && !headerIsValid(column)) || (!header && !cellIsValid(row, column)))

View File

@ -6,15 +6,19 @@
/**
* Accessible interface for AbstractTableView.
* This accessibility interface only exposes what is visible on the screen because the data scale of underlying AbstractTableView is uncontrollable.
* Its direct-child layout matches Qt's QAccessibleTable without a vertical
* header: column headers first, followed by row-major data cells. Like Qt's
* item-view adapter, virtual children retain the widget and model identity and
* re-query this adapter instead of retaining its address.
* Its direct-child layout matches QAccessibleTable with horizontal and vertical
* headers: a hidden corner, column headers, then a hidden row header followed by
* each row's data cells. Row-header names use the first raw data column, like a
* QTableView model whose vertical headerData contains debugger addresses.
* Like Qt's item-view adapter, virtual children retain the widget and model
* identity and re-query this adapter instead of retaining its address.
*/
class AccessibleAbstractTableView : public QAccessibleWidget, public QAccessibleTableInterface
{
std::vector<QAccessible::Id> cellInterfaces;
std::vector<QAccessible::Id> columnTitleInterfaces;
std::vector<QAccessible::Id> rowTitleInterfaces;
QAccessible::Id cornerInterface = 0;
int rows = 0;
int cols = 0;
duint tableOffset = 0;
@ -39,7 +43,7 @@ public:
QAccessible::State state() const override;
void* interface_cast(QAccessible::InterfaceType type) override;
// QAccessibleTableInterface. Rows and columns are zero-based data coordinates;
// column headers are separate children and are not part of rowCount().
// structural headers are separate children and are not part of rowCount().
QAccessibleInterface* caption() const override;
QAccessibleInterface* cellAt(int row, int column) const override;
int columnCount() const override;
@ -64,6 +68,8 @@ protected:
virtual QString getCellContent(int row, int col) const; // Get plain text of a cell
AbstractTableView* m_tableView;
private:
std::vector<QAccessible::Id> takeChildInterfaces();
static void deleteChildInterfaces(const std::vector<QAccessible::Id>& ids);
void clearChildInterfaces();
std::vector<duint> visibleColumns() const;
int visibleRowCount() const;
@ -71,9 +77,13 @@ private:
void ensureModelUpToDate() const;
QAccessibleInterface* cellInterface(int row, int column) const;
QAccessibleInterface* columnHeaderInterface(int column) const;
QAccessibleInterface* rowHeaderInterface(int row) const;
QAccessibleInterface* cornerHeaderInterface() const;
QRect elementRect(int row, int column, bool header) const;
bool cellIsValid(int row, int column) const;
bool headerIsValid(int column) const;
bool rowHeaderIsValid(int row) const;
bool cornerIsValid() const;
};
#endif

View File

@ -177,7 +177,11 @@ QList<QAccessibleInterface*> AccessibleAbstractTableViewCell::columnHeaderCells(
QList<QAccessibleInterface*> AccessibleAbstractTableViewCell::rowHeaderCells() const
{
// AbstractTableView does not paint or expose row headers.
AccessibleAbstractTableView* accessible = accessibleTable();
if(!belongsTo(accessible) || !accessible->cellIsValid(row, column))
return QList<QAccessibleInterface*>();
if(auto header = accessible->rowHeaderInterface(row))
return QList<QAccessibleInterface*>({header});
return QList<QAccessibleInterface*>();
}

View File

@ -1,27 +1,52 @@
// This file implements accessibility interface for the column headers of AbstractTableView
// This file implements the structural headers of AbstractTableView.
#ifndef QT_NO_ACCESSIBILITY
#include "AccessibleAbstractTableViewCellTitle.h"
#include "AccessibleAbstractTableView.h"
#include <exception>
AccessibleAbstractTableViewCellTitle::AccessibleAbstractTableViewCellTitle(AbstractTableView* tableView, int column, quint64 modelRevision)
: AccessibleAbstractTableViewCell(tableView, -1, column, modelRevision)
AccessibleAbstractTableViewCellTitle::AccessibleAbstractTableViewCellTitle(
AbstractTableView* tableView, HeaderType type, int index, quint64 modelRevision)
: AccessibleAbstractTableViewCell(
tableView,
type == HeaderType::Row ? index : -1,
type == HeaderType::Column ? index : -1,
modelRevision)
, mType(type)
{
}
QString AccessibleAbstractTableViewCellTitle::text(QAccessible::Text t) const
{
AccessibleAbstractTableView* accessible = accessibleTable();
if(!belongsTo(accessible) || !accessible->headerIsValid(column))
if(t != QAccessible::Name)
return QString();
if(t == QAccessible::Name)
AccessibleAbstractTableView* accessible = accessibleTable();
if(!isValidFor(accessible))
return QString();
if(mType == HeaderType::Column)
return mTableView->getColTitle(accessible->logicalColumn(column));
if(mType == HeaderType::Row && mTableView->getColumnCount() > 0)
{
try
{
// Match a QTableView with custom vertical headerData: the dedicated
// row-header object carries the debugger row's stable identifier,
// while the first data cell remains an ordinary table cell.
return accessible->getCellContent(row, 0);
}
catch(const std::exception &)
{
return QString();
}
}
return QString();
}
QColor AccessibleAbstractTableViewCellTitle::foregroundColor() const
{
AccessibleAbstractTableView* accessible = accessibleTable();
return belongsTo(accessible) && accessible->headerIsValid(column) && mTableView
return isValidFor(accessible) && mTableView
? mTableView->mHeaderTextColor
: QColor();
}
@ -29,7 +54,7 @@ QColor AccessibleAbstractTableViewCellTitle::foregroundColor() const
QColor AccessibleAbstractTableViewCellTitle::backgroundColor() const
{
AccessibleAbstractTableView* accessible = accessibleTable();
return belongsTo(accessible) && accessible->headerIsValid(column) && mTableView
return isValidFor(accessible) && mTableView
? mTableView->mHeaderBackgroundColor
: QColor();
}
@ -39,7 +64,7 @@ QAccessible::State AccessibleAbstractTableViewCellTitle::state() const
QAccessible::State result;
AccessibleAbstractTableView* accessible = accessibleTable();
const AbstractTableView* table = mTableView.data();
if(!belongsTo(accessible) || !accessible->headerIsValid(column) || !table)
if(!isValidFor(accessible) || !table)
{
result.invalid = true;
return result;
@ -48,48 +73,89 @@ QAccessible::State AccessibleAbstractTableViewCellTitle::state() const
const bool visible = !rect().isEmpty();
result.disabled = !table->isEnabled();
result.readOnly = true;
result.invisible = table->getHeaderHeight() == 0 || !table->isVisible() || !visible;
// AbstractTableView paints its horizontal header, but has no visible
// vertical-header gutter or corner. Keep those canonical structural
// objects available to table APIs while native trees mark them hidden.
result.invisible = mType != HeaderType::Column
|| table->getHeaderHeight() == 0
|| !table->isVisible()
|| !visible;
result.offscreen = !visible;
return result;
}
QRect AccessibleAbstractTableViewCellTitle::rect() const
{
if(mType != HeaderType::Column)
return QRect();
AccessibleAbstractTableView* accessible = accessibleTable();
return belongsTo(accessible) ? accessible->elementRect(-1, column, true) : QRect();
return isValidFor(accessible) ? accessible->elementRect(-1, column, true) : QRect();
}
QAccessible::Role AccessibleAbstractTableViewCellTitle::role() const
{
return QAccessible::ColumnHeader;
switch(mType)
{
case HeaderType::Column:
return QAccessible::ColumnHeader;
case HeaderType::Row:
return QAccessible::RowHeader;
case HeaderType::Corner:
return QAccessible::Pane;
}
return QAccessible::NoRole;
}
int AccessibleAbstractTableViewCellTitle::columnIndex() const
{
return mType == HeaderType::Column ? column : -1;
}
int AccessibleAbstractTableViewCellTitle::rowIndex() const
{
return -1;
return mType == HeaderType::Row ? row : -1;
}
bool AccessibleAbstractTableViewCellTitle::isValidFor(AccessibleAbstractTableView* accessible) const
{
if(!belongsTo(accessible))
return false;
switch(mType)
{
case HeaderType::Column:
return accessible->headerIsValid(column);
case HeaderType::Row:
return accessible->rowHeaderIsValid(row);
case HeaderType::Corner:
return accessible->cornerIsValid();
}
return false;
}
bool AccessibleAbstractTableViewCellTitle::isValid() const
{
AccessibleAbstractTableView* accessible = accessibleTable();
return belongsTo(accessible) && accessible->headerIsValid(column);
return isValidFor(accessibleTable());
}
void* AccessibleAbstractTableViewCellTitle::interface_cast(QAccessible::InterfaceType type)
{
Q_UNUSED(type);
// Headers are separate structural children, not cells in the data grid.
// Headers are structural children, not cells in the data grid.
return nullptr;
}
QList<QAccessibleInterface*> AccessibleAbstractTableViewCellTitle::rowHeaderCells() const
{
return QList<QAccessibleInterface*>();
return mType == HeaderType::Row
? QList<QAccessibleInterface*>({const_cast<AccessibleAbstractTableViewCellTitle*>(this)})
: QList<QAccessibleInterface*>();
}
QList<QAccessibleInterface*> AccessibleAbstractTableViewCellTitle::columnHeaderCells() const
{
return QList<QAccessibleInterface*>({const_cast<AccessibleAbstractTableViewCellTitle*>(this)});
return mType == HeaderType::Column
? QList<QAccessibleInterface*>({const_cast<AccessibleAbstractTableViewCellTitle*>(this)})
: QList<QAccessibleInterface*>();
}
#endif

View File

@ -6,7 +6,14 @@
class AccessibleAbstractTableViewCellTitle : public AccessibleAbstractTableViewCell
{
public:
AccessibleAbstractTableViewCellTitle(AbstractTableView* tableView, int column, quint64 modelRevision);
enum class HeaderType
{
Column,
Row,
Corner
};
AccessibleAbstractTableViewCellTitle(AbstractTableView* tableView, HeaderType type, int index, quint64 modelRevision);
// QAccessibleInterface
QString text(QAccessible::Text t) const override;
QColor foregroundColor() const override;
@ -16,9 +23,14 @@ public:
QList<QAccessibleInterface*> columnHeaderCells() const override;
QRect rect() const override;
QAccessible::Role role() const override;
int columnIndex() const override;
int rowIndex() const override;
bool isValid() const override;
void* interface_cast(QAccessible::InterfaceType type) override;
private:
bool isValidFor(AccessibleAbstractTableView* accessible) const;
HeaderType mType;
};
#endif

View File

@ -40,6 +40,7 @@ QString AccessibleRegistersViewItem::text(QAccessible::Text t) const
switch(t)
{
case QAccessible::Name:
case QAccessible::Value:
{
const auto it = view->mRegisterMapping.constFind(id);
if(it == view->mRegisterMapping.cend())
@ -204,6 +205,9 @@ AccessibleRegistersView::~AccessibleRegistersView()
std::vector<RegistersView::REGISTER_NAME> AccessibleRegistersView::registerOrder() const
{
// REGISTER_NAME groups storage identities, not presentation order. The
// visible layout also changes with x87/MMX and AVX-512 display modes, so
// derive child order from the same geometry used for painting and hit tests.
std::vector<RegistersView::REGISTER_NAME> result;
if(!m_registersView)
return result;

View File

@ -1479,7 +1479,9 @@ void AbstractTableView::accessibilitySelectionChanged()
return false;
QAccessibleEvent event(this, type);
event.setChild(columns + row * columns + column);
// Match QAccessibleTable's structural grid: hidden corner and column
// headers in row zero, then a hidden row header before each data row.
event.setChild((row + 1) * (columns + 1) + column + 1);
QAccessible::updateAccessibility(&event);
return true;
};

View File

@ -1,4 +1,5 @@
#include "DebugStatusLabel.h"
#include <QAccessible>
#include <QStyle>
#include <QMetaEnum>
@ -45,5 +46,12 @@ void DebugStatusLabel::debugStateChangedSlot(DBGSTATE state)
this->style()->polish(this);
this->update();
// QLabel::setText() emits QAccessible::NameChanged when needed.
// Passive status labels are not focused, so screen readers such as
// Narrator do not announce QLabel's automatic NameChanged notification.
// Preserve the explicit ValueChanged event used for live status updates.
if(QAccessible::isActive())
{
QAccessibleValueChangeEvent updateEvent(this, mStatusTexts[state]);
QAccessible::updateAccessibility(&updateEvent);
}
}

View File

@ -1,6 +1,8 @@
#include "LogStatusLabel.h"
#include "LogView.h"
#include <QAccessible>
#include <QApplication>
#include <QTextDocumentFragment>
#include <QStatusBar>
LogStatusLabel::LogStatusLabel(QStatusBar* parent) : QLabel(parent)
@ -42,7 +44,15 @@ void LogStatusLabel::logUpdate(QString message, bool encodeHTML)
}
}
setText(finalLabel);
// QLabel::setText() emits QAccessible::NameChanged when needed.
// A status-bar label is passive and its automatic NameChanged event is not
// announced by Narrator. Send the explicit live ValueChanged notification
// and strip any rich-text markup from its payload.
if(QAccessible::isActive())
{
QAccessibleValueChangeEvent updateEvent(
this, QTextDocumentFragment::fromHtml(finalLabel).toPlainText());
QAccessible::updateAccessibility(&updateEvent);
}
}
void LogStatusLabel::logUpdateUtf8(QByteArray message)

View File

@ -3548,10 +3548,13 @@ void RegistersView::accessibilityValueChanged()
{
if(auto item = accessible->interfaceForRegister(reg))
{
// Register items expose their displayed "RAX = value" string as
// Name and do not implement a numeric QAccessibleValueInterface.
QAccessibleEvent nameChangeEvent(item, QAccessible::NameChanged);
QAccessible::updateAccessibility(&nameChangeEvent);
// Narrator listens for ValueChanged on register list items. The
// displayed value is textual (and may include a symbol), so expose
// the same string through QAccessible::Value without claiming a
// numeric QAccessibleValueInterface.
QAccessibleValueChangeEvent valueChangeEvent(
item, QVariant(item->text(QAccessible::Value)));
QAccessible::updateAccessibility(&valueChangeEvent);
}
}
}

View File

@ -41,8 +41,10 @@ The checker validates:
GridItem row/column and containing Grid round-trip correctly.
- A populated table exposes one column-header relation per column, and every
first-row cell points to the corresponding header.
- Visible cells/headers participate in direct child navigation and point back to
the table.
- Every row has a distinct, hidden row-header object and all cells in that row
reference it. The first data cell is never repurposed as the header.
- Visible cells/column headers participate in direct child navigation and point
back to the table; hidden row headers remain available through TablePattern.
- Hit-testing the center of visible headers and first-row cells returns that
exact UIA element.
- UIA Name properties can be queried for all cells and headers.
@ -50,6 +52,21 @@ The checker validates:
The script exits non-zero on a contract failure. `--max-cells` limits work for
unexpectedly large grids.
## Live event checks
With a live debug target paused, the event checker logs a unique marker and
single-steps once through the debugger Command Bar:
```powershell
uv run x64dbg-screenreader-event-checks
```
It listens through native UIA and requires `ValueChanged` payloads for the log
message, `Running` and `Paused` debug states, and the updated `EIP`/`RIP` list
item. These are the passive live-region events consumed by Microsoft Narrator;
a QLabel `NameChanged` event alone is not announced. The command intentionally
advances the debug target by one instruction.
## Capture visible contents
The dump command writes the currently visible tables, register lists, text
@ -80,7 +97,7 @@ output file includes the corresponding `ERROR:` section.
`--window-index`.
- Empty tables can validate Grid structure but cannot expose header relations
through Qt's UIA Table provider until at least one data row exists.
- These scripts do not yet capture UIA events or automate scrolling/model-reset
transitions. Those still require a deliberate manual scenario.
- Table scrolling/model-reset transitions still require a deliberate manual
scenario. The event checker automates only one instruction step.
- macOS VoiceOver/Accessibility Inspector and Linux AT-SPI require separate
platform-specific testing.

View File

@ -4,14 +4,16 @@ version = "0.1.0"
description = "UIA-based accessibility checks for x64dbg table views."
requires-python = ">=3.11"
dependencies = [
"comtypes>=1.4.10; sys_platform == 'win32'",
"pywinauto>=0.6.9",
]
[tool.setuptools]
py-modules = ["screenreader_check", "ui_dump", "ui_common"]
py-modules = ["screenreader_check", "uia_event_check", "ui_dump", "ui_common"]
[project.scripts]
x64dbg-screenreader-checks = "screenreader_check:main"
x64dbg-screenreader-event-checks = "uia_event_check:main"
x64dbg-ui-dump = "ui_dump:main"
[tool.uv]

View File

@ -198,13 +198,65 @@ def _check_headers(
except Exception as exc:
failures.append(f"Cell (0,{col}) header relation failed: {exc}")
row_headers: list[UIAWrapper] = []
if rows > 0 and cols > 0:
try:
row_header_array = table.iface_table.GetCurrentRowHeaders()
row_headers = [
wrap_uia_element(row_header_array.GetElement(index))
for index in range(int(row_header_array.Length))
]
except Exception as exc:
failures.append(f"Table row-header query failed: {exc}")
if len(row_headers) != rows:
failures.append(
f"TablePattern returned {len(row_headers)} row headers for {rows} rows"
)
row_header_ids: set[tuple[int, ...]] = set()
for row, row_header in enumerate(row_headers):
row_header_id = _runtime_id(row_header)
if not row_header_id:
failures.append(f"Row header {row} has no runtime ID")
elif row_header_id in row_header_ids:
failures.append(f"Row header {row} reuses runtime ID {row_header_id}")
else:
row_header_ids.add(row_header_id)
if row_header.element_info.control_type not in {"Header", "HeaderItem"}:
failures.append(
f"Row header {row} has type "
f"{row_header.element_info.control_type!r}"
)
if row < len(grid_items) and grid_items[row]:
if _same_element(row_header, grid_items[row][0]):
failures.append(f"Row header {row} reuses its first data cell")
for col, item in enumerate(grid_items[row]):
try:
header_array = item.iface_table_item.GetCurrentRowHeaderItems()
cell_headers = [
wrap_uia_element(header_array.GetElement(index))
for index in range(int(header_array.Length))
]
if len(cell_headers) != 1 or not _same_element(
cell_headers[0], row_header
):
failures.append(
f"Cell ({row},{col}) does not reference row header {row}"
)
except Exception as exc:
failures.append(
f"Cell ({row},{col}) row-header relation failed: {exc}"
)
if failures:
return headers, CheckResult(False, "; ".join(failures[:8]))
if rows == 0:
return headers, CheckResult(
True, "Header relation check skipped because the Grid has no data rows."
)
return headers, CheckResult(True, f"Header relations OK ({len(headers)} headers).")
return headers, CheckResult(
True,
f"Header relations OK ({len(headers)} column, {len(row_headers)} row).",
)
def _check_child_navigation(

View File

@ -88,6 +88,15 @@ def list_matching_windows(title_hint: Optional[str]) -> list[WindowMatch]:
continue
windows.append(window)
# UIA desktop enumeration order is not stable between calls. Both the CLI
# validation and select_window() enumerate, so sort before assigning indexes
# or --window-index can select a different process than --list-windows showed.
windows.sort(
key=lambda window: (
int(window.element_info.process_id),
window.window_text() or "",
)
)
return [
WindowMatch(index=index, title=window.window_text(), window=window)
for index, window in enumerate(windows)

View File

@ -0,0 +1,195 @@
from __future__ import annotations
import argparse
import ctypes
import re
import sys
from dataclasses import dataclass
from typing import Any, Optional
# Let pywinauto establish the process COM apartment before importing comtypes;
# reversing this order makes pywinauto warn and switch apartment assumptions.
from pywinauto.controls.uiawrapper import UIAWrapper
from pywinauto.uia_defines import IUIA
from ui_common import list_matching_windows, select_window
import comtypes
import comtypes.client
import comtypes.gen.UIAutomationClient as UIA
LOG_MARKER = "X64DBG_ACCESSIBILITY_EVENT_PROBE"
INSTRUCTION_POINTER = re.compile(r"^(?:EIP|RIP) = ", re.IGNORECASE)
@dataclass(frozen=True)
class PropertyEvent:
property_id: int
name: str
value: str
control_type: int
def _variant_text(value: Any) -> str:
try:
unwrapped = value.value
except Exception:
unwrapped = value
return "" if unwrapped is None else str(unwrapped)
class PropertyChangedHandler(comtypes.COMObject):
_com_interfaces_ = [UIA.IUIAutomationPropertyChangedEventHandler]
def __init__(self) -> None:
super().__init__()
self.events: list[PropertyEvent] = []
def HandlePropertyChangedEvent(
self, sender: Any, property_id: int, new_value: Any
) -> int:
try:
name = str(sender.CurrentName or "")
except Exception:
name = ""
try:
control_type = int(sender.CurrentControlType)
except Exception:
control_type = 0
self.events.append(
PropertyEvent(
property_id=int(property_id),
name=name,
value=_variant_text(new_value),
control_type=control_type,
)
)
return 0
def _command_line(window: UIAWrapper) -> Optional[UIAWrapper]:
for edit in window.descendants(control_type="Edit"):
try:
parent = edit.parent()
if parent and parent.element_info.name == "CommandBar":
return edit
except Exception:
continue
return None
def _execute(command_line: UIAWrapper, command: str) -> None:
command_line.set_focus()
command_line.set_edit_text(command)
command_line.type_keys("{ENTER}")
def _has_value(events: list[PropertyEvent], predicate) -> bool:
return any(
event.property_id == UIA.UIA_ValueValuePropertyId and predicate(event.value)
for event in events
)
def main() -> int:
parser = argparse.ArgumentParser(
description=(
"Verify the live UIA events consumed by screen readers. The selected "
"debugger must be paused with a live debug target."
)
)
parser.add_argument(
"--window-title",
default=None,
help="Substring to match an x64dbg/x32dbg window title (optional).",
)
parser.add_argument(
"--window-index",
type=int,
default=None,
help="Select a specific matching debugger window by index (0-based).",
)
parser.add_argument(
"--timeout",
type=float,
default=6.0,
help="Seconds to collect events after issuing a single-step command.",
)
args = parser.parse_args()
matches = list_matching_windows(args.window_title)
if not matches:
print("ERROR: Could not find a running x64dbg/x32dbg window.", file=sys.stderr)
return 2
if args.window_index is not None and not (0 <= args.window_index < len(matches)):
print("ERROR: --window-index is out of range.", file=sys.stderr)
return 2
window = select_window(args.window_title, args.window_index)
if window is None:
print("ERROR: Could not select a debugger window.", file=sys.stderr)
return 2
print(f"Window: {window.window_text()}")
command_line = _command_line(window)
if command_line is None:
print("ERROR: Could not find the debugger CommandBar edit.", file=sys.stderr)
return 3
automation = IUIA().iuia
handler = PropertyChangedHandler()
properties = (ctypes.c_long * 1)(UIA.UIA_ValueValuePropertyId)
root = window.element_info.element
automation.AddPropertyChangedEventHandlerNativeArray(
root,
UIA.TreeScope_Subtree,
None,
handler,
properties,
len(properties),
)
try:
_execute(command_line, f'log "{LOG_MARKER}"')
comtypes.client.PumpEvents(1.0)
_execute(command_line, "sti")
comtypes.client.PumpEvents(max(args.timeout, 0.1))
finally:
automation.RemovePropertyChangedEventHandler(root, handler)
checks = [
(
"log message",
_has_value(handler.events, lambda value: LOG_MARKER in value),
),
(
"running debug state",
_has_value(handler.events, lambda value: value == "Running"),
),
(
"paused debug state",
_has_value(handler.events, lambda value: value == "Paused"),
),
(
"instruction pointer",
_has_value(
handler.events, lambda value: bool(INSTRUCTION_POINTER.match(value))
),
),
]
failed = False
for name, passed in checks:
print(f"[{'OK' if passed else 'FAIL'}] {name} ValueChanged event")
failed = failed or not passed
print(f"Captured {len(handler.events)} UIA property-change events.")
if failed:
print("Observed ValueChanged payloads:")
for event in handler.events:
if event.property_id == UIA.UIA_ValueValuePropertyId:
print(f" {event.control_type} {event.name!r}: {event.value!r}")
return 1 if failed else 0
if __name__ == "__main__":
raise SystemExit(main())

View File

@ -1,5 +1,5 @@
version = 1
revision = 2
revision = 3
requires-python = ">=3.11"
[[package]]
@ -71,8 +71,12 @@ name = "x64dbg-screenreader-checks"
version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "comtypes", marker = "sys_platform == 'win32'" },
{ name = "pywinauto" },
]
[package.metadata]
requires-dist = [{ name = "pywinauto", specifier = ">=0.6.9" }]
requires-dist = [
{ name = "comtypes", marker = "sys_platform == 'win32'", specifier = ">=1.4.10" },
{ name = "pywinauto", specifier = ">=0.6.9" },
]