2012-06-07 04:26:45 +04:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
2012-12-02 04:58:25 +04:00
|
|
|
#include "Platform.h"
|
2015-05-29 20:42:23 +03:00
|
|
|
#include "ProxyAccessible.h"
|
2012-06-07 04:26:45 +04:00
|
|
|
|
|
|
|
#include "nsAppShell.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2012-06-20 03:19:13 +04:00
|
|
|
// Mac a11y whitelisting
|
2012-06-07 04:26:45 +04:00
|
|
|
static bool sA11yShouldBeEnabled = false;
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShouldA11yBeEnabled()
|
|
|
|
{
|
2012-06-20 03:19:13 +04:00
|
|
|
EPlatformDisabledState disabledState = PlatformDisabledState();
|
|
|
|
return (disabledState == ePlatformIsForceEnabled) || ((disabledState == ePlatformIsEnabled) && sA11yShouldBeEnabled);
|
2012-06-07 04:26:45 +04:00
|
|
|
}
|
|
|
|
|
2012-12-02 04:58:25 +04:00
|
|
|
void
|
|
|
|
PlatformInit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlatformShutdown()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:35:19 +04:00
|
|
|
void
|
2015-05-29 20:42:23 +03:00
|
|
|
ProxyCreated(ProxyAccessible* aProxy, uint32_t)
|
2014-03-08 01:35:19 +04:00
|
|
|
{
|
2015-05-29 20:42:23 +03:00
|
|
|
// Pass in dummy state for now as retrieving proxy state requires IPC.
|
|
|
|
Class type = GetTypeFromRole(aProxy->Role());
|
|
|
|
uintptr_t accWrap = reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY;
|
|
|
|
mozAccessible* mozWrapper = [[type alloc] initWithAccessible:accWrap];
|
|
|
|
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(mozWrapper));
|
2014-03-08 01:35:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-29 20:42:23 +03:00
|
|
|
ProxyDestroyed(ProxyAccessible* aProxy)
|
2014-03-08 01:35:19 +04:00
|
|
|
{
|
2015-06-08 17:42:33 +03:00
|
|
|
mozAccessible* wrapper = GetNativeFromProxy(aProxy);
|
2015-05-29 20:42:23 +03:00
|
|
|
[wrapper expire];
|
|
|
|
[wrapper release];
|
|
|
|
aProxy->SetWrapper(0);
|
2014-03-08 01:35:19 +04:00
|
|
|
}
|
2014-09-30 18:00:26 +04:00
|
|
|
|
|
|
|
void
|
2015-05-29 20:50:26 +03:00
|
|
|
ProxyEvent(ProxyAccessible* aProxy, uint32_t aEventType)
|
2014-09-30 18:00:26 +04:00
|
|
|
{
|
2015-05-29 20:50:26 +03:00
|
|
|
// 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;
|
|
|
|
|
2015-06-08 17:42:33 +03:00
|
|
|
mozAccessible* wrapper = GetNativeFromProxy(aProxy);
|
2015-05-29 20:50:26 +03:00
|
|
|
if (wrapper)
|
|
|
|
FireNativeEvent(wrapper, aEventType);
|
2014-09-30 18:00:26 +04:00
|
|
|
}
|
2015-05-13 21:21:23 +03:00
|
|
|
|
|
|
|
void
|
2015-05-29 20:50:26 +03:00
|
|
|
ProxyStateChangeEvent(ProxyAccessible* aProxy, uint64_t, bool)
|
2015-05-13 21:21:23 +03:00
|
|
|
{
|
2015-05-29 20:50:26 +03:00
|
|
|
// mac doesn't care about state change events
|
2015-05-13 21:21:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ProxyCaretMoveEvent(ProxyAccessible* aTarget, int32_t aOffset)
|
|
|
|
{
|
2015-06-08 17:42:33 +03:00
|
|
|
mozAccessible* wrapper = GetNativeFromProxy(aTarget);
|
2015-05-29 20:50:26 +03:00
|
|
|
if (wrapper)
|
|
|
|
[wrapper selectedTextDidChange];
|
2015-05-13 21:21:23 +03:00
|
|
|
}
|
2015-05-29 20:50:26 +03:00
|
|
|
|
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
2012-06-07 04:26:45 +04:00
|
|
|
|
|
|
|
@interface GeckoNSApplication(a11y)
|
|
|
|
-(void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation GeckoNSApplication(a11y)
|
|
|
|
|
|
|
|
-(void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute
|
|
|
|
{
|
|
|
|
if ([attribute isEqualToString:@"AXEnhancedUserInterface"])
|
|
|
|
mozilla::a11y::sA11yShouldBeEnabled = ([value intValue] == 1);
|
|
|
|
|
|
|
|
return [super accessibilitySetValue:value forAttribute:attribute];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|