diff --git a/accessible/android/AccessibleWrap.cpp b/accessible/android/AccessibleWrap.cpp index bd6e5be1fdf4..b352378fb066 100644 --- a/accessible/android/AccessibleWrap.cpp +++ b/accessible/android/AccessibleWrap.cpp @@ -169,6 +169,12 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) { event->MaxScrollY()); break; } + case nsIAccessibleEvent::EVENT_ANNOUNCEMENT: { + AccAnnouncementEvent* event = downcast_accEvent(aEvent); + sessionAcc->SendAnnouncementEvent(accessible, event->Announcement(), + event->Priority()); + break; + } default: break; } diff --git a/accessible/android/Platform.cpp b/accessible/android/Platform.cpp index 06fcf9a7c763..39109c4375f1 100644 --- a/accessible/android/Platform.cpp +++ b/accessible/android/Platform.cpp @@ -158,6 +158,18 @@ void a11y::ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType, } } +void a11y::ProxyAnnouncementEvent(ProxyAccessible* aTarget, + const nsString& aAnnouncement, + uint16_t aPriority) { + SessionAccessibility* sessionAcc = + SessionAccessibility::GetInstanceFor(aTarget); + + if (sessionAcc) { + sessionAcc->SendAnnouncementEvent(WrapperFor(aTarget), aAnnouncement, + aPriority); + } +} + void a11y::ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType, const nsTArray& aAccessibles, const nsTArray& aData) { diff --git a/accessible/android/SessionAccessibility.cpp b/accessible/android/SessionAccessibility.cpp index 3cdc33f51145..9e65d589c469 100644 --- a/accessible/android/SessionAccessibility.cpp +++ b/accessible/android/SessionAccessibility.cpp @@ -322,6 +322,20 @@ void SessionAccessibility::SendSelectedEvent(AccessibleWrap* aAccessible, aAccessible->VirtualViewID(), aAccessible->AndroidClass(), eventInfo); } +void SessionAccessibility::SendAnnouncementEvent(AccessibleWrap* aAccessible, + const nsString& aAnnouncement, + uint16_t aPriority) { + GECKOBUNDLE_START(eventInfo); + GECKOBUNDLE_PUT(eventInfo, "text", jni::StringParam(aAnnouncement)); + GECKOBUNDLE_FINISH(eventInfo); + + // Announcements should have the root as their source, so we ignore the + // accessible of the event. + mSessionAccessibility->SendEvent( + java::sdk::AccessibilityEvent::TYPE_ANNOUNCEMENT, AccessibleWrap::kNoID, + java::SessionAccessibility::CLASSNAME_WEBVIEW, eventInfo); +} + void SessionAccessibility::ReplaceViewportCache( const nsTArray& aAccessibles, const nsTArray& aData) { diff --git a/accessible/android/SessionAccessibility.h b/accessible/android/SessionAccessibility.h index 73c4af6b0483..0ba9b9b62747 100644 --- a/accessible/android/SessionAccessibility.h +++ b/accessible/android/SessionAccessibility.h @@ -96,6 +96,8 @@ class SessionAccessibility final void SendClickedEvent(AccessibleWrap* aAccessible, bool aChecked); void SendWindowContentChangedEvent(); void SendWindowStateChangedEvent(AccessibleWrap* aAccessible); + void SendAnnouncementEvent(AccessibleWrap* aAccessible, + const nsString& aAnnouncement, uint16_t aPriority); // Cache methods void ReplaceViewportCache( diff --git a/accessible/base/Platform.h b/accessible/base/Platform.h index a677199622f5..eec9ccf983c0 100644 --- a/accessible/base/Platform.h +++ b/accessible/base/Platform.h @@ -122,6 +122,9 @@ void ProxyScrollingEvent(ProxyAccessible* aTarget, uint32_t aEventType, uint32_t aScrollX, uint32_t aScrollY, uint32_t aMaxScrollX, uint32_t aMaxScrollY); +void ProxyAnnouncementEvent(ProxyAccessible* aTarget, + const nsString& aAnnouncement, uint16_t aPriority); + class BatchData; void ProxyBatch(ProxyAccessible* aDocument, const uint64_t aBatchType, diff --git a/accessible/ipc/DocAccessibleParent.cpp b/accessible/ipc/DocAccessibleParent.cpp index 52029a29d512..6aa9e6146ac4 100644 --- a/accessible/ipc/DocAccessibleParent.cpp +++ b/accessible/ipc/DocAccessibleParent.cpp @@ -442,8 +442,9 @@ mozilla::ipc::IPCResult DocAccessibleParent::RecvAnnouncementEvent( return IPC_OK(); } - // XXX: A future patch will add platform support for this event type. - // Right now, we just need to support XPC for testing. +# if defined(ANDROID) + ProxyAnnouncementEvent(target, aAnnouncement, aPriority); +# endif if (!nsCoreUtils::AccEventObserversExist()) { return IPC_OK();