Bug 1521438: Correct IAccessible::get_accSelection implementation for no selection and single selection. r=MarcoZ

Previously, we were always returning VT_UNKNOWN and an IEnumVARIANT.
According to the IAccessible documentation, this should only be done for multiple selection.
Change this to correctly return VT_EMPTY for no selection and VT_DISPATCH (with an accessible) for single selection.

Differential Revision: https://phabricator.services.mozilla.com/D17091

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2019-01-21 07:21:01 +00:00
Родитель e5c8ead70a
Коммит 4fa1e2f7b8
1 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -740,17 +740,25 @@ AccessibleWrap::get_accSelection(VARIANT __RPC_FAR* pvarChildren) {
if (IsDefunct()) return CO_E_OBJNOTCONNECTED;
if (IsSelect()) {
AutoTArray<Accessible*, 10> selectedItems;
SelectedItems(&selectedItems);
if (!IsSelect()) {
return S_OK;
}
// 1) Create and initialize the enumeration
AutoTArray<Accessible*, 10> selectedItems;
SelectedItems(&selectedItems);
uint32_t count = selectedItems.Length();
if (count == 1) {
pvarChildren->vt = VT_DISPATCH;
pvarChildren->pdispVal = NativeAccessible(selectedItems[0]);
} else if (count > 1) {
RefPtr<AccessibleEnumerator> pEnum =
new AccessibleEnumerator(selectedItems);
pvarChildren->vt =
VT_UNKNOWN; // this must be VT_UNKNOWN for an IEnumVARIANT
NS_ADDREF(pvarChildren->punkVal = pEnum);
}
// If count == 0, vt is already VT_EMPTY, so there's nothing else to do.
return S_OK;
}