Bug 1694573 part 2: Make Platform*Event functions take Accessible instead of RemoteAccessible. r=eeejay

Some of these methods don't yet handle LocalAccessible properly, but that will be fixed in subsequent patches.

Differential Revision: https://phabricator.services.mozilla.com/D183701
This commit is contained in:
James Teh 2023-07-19 02:56:53 +00:00
Родитель 7e43083f11
Коммит 4d2410a13e
6 изменённых файлов: 90 добавлений и 95 удалений

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

@ -84,7 +84,7 @@ void a11y::ProxyDestroyed(RemoteAccessible* aProxy) {
SessionAccessibility::UnregisterAccessible(aProxy);
}
void a11y::PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType) {
void a11y::PlatformEvent(Accessible* aTarget, uint32_t aEventType) {
RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
if (!sessionAcc) {
@ -100,7 +100,7 @@ void a11y::PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType) {
}
}
void a11y::PlatformStateChangeEvent(RemoteAccessible* aTarget, uint64_t aState,
void a11y::PlatformStateChangeEvent(Accessible* aTarget, uint64_t aState,
bool aEnabled) {
RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
@ -131,7 +131,7 @@ void a11y::PlatformStateChangeEvent(RemoteAccessible* aTarget, uint64_t aState,
}
}
void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
void a11y::PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect) {
if (RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget)) {
@ -139,7 +139,7 @@ void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
}
}
void a11y::PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed,
int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect) {
@ -151,10 +151,9 @@ void a11y::PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
}
}
void a11y::PlatformTextChangeEvent(RemoteAccessible* aTarget,
const nsAString& aStr, int32_t aStart,
uint32_t aLen, bool aIsInsert,
bool aFromUser) {
void a11y::PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr,
int32_t aStart, uint32_t aLen,
bool aIsInsert, bool aFromUser) {
RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
@ -164,19 +163,17 @@ void a11y::PlatformTextChangeEvent(RemoteAccessible* aTarget,
}
}
void a11y::PlatformShowHideEvent(RemoteAccessible* aTarget,
RemoteAccessible* aParent, bool aInsert,
bool aFromUser) {
void a11y::PlatformShowHideEvent(Accessible* aTarget, Accessible* aParent,
bool aInsert, bool aFromUser) {
// We rely on the window content changed events to be dispatched
// after the viewport cache is refreshed.
}
void a11y::PlatformSelectionEvent(RemoteAccessible*, RemoteAccessible*,
uint32_t) {}
void a11y::PlatformSelectionEvent(Accessible*, Accessible*, uint32_t) {}
void a11y::PlatformVirtualCursorChangeEvent(RemoteAccessible* aTarget,
RemoteAccessible* aOldPosition,
RemoteAccessible* aNewPosition,
void a11y::PlatformVirtualCursorChangeEvent(Accessible* aTarget,
Accessible* aOldPosition,
Accessible* aNewPosition,
int16_t aReason, bool aFromUser) {
if (!aNewPosition || !aFromUser) {
return;
@ -196,10 +193,9 @@ void a11y::PlatformVirtualCursorChangeEvent(RemoteAccessible* aTarget,
}
}
void a11y::PlatformScrollingEvent(RemoteAccessible* aTarget,
uint32_t aEventType, uint32_t aScrollX,
uint32_t aScrollY, uint32_t aMaxScrollX,
uint32_t aMaxScrollY) {
void a11y::PlatformScrollingEvent(Accessible* aTarget, uint32_t aEventType,
uint32_t aScrollX, uint32_t aScrollY,
uint32_t aMaxScrollX, uint32_t aMaxScrollY) {
if (aEventType == nsIAccessibleEvent::EVENT_SCROLLING) {
RefPtr<SessionAccessibility> sessionAcc =
SessionAccessibility::GetInstanceFor(aTarget);
@ -211,7 +207,7 @@ void a11y::PlatformScrollingEvent(RemoteAccessible* aTarget,
}
}
void a11y::PlatformAnnouncementEvent(RemoteAccessible* aTarget,
void a11y::PlatformAnnouncementEvent(Accessible* aTarget,
const nsAString& aAnnouncement,
uint16_t aPriority) {
RefPtr<SessionAccessibility> sessionAcc =

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

@ -1230,7 +1230,7 @@ nsresult AccessibleWrap::HandleAccEvent(AccEvent* aEvent) {
return NS_OK;
}
void a11y::PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType) {
void a11y::PlatformEvent(Accessible* aTarget, uint32_t aEventType) {
AtkObject* wrapper = GetWrapperFor(aTarget);
switch (aEventType) {
@ -1277,13 +1277,13 @@ void a11y::PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType) {
}
}
void a11y::PlatformStateChangeEvent(RemoteAccessible* aTarget, uint64_t aState,
void a11y::PlatformStateChangeEvent(Accessible* aTarget, uint64_t aState,
bool aEnabled) {
MaiAtkObject* atkObj = MAI_ATK_OBJECT(GetWrapperFor(aTarget));
atkObj->FireStateChangeEvent(aState, aEnabled);
}
void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
void a11y::PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect) {
AtkObject* wrapper = GetWrapperFor(aTarget);
@ -1291,7 +1291,7 @@ void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
atk_object_notify_state_change(wrapper, ATK_STATE_FOCUSED, true);
}
void a11y::PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed,
int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect) {
@ -1328,10 +1328,9 @@ void MaiAtkObject::FireStateChangeEvent(uint64_t aState, bool aEnabled) {
}
}
void a11y::PlatformTextChangeEvent(RemoteAccessible* aTarget,
const nsAString& aStr, int32_t aStart,
uint32_t aLen, bool aIsInsert,
bool aFromUser) {
void a11y::PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr,
int32_t aStart, uint32_t aLen,
bool aIsInsert, bool aFromUser) {
MaiAtkObject* atkObj = MAI_ATK_OBJECT(GetWrapperFor(aTarget));
atkObj->FireTextChangeEvent(aStr, aStart, aLen, aIsInsert, aFromUser);
}
@ -1371,9 +1370,8 @@ void MaiAtkObject::FireTextChangeEvent(const nsAString& aStr, int32_t aStart,
}
}
void a11y::PlatformShowHideEvent(RemoteAccessible* aTarget,
RemoteAccessible* aParent, bool aInsert,
bool aFromUser) {
void a11y::PlatformShowHideEvent(Accessible* aTarget, Accessible* aParent,
bool aInsert, bool aFromUser) {
MaiAtkObject* obj = MAI_ATK_OBJECT(GetWrapperFor(aTarget));
obj->FireAtkShowHideEvent(GetWrapperFor(aParent), aInsert, aFromUser);
}
@ -1393,8 +1391,7 @@ void MaiAtkObject::FireAtkShowHideEvent(AtkObject* aParent, bool aIsAdded,
g_signal_emit_by_name(aParent, signal_name, indexInParent, this, nullptr);
}
void a11y::PlatformSelectionEvent(RemoteAccessible*, RemoteAccessible* aWidget,
uint32_t) {
void a11y::PlatformSelectionEvent(Accessible*, Accessible* aWidget, uint32_t) {
MaiAtkObject* obj = MAI_ATK_OBJECT(GetWrapperFor(aWidget));
g_signal_emit_by_name(obj, "selection_changed");
}

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

@ -24,6 +24,7 @@
namespace mozilla {
namespace a11y {
class Accessible;
class RemoteAccessible;
enum EPlatformDisabledState {
@ -87,36 +88,37 @@ void ProxyCreated(RemoteAccessible* aProxy);
void ProxyDestroyed(RemoteAccessible*);
/**
* Callied when an event is fired on a proxied accessible.
* Called when an event is fired on an Accessible so that platforms may fire
* events if appropriate.
*/
void PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType);
void PlatformStateChangeEvent(RemoteAccessible* aTarget, uint64_t aState,
void PlatformEvent(Accessible* aTarget, uint32_t aEventType);
void PlatformStateChangeEvent(Accessible* aTarget, uint64_t aState,
bool aEnabled);
void PlatformFocusEvent(RemoteAccessible* aTarget,
void PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect);
void PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed, int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect);
void PlatformTextChangeEvent(RemoteAccessible* aTarget, const nsAString& aStr,
void PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr,
int32_t aStart, uint32_t aLen, bool aIsInsert,
bool aFromUser);
void PlatformShowHideEvent(RemoteAccessible* aTarget, RemoteAccessible* aParent,
void PlatformShowHideEvent(Accessible* aTarget, Accessible* aParent,
bool aInsert, bool aFromUser);
void PlatformSelectionEvent(RemoteAccessible* aTarget,
RemoteAccessible* aWidget, uint32_t aType);
void PlatformSelectionEvent(Accessible* aTarget, Accessible* aWidget,
uint32_t aType);
#if defined(ANDROID)
void PlatformVirtualCursorChangeEvent(RemoteAccessible* aTarget,
RemoteAccessible* aOldPosition,
RemoteAccessible* aNewPosition,
int16_t aReason, bool aFromUser);
void PlatformVirtualCursorChangeEvent(Accessible* aTarget,
Accessible* aOldPosition,
Accessible* aNewPosition, int16_t aReason,
bool aFromUser);
void PlatformScrollingEvent(RemoteAccessible* aTarget, uint32_t aEventType,
void PlatformScrollingEvent(Accessible* aTarget, uint32_t aEventType,
uint32_t aScrollX, uint32_t aScrollY,
uint32_t aMaxScrollX, uint32_t aMaxScrollY);
void PlatformAnnouncementEvent(RemoteAccessible* aTarget,
void PlatformAnnouncementEvent(Accessible* aTarget,
const nsAString& aAnnouncement,
uint16_t aPriority);
@ -126,10 +128,9 @@ bool LocalizeString(const nsAString& aToken, nsAString& aLocalized);
#ifdef MOZ_WIDGET_COCOA
class TextRangeData;
void PlatformTextSelectionChangeEvent(
RemoteAccessible* aTarget, const nsTArray<TextRangeData>& aSelection);
Accessible* aTarget, const nsTArray<TextRangeData>& aSelection);
void PlatformRoleChangedEvent(RemoteAccessible* aTarget,
const a11y::role& aRole,
void PlatformRoleChangedEvent(Accessible* aTarget, const a11y::role& aRole,
uint8_t aRoleMapEntryIndex);
#endif

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

@ -15,6 +15,7 @@
#include "mozTableAccessible.h"
#include "mozTextAccessible.h"
#include "MOXWebAreaAccessible.h"
#include "nsAccUtils.h"
#include "nsAppShell.h"
#include "nsCocoaUtils.h"
@ -82,7 +83,7 @@ void ProxyDestroyed(RemoteAccessible* aProxy) {
}
}
void PlatformEvent(RemoteAccessible* aProxy, uint32_t aEventType) {
void PlatformEvent(Accessible* aTarget, uint32_t aEventType) {
// Ignore event that we don't escape below, they aren't yet supported.
if (aEventType != nsIAccessibleEvent::EVENT_ALERT &&
aEventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE &&
@ -97,33 +98,33 @@ void PlatformEvent(RemoteAccessible* aProxy, uint32_t aEventType) {
return;
}
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aProxy);
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget);
if (wrapper) {
[wrapper handleAccessibleEvent:aEventType];
}
}
void PlatformStateChangeEvent(RemoteAccessible* aProxy, uint64_t aState,
void PlatformStateChangeEvent(Accessible* aTarget, uint64_t aState,
bool aEnabled) {
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aProxy);
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget);
if (wrapper) {
[wrapper stateChanged:aState isEnabled:aEnabled];
}
}
void PlatformFocusEvent(RemoteAccessible* aTarget,
void PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect) {
if (mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget)) {
[wrapper handleAccessibleEvent:nsIAccessibleEvent::EVENT_FOCUS];
}
}
void PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed, int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect) {
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget);
MOXTextMarkerDelegate* delegate =
[MOXTextMarkerDelegate getOrCreateForDoc:aTarget->Document()];
MOXTextMarkerDelegate* delegate = [MOXTextMarkerDelegate
getOrCreateForDoc:nsAccUtils::DocumentFor(aTarget)];
[delegate setCaretOffset:aTarget at:aOffset moveGranularity:aGranularity];
if (aIsSelectionCollapsed) {
// If selection is collapsed, invalidate selection.
@ -142,13 +143,13 @@ void PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
}
}
void PlatformTextChangeEvent(RemoteAccessible* aTarget, const nsAString& aStr,
void PlatformTextChangeEvent(Accessible* aTarget, const nsAString& aStr,
int32_t aStart, uint32_t aLen, bool aIsInsert,
bool aFromUser) {
RemoteAccessible* acc = aTarget;
Accessible* acc = aTarget;
// If there is a text input ancestor, use it as the event source.
while (acc && GetTypeFromRole(acc->Role()) != [mozTextAccessible class]) {
acc = acc->RemoteParent();
acc = acc->Parent();
}
mozAccessible* wrapper = GetNativeFromGeckoAccessible(acc ? acc : aTarget);
[wrapper handleAccessibleTextChangeEvent:nsCocoaUtils::ToNSString(aStr)
@ -157,10 +158,10 @@ void PlatformTextChangeEvent(RemoteAccessible* aTarget, const nsAString& aStr,
at:aStart];
}
void PlatformShowHideEvent(RemoteAccessible*, RemoteAccessible*, bool, bool) {}
void PlatformShowHideEvent(Accessible*, Accessible*, bool, bool) {}
void PlatformSelectionEvent(RemoteAccessible* aTarget,
RemoteAccessible* aWidget, uint32_t aEventType) {
void PlatformSelectionEvent(Accessible* aTarget, Accessible* aWidget,
uint32_t aEventType) {
mozAccessible* wrapper = GetNativeFromGeckoAccessible(aWidget);
if (wrapper) {
[wrapper handleAccessibleEvent:aEventType];
@ -168,11 +169,12 @@ void PlatformSelectionEvent(RemoteAccessible* aTarget,
}
void PlatformTextSelectionChangeEvent(
RemoteAccessible* aTarget, const nsTArray<TextRangeData>& aSelection) {
Accessible* aTarget, const nsTArray<TextRangeData>& aSelection) {
if (aSelection.Length()) {
MOXTextMarkerDelegate* delegate =
[MOXTextMarkerDelegate getOrCreateForDoc:aTarget->Document()];
DocAccessibleParent* doc = aTarget->Document();
// XXX Don't assume aTarget is remote.
MOXTextMarkerDelegate* delegate = [MOXTextMarkerDelegate
getOrCreateForDoc:aTarget->AsRemote()->Document()];
DocAccessibleParent* doc = aTarget->AsRemote()->Document();
RemoteAccessible* startContainer =
doc->GetAccessible(aSelection[0].StartID());
RemoteAccessible* endContainer = doc->GetAccessible(aSelection[0].EndID());
@ -190,8 +192,7 @@ void PlatformTextSelectionChangeEvent(
}
}
void PlatformRoleChangedEvent(RemoteAccessible* aTarget,
const a11y::role& aRole,
void PlatformRoleChangedEvent(Accessible* aTarget, const a11y::role& aRole,
uint8_t aRoleMapEntryIndex) {
if (mozAccessible* wrapper = GetNativeFromGeckoAccessible(aTarget)) {
[wrapper handleRoleChanged:aRole];

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

@ -17,23 +17,21 @@ void a11y::ProxyCreated(RemoteAccessible*) {}
void a11y::ProxyDestroyed(RemoteAccessible*) {}
void a11y::PlatformEvent(RemoteAccessible*, uint32_t) {}
void a11y::PlatformEvent(Accessible*, uint32_t) {}
void a11y::PlatformStateChangeEvent(RemoteAccessible*, uint64_t, bool) {}
void a11y::PlatformStateChangeEvent(Accessible*, uint64_t, bool) {}
void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
void a11y::PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect) {}
void a11y::PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed,
int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect) {}
void a11y::PlatformTextChangeEvent(RemoteAccessible*, const nsAString&, int32_t,
void a11y::PlatformTextChangeEvent(Accessible*, const nsAString&, int32_t,
uint32_t, bool, bool) {}
void a11y::PlatformShowHideEvent(RemoteAccessible*, RemoteAccessible*, bool,
bool) {}
void a11y::PlatformShowHideEvent(Accessible*, Accessible*, bool, bool) {}
void a11y::PlatformSelectionEvent(RemoteAccessible*, RemoteAccessible*,
uint32_t) {}
void a11y::PlatformSelectionEvent(Accessible*, Accessible*, uint32_t) {}

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

@ -66,18 +66,18 @@ void a11y::ProxyDestroyed(RemoteAccessible* aProxy) {
}
}
void a11y::PlatformEvent(RemoteAccessible* aTarget, uint32_t aEventType) {
void a11y::PlatformEvent(Accessible* aTarget, uint32_t aEventType) {
MsaaAccessible::FireWinEvent(aTarget, aEventType);
}
void a11y::PlatformStateChangeEvent(RemoteAccessible* aTarget, uint64_t, bool) {
void a11y::PlatformStateChangeEvent(Accessible* aTarget, uint64_t, bool) {
MsaaAccessible::FireWinEvent(aTarget, nsIAccessibleEvent::EVENT_STATE_CHANGE);
}
void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
void a11y::PlatformFocusEvent(Accessible* aTarget,
const LayoutDeviceIntRect& aCaretRect) {
FocusManager* focusMgr = FocusMgr();
if (focusMgr && focusMgr->FocusedLocalAccessible()) {
if (aTarget->IsRemote() && FocusMgr() &&
FocusMgr()->FocusedLocalAccessible()) {
// This is a focus event from a remote document, but focus has moved out
// of that document into the chrome since that event was sent. For example,
// this can happen when choosing File menu -> New Tab. See bug 1471466.
@ -88,22 +88,24 @@ void a11y::PlatformFocusEvent(RemoteAccessible* aTarget,
return;
}
AccessibleWrap::UpdateSystemCaretFor(aTarget, aCaretRect);
// XXX Don't assume aTarget is remote.
AccessibleWrap::UpdateSystemCaretFor(aTarget->AsRemote(), aCaretRect);
MsaaAccessible::FireWinEvent(aTarget, nsIAccessibleEvent::EVENT_FOCUS);
}
void a11y::PlatformCaretMoveEvent(RemoteAccessible* aTarget, int32_t aOffset,
void a11y::PlatformCaretMoveEvent(Accessible* aTarget, int32_t aOffset,
bool aIsSelectionCollapsed,
int32_t aGranularity,
const LayoutDeviceIntRect& aCaretRect) {
AccessibleWrap::UpdateSystemCaretFor(aTarget, aCaretRect);
// XXX Don't assume aTarget is remote.
AccessibleWrap::UpdateSystemCaretFor(aTarget->AsRemote(), aCaretRect);
MsaaAccessible::FireWinEvent(aTarget,
nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED);
}
void a11y::PlatformTextChangeEvent(RemoteAccessible* aText,
const nsAString& aStr, int32_t aStart,
uint32_t aLen, bool aInsert, bool) {
void a11y::PlatformTextChangeEvent(Accessible* aText, const nsAString& aStr,
int32_t aStart, uint32_t aLen, bool aInsert,
bool) {
uint32_t eventType = aInsert ? nsIAccessibleEvent::EVENT_TEXT_INSERTED
: nsIAccessibleEvent::EVENT_TEXT_REMOVED;
MOZ_ASSERT(aText->IsHyperText());
@ -112,14 +114,14 @@ void a11y::PlatformTextChangeEvent(RemoteAccessible* aText,
MsaaAccessible::FireWinEvent(aText, eventType);
}
void a11y::PlatformShowHideEvent(RemoteAccessible* aTarget, RemoteAccessible*,
bool aInsert, bool) {
void a11y::PlatformShowHideEvent(Accessible* aTarget, Accessible*, bool aInsert,
bool) {
uint32_t event =
aInsert ? nsIAccessibleEvent::EVENT_SHOW : nsIAccessibleEvent::EVENT_HIDE;
MsaaAccessible::FireWinEvent(aTarget, event);
}
void a11y::PlatformSelectionEvent(RemoteAccessible* aTarget, RemoteAccessible*,
void a11y::PlatformSelectionEvent(Accessible* aTarget, Accessible*,
uint32_t aType) {
MsaaAccessible::FireWinEvent(aTarget, aType);
}