Bug 1963996: Clear the selection if IAccessibleTextSelectionContainer::setSelections is called with nSelections set to 0. r=eeejay
I removed this behaviour in bug 1951573. Unfortunately, it turns out that contrary to the spec (which says "1 or more selections"), NVDA depends on this behaviour. Reinstate this by supporting kRemoveAllExistingSelectedRanges in HyperTextAccessibleBase::RemoveFromSelection and using that. Differential Revision: https://phabricator.services.mozilla.com/D247875
This commit is contained in:
committed by
jteh@mozilla.com
parent
cbb0e08325
commit
7932ffe32b
@@ -248,7 +248,8 @@ class HyperTextAccessibleBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified selection.
|
||||
* Removes the specified selection, or removes all selections if aSelectionNum
|
||||
*is TextLeafRange::kRemoveAllExistingSelectedRanges.
|
||||
* @return true if succeeded
|
||||
*/
|
||||
// TODO: annotate this with `MOZ_CAN_RUN_SCRIPT` instead.
|
||||
|
||||
@@ -767,6 +767,11 @@ bool HyperTextAccessible::RemoveFromSelection(int32_t aSelectionNum) {
|
||||
RefPtr<dom::Selection> domSel = DOMSelection();
|
||||
if (!domSel) return false;
|
||||
|
||||
if (aSelectionNum == TextLeafRange::kRemoveAllExistingSelectedRanges) {
|
||||
domSel->RemoveAllRanges(IgnoreErrors());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aSelectionNum < 0 ||
|
||||
aSelectionNum >= static_cast<int32_t>(domSel->RangeCount())) {
|
||||
return false;
|
||||
|
||||
@@ -110,5 +110,13 @@ addAccessibleTask(
|
||||
[p, 0, p, 1],
|
||||
[link, 0, link, 1],
|
||||
]);
|
||||
|
||||
info("Clearing selection");
|
||||
selected = waitForEvent(EVENT_TEXT_SELECTION_CHANGED, docAcc);
|
||||
await runPython(`
|
||||
docSel.setSelections(0, byref(IA2TextSelection()))
|
||||
`);
|
||||
await selected;
|
||||
checkSelection(docAcc, []);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -53,13 +53,17 @@ ia2AccessibleTextSelectionContainer::get_selections(
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTextSelectionContainer::setSelections(
|
||||
long nSelections, IA2TextSelection* selections) {
|
||||
if (nSelections <= 0 || !selections) {
|
||||
if (nSelections < 0 || !selections) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
HyperTextAccessibleBase* text = TextAcc();
|
||||
if (!text) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
if (nSelections == 0) {
|
||||
text->RemoveFromSelection(TextLeafRange::kRemoveAllExistingSelectedRanges);
|
||||
return S_OK;
|
||||
}
|
||||
// Build and validate new selection ranges.
|
||||
AutoTArray<TextLeafRange, 1> newRanges;
|
||||
newRanges.SetCapacity(nSelections);
|
||||
|
||||
Reference in New Issue
Block a user