diff --git a/accessible/mac/AccessibleWrap.h b/accessible/mac/AccessibleWrap.h index 3a8ab84a0a3..c89613407bc 100644 --- a/accessible/mac/AccessibleWrap.h +++ b/accessible/mac/AccessibleWrap.h @@ -105,6 +105,12 @@ private: bool mNativeInited; }; +#if defined(__OBJC__) + void FireNativeEvent(mozAccessible* aNativeAcc, uint32_t aEventType); +#else + void FireNativeEvent(id aNativeAcc, uint32_t aEventType); +#endif + Class GetTypeFromRole(roles::Role aRole); } // namespace a11y diff --git a/accessible/mac/AccessibleWrap.mm b/accessible/mac/AccessibleWrap.mm index 10fded7ed96..8aa2d1b399b 100644 --- a/accessible/mac/AccessibleWrap.mm +++ b/accessible/mac/AccessibleWrap.mm @@ -112,18 +112,7 @@ AccessibleWrap::HandleAccEvent(AccEvent* aEvent) if (!nativeAcc) return NS_ERROR_FAILURE; - switch (eventType) { - case nsIAccessibleEvent::EVENT_FOCUS: - [nativeAcc didReceiveFocus]; - break; - case nsIAccessibleEvent::EVENT_VALUE_CHANGE: - [nativeAcc valueDidChange]; - break; - case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: - case nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED: - [nativeAcc selectedTextDidChange]; - break; - } + FireNativeEvent(nativeAcc, eventType); return NS_OK; @@ -234,6 +223,27 @@ AccessibleWrap::AncestorIsFlat() return false; } +void +a11y::FireNativeEvent(mozAccessible* aNativeAcc, uint32_t aEventType) +{ + NS_OBJC_BEGIN_TRY_ABORT_BLOCK; + + switch (aEventType) { + case nsIAccessibleEvent::EVENT_FOCUS: + [aNativeAcc didReceiveFocus]; + break; + case nsIAccessibleEvent::EVENT_VALUE_CHANGE: + [aNativeAcc valueDidChange]; + break; + case nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED: + case nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED: + [aNativeAcc selectedTextDidChange]; + break; + } + + NS_OBJC_END_TRY_ABORT_BLOCK; +} + Class a11y::GetTypeFromRole(roles::Role aRole) { diff --git a/accessible/mac/Platform.mm b/accessible/mac/Platform.mm index 8c8423dd88e..8b6ab64e663 100644 --- a/accessible/mac/Platform.mm +++ b/accessible/mac/Platform.mm @@ -55,21 +55,39 @@ ProxyDestroyed(ProxyAccessible* aProxy) } void -ProxyEvent(ProxyAccessible*, uint32_t) +ProxyEvent(ProxyAccessible* aProxy, uint32_t aEventType) { + // ignore everything but focus-changed, value-changed, caret and selection + // events for now. + if (aEventType != nsIAccessibleEvent::EVENT_FOCUS && + aEventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE && + aEventType != nsIAccessibleEvent::EVENT_TEXT_CARET_MOVED && + aEventType != nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED) + return; + + mozAccessible* wrapper = + reinterpret_cast(aProxy->GetWrapper()); + if (wrapper) + FireNativeEvent(wrapper, aEventType); } void -ProxyStateChangeEvent(ProxyAccessible*, uint64_t, bool) +ProxyStateChangeEvent(ProxyAccessible* aProxy, uint64_t, bool) { + // mac doesn't care about state change events } void ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset) { + mozAccessible* wrapper = + reinterpret_cast(aTarget->GetWrapper()); + if (wrapper) + [wrapper selectedTextDidChange]; } -} -} + +} // namespace a11y +} // namespace mozilla @interface GeckoNSApplication(a11y) -(void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;