Bug 1574428: IAccessible2_2::relationTargetsOfType: Support 0 for all targets and fix off-by-one error. r=MarcoZ

1. As per the spec, if maxTargets is 0, return all targets.
2. Where maxTargets > 0, fix the loop condition so it doesn't incorrectly fetch one more target than requested.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2019-08-19 05:58:49 +00:00
Родитель 87aa804651
Коммит bda9b87fdb
1 изменённых файлов: 3 добавлений и 2 удалений

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

@ -493,8 +493,9 @@ ia2Accessible::get_relationTargetsOfType(BSTR aType, long aMaxTargets,
MOZ_ASSERT(!acc->IsProxy());
Relation rel = acc->RelationByType(*relationType);
Accessible* target = nullptr;
while ((target = rel.Next()) &&
static_cast<long>(targets.Length()) <= aMaxTargets) {
while (
(target = rel.Next()) &&
(aMaxTargets == 0 || static_cast<long>(targets.Length()) < aMaxTargets)) {
targets.AppendElement(target);
}