Bug 1748755: Support IAccessibleText::get_new/oldText for cached RemoteAccessible. r=morgan

1. Make ia2AccessibleText::UpdateTextChangeData (and sLastTextChangeAcc) use HyperTextAccessibleBase instead of HyperTextAccessibleWrap.
2. Make ProxyTextChangeEvent call UpdateTextChangeData when the cache is enabled.
3. Don't send sync text change events when the cache is enabled. They don't need to be sync because clients query the cache, not the content process a11y tree. Even if the content process a11y tree mutates, the cache can't update until in-process clients have synchronously handled the event.

Differential Revision: https://phabricator.services.mozilla.com/D139677
This commit is contained in:
James Teh 2022-07-12 02:45:58 +00:00
Родитель 2e5729d4e9
Коммит d2d7992aaf
4 изменённых файлов: 18 добавлений и 10 удалений

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

@ -958,9 +958,11 @@ nsresult LocalAccessible::HandleAccEvent(AccEvent* aEvent) {
AccTextChangeEvent* event = downcast_accEvent(aEvent);
const nsString& text = event->ModifiedText();
#if defined(XP_WIN)
// On Windows, events for live region updates containing embedded
// objects require us to dispatch synchronous events.
bool sync = text.Contains(L'\xfffc') &&
// On Windows with the cache disabled, events for live region updates
// containing embedded objects require us to dispatch synchronous
// events.
bool sync = !StaticPrefs::accessibility_cache_enabled_AtStartup() &&
text.Contains(L'\xfffc') &&
nsAccUtils::IsARIALive(aEvent->GetAccessible());
#endif
ipcDoc->SendTextChangeEvent(id, text, event->GetStartOffset(),

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

@ -17,7 +17,7 @@
using namespace mozilla::a11y;
StaticRefPtr<HyperTextAccessibleWrap> ia2AccessibleText::sLastTextChangeAcc;
HyperTextAccessibleBase* ia2AccessibleText::sLastTextChangeAcc = nullptr;
StaticAutoPtr<nsString> ia2AccessibleText::sLastTextChangeString;
uint32_t ia2AccessibleText::sLastTextChangeStart = 0;
uint32_t ia2AccessibleText::sLastTextChangeEnd = 0;
@ -464,11 +464,10 @@ AccessibleTextBoundary ia2AccessibleText::GetGeckoTextBoundary(
}
void ia2AccessibleText::InitTextChangeData() {
ClearOnShutdown(&sLastTextChangeAcc);
ClearOnShutdown(&sLastTextChangeString);
}
void ia2AccessibleText::UpdateTextChangeData(HyperTextAccessibleWrap* aAcc,
void ia2AccessibleText::UpdateTextChangeData(HyperTextAccessibleBase* aAcc,
bool aInsert, const nsString& aStr,
int32_t aStart, uint32_t aLen) {
if (!sLastTextChangeString) sLastTextChangeString = new nsString();

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

@ -119,12 +119,16 @@ class ia2AccessibleText : public IAccessibleText {
/* [retval][out] */ IA2TextSegment* oldText);
static void InitTextChangeData();
static void UpdateTextChangeData(HyperTextAccessibleWrap* aAcc, bool aInsert,
static void UpdateTextChangeData(HyperTextAccessibleBase* aAcc, bool aInsert,
const nsString& aStr, int32_t aStart,
uint32_t aLen);
protected:
static StaticRefPtr<HyperTextAccessibleWrap> sLastTextChangeAcc;
// This can't be a RefPtr because RemoteAccessibles aren't ref counted. It
// can't be an id because this is global and ids are only unique within the
// document. Since this is only used for comparison, we use a raw pointer.
// This should *never* be dereferenced, only used for comparison!
static HyperTextAccessibleBase* sLastTextChangeAcc;
static StaticAutoPtr<nsString> sLastTextChangeString;
static bool sLastTextChangeWasInsert;
static uint32_t sLastTextChangeStart;

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

@ -194,8 +194,11 @@ void a11y::ProxyTextChangeEvent(RemoteAccessible* aText, const nsString& aStr,
return;
}
// XXX Call ia2AccessibleText::UpdateTextChangeData once that works for
// RemoteAccessible.
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
MOZ_ASSERT(aText->IsHyperText());
ia2AccessibleText::UpdateTextChangeData(aText->AsHyperTextBase(), aInsert,
aStr, aStart, aLen);
}
MsaaAccessible::FireWinEvent(aText, eventType);
}