Bug 1950782 part 2: Fix UIA SupportedTextSelection on text leaves. r=nlapre
For now, the core SELECTABLE_TEXT state is only exposed on text containers, not on text leaves. We may want to reconsider this at some point. For now, just handle this case in the UIA code, since that's the only place it matters. Differential Revision: https://phabricator.services.mozilla.com/D239855
This commit is contained in:
@@ -1397,6 +1397,7 @@ body {
|
||||
}
|
||||
</style>
|
||||
<input id="input">
|
||||
<p id="p">p</p>
|
||||
`,
|
||||
async function testTextSupportedTextSelection() {
|
||||
let result = await runPython(`
|
||||
@@ -1411,9 +1412,20 @@ body {
|
||||
SupportedTextSelection_Multiple,
|
||||
"input SupportedTextSelection correct"
|
||||
);
|
||||
// The IA2 -> UIA bridge doesn't understand that text isn't selectable in
|
||||
// this document.
|
||||
if (gIsUiaEnabled) {
|
||||
// The IA2 -> UIA proxy doesn't expose the Text pattern on this text leaf.
|
||||
is(
|
||||
await runPython(`
|
||||
p = findUiaByDomId(doc, "p")
|
||||
pLeaf = uiaClient.RawViewWalker.GetFirstChildElement(p)
|
||||
text = getUiaPattern(pLeaf, "Text")
|
||||
return text.SupportedTextSelection
|
||||
`),
|
||||
SupportedTextSelection_None,
|
||||
"pLeaf SupportedTextSelection correct"
|
||||
);
|
||||
// The IA2 -> UIA proxy doesn't understand that text isn't selectable in
|
||||
// this document.
|
||||
is(
|
||||
await runPython(`getUiaPattern(doc, "Text").SupportedTextSelection`),
|
||||
SupportedTextSelection_None,
|
||||
@@ -1427,18 +1439,34 @@ body {
|
||||
* Test the Text pattern's SupportedTextSelection property on a document with a
|
||||
* selectable body.
|
||||
*/
|
||||
addUiaTask(``, async function testTextSupportedTextSelectionSelectableBody() {
|
||||
is(
|
||||
await runPython(`
|
||||
global doc
|
||||
doc = getDocUia()
|
||||
text = getUiaPattern(doc, "Text")
|
||||
return text.SupportedTextSelection
|
||||
`),
|
||||
SupportedTextSelection_Multiple,
|
||||
"doc SupportedTextSelection correct"
|
||||
);
|
||||
});
|
||||
addUiaTask(
|
||||
`<p id="p">p</p>`,
|
||||
async function testTextSupportedTextSelectionSelectableBody() {
|
||||
is(
|
||||
await runPython(`
|
||||
global doc
|
||||
doc = getDocUia()
|
||||
text = getUiaPattern(doc, "Text")
|
||||
return text.SupportedTextSelection
|
||||
`),
|
||||
SupportedTextSelection_Multiple,
|
||||
"doc SupportedTextSelection correct"
|
||||
);
|
||||
// The IA2 -> UIA proxy doesn't expose the Text pattern on this text leaf.
|
||||
if (gIsUiaEnabled) {
|
||||
is(
|
||||
await runPython(`
|
||||
p = findUiaByDomId(doc, "p")
|
||||
pLeaf = uiaClient.RawViewWalker.GetFirstChildElement(p)
|
||||
text = getUiaPattern(pLeaf, "Text")
|
||||
return text.SupportedTextSelection
|
||||
`),
|
||||
SupportedTextSelection_Multiple,
|
||||
"pLeaf SupportedTextSelection correct"
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Test the Text pattern's GetSelection method with the caret.
|
||||
|
||||
@@ -165,7 +165,12 @@ UiaText::get_SupportedTextSelection(
|
||||
if (!acc) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
if (acc->State() & states::SELECTABLE_TEXT) {
|
||||
if (!acc->IsHyperText()) {
|
||||
// Currently, the SELECTABLE_TEXT state is only exposed on HyperText
|
||||
// Accessibles.
|
||||
acc = acc->Parent();
|
||||
}
|
||||
if (acc && acc->State() & states::SELECTABLE_TEXT) {
|
||||
*aRetVal = SupportedTextSelection_Multiple;
|
||||
} else {
|
||||
*aRetVal = SupportedTextSelection_None;
|
||||
|
||||
Reference in New Issue
Block a user