diff --git a/accessible/android/Platform.cpp b/accessible/android/Platform.cpp index 1b670638ad2e..02f808f8bcab 100644 --- a/accessible/android/Platform.cpp +++ b/accessible/android/Platform.cpp @@ -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); } } } diff --git a/accessible/android/SessionAccessibility.cpp b/accessible/android/SessionAccessibility.cpp index 0a2e5da40e06..aab9b7da69b3 100644 --- a/accessible/android/SessionAccessibility.cpp +++ b/accessible/android/SessionAccessibility.cpp @@ -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::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) { diff --git a/accessible/android/SessionAccessibility.h b/accessible/android/SessionAccessibility.h index 58282e52f149..deacc571500d 100644 --- a/accessible/android/SessionAccessibility.h +++ b/accessible/android/SessionAccessibility.h @@ -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);