Bug 1169701 - Fire native OS X accessibility events for proxied accessibles r=tbsaunde

This commit is contained in:
Lorien Hu 2015-05-29 13:50:26 -04:00
parent b774730849
commit 49a6ad2ed5
3 changed files with 50 additions and 16 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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<mozAccessible*>(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<mozAccessible*>(aTarget->GetWrapper());
if (wrapper)
[wrapper selectedTextDidChange];
}
}
}
} // namespace a11y
} // namespace mozilla
@interface GeckoNSApplication(a11y)
-(void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;