зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1624729 - Notify observer service of mac accessibility events. r=morgan,yzen
Differential Revision: https://phabricator.services.mozilla.com/D68127 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0ade2fd945
Коммит
14ca656c7f
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "Accessible-inl.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "xpcAccessibleMacInterface.h"
|
||||
#include "nsIPersistentProperties2.h"
|
||||
#include "DocAccessibleParent.h"
|
||||
#include "Relation.h"
|
||||
|
@ -1176,6 +1177,9 @@ struct RoleDescrComparator {
|
|||
}
|
||||
|
||||
- (void)postNotification:(NSString*)notification {
|
||||
// This sends events via nsIObserverService to be consumed by our mochitests.
|
||||
xpcAccessibleMacInterface::FireEvent(self, notification);
|
||||
|
||||
if (gfxPlatform::IsHeadless()) {
|
||||
// Using a headless toolkit for tests and whatnot, posting accessibility
|
||||
// notification won't work.
|
||||
|
|
|
@ -52,6 +52,9 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
|||
UNIFIED_SOURCES += [
|
||||
'xpcAccessibleMacInterface.mm'
|
||||
]
|
||||
EXPORTS += [
|
||||
'xpcAccessibleMacInterface.h',
|
||||
]
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
LOCAL_INCLUDES += [
|
||||
'/accessible/android',
|
||||
|
|
|
@ -29,6 +29,11 @@ class xpcAccessibleMacInterface : public nsIAccessibleMacInterface {
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIACCESSIBLEMACINTERFACE
|
||||
|
||||
// This sends notifications via nsIObserverService to be consumed by our
|
||||
// mochitests. aNativeObj is a NSAccessibility protocol object,
|
||||
// and aNotification is a NSString.
|
||||
static void FireEvent(id aNativeObj, id aNotification);
|
||||
|
||||
protected:
|
||||
virtual ~xpcAccessibleMacInterface();
|
||||
|
||||
|
|
|
@ -367,3 +367,22 @@ nsresult xpcAccessibleMacInterface::NSObjectToJsValue(id aObj, JSContext* aCx,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void xpcAccessibleMacInterface::FireEvent(id aNativeObj, id aNotification) {
|
||||
if (nsCOMPtr<nsIObserverService> obsService = services::GetObserverService()) {
|
||||
nsCOMPtr<nsISimpleEnumerator> observers;
|
||||
// Get all observers for the mac event topic.
|
||||
obsService->EnumerateObservers(NS_ACCESSIBLE_MAC_EVENT_TOPIC, getter_AddRefs(observers));
|
||||
if (observers) {
|
||||
bool hasObservers = false;
|
||||
observers->HasMoreElements(&hasObservers);
|
||||
// If we have observers, notify them.
|
||||
if (hasObservers) {
|
||||
nsCOMPtr<nsIAccessibleMacInterface> xpcIface = new xpcAccessibleMacInterface(aNativeObj);
|
||||
nsAutoString notificationStr;
|
||||
nsCocoaUtils::GetStringForNSString(aNotification, notificationStr);
|
||||
obsService->NotifyObservers(xpcIface, NS_ACCESSIBLE_MAC_EVENT_TOPIC, notificationStr.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче