Bug 1564549 - Add action forwarding macro. r=Jamie

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eitan Isaacson 2019-09-23 23:42:53 +00:00
Родитель 7b90734d1f
Коммит f636c8855c
1 изменённых файлов: 14 добавлений и 16 удалений

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

@ -31,6 +31,16 @@
} while (0) } while (0)
#endif #endif
#define FORWARD_ACTION_TO_ACCESSIBLE(funcname, ...) \
if (RootAccessibleWrap* rootAcc = GetRoot()) { \
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID); \
if (!acc) { \
return; \
} \
\
acc->funcname(__VA_ARGS__); \
}
template <> template <>
const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] = const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
"SessionAccessibility"; "SessionAccessibility";
@ -98,25 +108,11 @@ RootAccessibleWrap* SessionAccessibility::GetRoot() {
} }
void SessionAccessibility::SetText(int32_t aID, jni::String::Param aText) { void SessionAccessibility::SetText(int32_t aID, jni::String::Param aText) {
if (RootAccessibleWrap* rootAcc = GetRoot()) { FORWARD_ACTION_TO_ACCESSIBLE(SetTextContents, aText->ToString());
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID);
if (!acc) {
return;
}
acc->SetTextContents(aText->ToString());
}
} }
void SessionAccessibility::Click(int32_t aID) { void SessionAccessibility::Click(int32_t aID) {
if (RootAccessibleWrap* rootAcc = GetRoot()) { FORWARD_ACTION_TO_ACCESSIBLE(DoAction, 0);
AccessibleWrap* acc = rootAcc->FindAccessibleById(aID);
if (!acc) {
return;
}
acc->DoAction(0);
}
} }
SessionAccessibility* SessionAccessibility::GetInstanceFor( SessionAccessibility* SessionAccessibility::GetInstanceFor(
@ -418,3 +414,5 @@ void SessionAccessibility::UpdateCachedBounds(
mSessionAccessibility->UpdateCachedBounds(infos); mSessionAccessibility->UpdateCachedBounds(infos);
SendWindowContentChangedEvent(); SendWindowContentChangedEvent();
} }
#undef FORWARD_ACTION_TO_ACCESSIBLE