Bug 1887784: Implement the UIA Level, PositionInSet and SizeOfSet properties. r=nlapre

Note that even though UIA has a dedicated HeadingLevel property, Chromium doesn't implement it and the documentation says the Level property can be used for headings as well.

Differential Revision: https://phabricator.services.mozilla.com/D207399
This commit is contained in:
James Teh 2024-04-15 22:34:27 +00:00
parent 77020ededa
commit 9cd86f5e84
2 changed files with 71 additions and 0 deletions

View File

@ -103,3 +103,59 @@ addUiaTask(
ok(await runPython(`p.CurrentIsEnabled`), "p has IsEnabled true");
}
);
async function testGroupPos(id, level, pos, size) {
await assignPyVarToUiaWithId(id);
is(await runPython(`${id}.CurrentLevel`), level, `${id} Level correct`);
is(
await runPython(`${id}.CurrentPositionInSet`),
pos,
`${id} PositionInSet correct`
);
is(
await runPython(`${id}.CurrentSizeOfSet`),
size,
`${id} SizeOfSet correct`
);
}
/**
* Test the Level, PositionInSet and SizeOfSet properties.
*/
addUiaTask(
`
<ul>
<li id="li1">li1<ul id="ul1">
<li id="li2a">li2a</li>
<li id="li2b" hidden>li2b</li>
<li id="li2c">li2c</li>
</ul></li>
</ul>
<h2 id="h2">h2</h2>
<button id="button">button</button>
`,
async function testGroupPosProps(browser) {
await definePyVar("doc", `getDocUia()`);
await testGroupPos("li1", 1, 1, 1);
await testGroupPos("li2a", 2, 1, 2);
await testGroupPos("li2c", 2, 2, 2);
info("Showing li2b");
// There aren't events in any API for a change to group position properties
// because this would be too spammy and isn't particularly useful given
// how frequently these can change.
let shown = waitForEvent(EVENT_SHOW, "li2b");
await invokeContentTask(browser, [], () => {
content.document.getElementById("li2b").hidden = false;
});
await shown;
await testGroupPos("li2a", 2, 1, 3);
await testGroupPos("li2b", 2, 2, 3);
await testGroupPos("li2c", 2, 3, 3);
// The IA2 -> UIA proxy doesn't map heading level to the Level property.
if (gIsUiaEnabled) {
await testGroupPos("h2", 2, 0, 0);
}
await testGroupPos("button", 0, 0, 0);
}
);

View File

@ -459,6 +459,11 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
(acc->State() & states::FOCUSABLE) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
case UIA_LevelPropertyId:
aPropertyValue->vt = VT_I4;
aPropertyValue->lVal = acc->GroupPosition().level;
return S_OK;
case UIA_NamePropertyId: {
nsAutoString name;
acc->Name(name);
@ -469,6 +474,16 @@ uiaRawElmProvider::GetPropertyValue(PROPERTYID aPropertyId,
}
break;
}
case UIA_PositionInSetPropertyId:
aPropertyValue->vt = VT_I4;
aPropertyValue->lVal = acc->GroupPosition().posInSet;
return S_OK;
case UIA_SizeOfSetPropertyId:
aPropertyValue->vt = VT_I4;
aPropertyValue->lVal = acc->GroupPosition().setSize;
return S_OK;
}
return S_OK;