Bug 1849398 - Gecko initiated a11y focus should not scroll. r=Jamie

If we send an Android ACCESSIBILITY_FOCUSED event because of a content
update (ie. scrolling to anchor or DOM selection changes) we should not
scroll the accessible into view. We should assume the content is being
brought into view by itself.

Testing: We already have tests to show that we scroll an accessible into
view when navigating content, testing for the inverse (that the scroll
is done by other means and NOT a11y) is very hard.

Differential Revision: https://phabricator.services.mozilla.com/D199433
This commit is contained in:
Eitan Isaacson 2024-01-24 04:49:03 +00:00
Родитель 4b439bc34d
Коммит ba3c5e3b7b
3 изменённых файлов: 10 добавлений и 7 удалений

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

@ -100,7 +100,7 @@ void a11y::PlatformEvent(Accessible* aTarget, uint32_t aEventType) {
if (Accessible* result = AccessibleWrap::DoPivot(
aTarget, java::SessionAccessibility::HTML_GRANULARITY_DEFAULT,
true, true)) {
sessionAcc->SendAccessibilityFocusedEvent(result);
sessionAcc->SendAccessibilityFocusedEvent(result, false);
}
break;
default:
@ -167,7 +167,7 @@ void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
if (Accessible* result = AccessibleWrap::DoPivot(
leaf, java::SessionAccessibility::HTML_GRANULARITY_DEFAULT, true,
true)) {
sessionAcc->SendAccessibilityFocusedEvent(result);
sessionAcc->SendAccessibilityFocusedEvent(result, false);
}
}
}

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

@ -168,7 +168,7 @@ bool SessionAccessibility::Pivot(int32_t aID, int32_t aGranularity,
MOZ_ASSERT(_acc->IsLocal());
if (Accessible* result = AccessibleWrap::DoPivot(
_acc, aGranularity, aForward, aInclusive)) {
SendAccessibilityFocusedEvent(result);
SendAccessibilityFocusedEvent(result, true);
}
}
});
@ -181,7 +181,7 @@ bool SessionAccessibility::Pivot(int32_t aID, int32_t aGranularity,
nsAppShell::PostEvent([this, self, virtualViewID] {
MonitorAutoLock mal(nsAccessibilityService::GetAndroidMonitor());
if (Accessible* acc = GetAccessibleByID(virtualViewID)) {
SendAccessibilityFocusedEvent(acc);
SendAccessibilityFocusedEvent(acc, true);
}
});
return true;
@ -411,13 +411,15 @@ RefPtr<SessionAccessibility> SessionAccessibility::GetInstanceFor(
}
void SessionAccessibility::SendAccessibilityFocusedEvent(
Accessible* aAccessible) {
Accessible* aAccessible, bool aScrollIntoView) {
MOZ_ASSERT(NS_IsMainThread());
mSessionAccessibility->SendEvent(
java::sdk::AccessibilityEvent::TYPE_VIEW_ACCESSIBILITY_FOCUSED,
AccessibleWrap::GetVirtualViewID(aAccessible),
AccessibleWrap::AndroidClass(aAccessible), nullptr);
aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
if (aScrollIntoView) {
aAccessible->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
}
}
void SessionAccessibility::SendHoverEnterEvent(Accessible* aAccessible) {

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

@ -65,7 +65,8 @@ class SessionAccessibility final
int32_t aScrollY, int32_t aMaxScrollX,
int32_t aMaxScrollY);
MOZ_CAN_RUN_SCRIPT_BOUNDARY
void SendAccessibilityFocusedEvent(Accessible* aAccessible);
void SendAccessibilityFocusedEvent(Accessible* aAccessible,
bool aScrollIntoView);
void SendHoverEnterEvent(Accessible* aAccessible);
void SendTextSelectionChangedEvent(Accessible* aAccessible,
int32_t aCaretOffset);