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"
|
2016-06-10 00:33:48 +03:00
|
|
|
#include "DocAccessibleParent.h"
|
2015-10-01 17:00:00 +03:00
|
|
|
#include "mozTableAccessible.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.
|
2015-10-01 17:00:00 +03:00
|
|
|
// Note that we can use ProxyAccessible::IsTable* functions here because they
|
|
|
|
// do not use IPC calls but that might change after bug 1210477.
|
|
|
|
Class type;
|
|
|
|
if (aProxy->IsTable())
|
|
|
|
type = [mozTableAccessible class];
|
|
|
|
else if (aProxy->IsTableRow())
|
|
|
|
type = [mozTableRowAccessible class];
|
|
|
|
else if (aProxy->IsTableCell())
|
|
|
|
type = [mozTableCellAccessible class];
|
|
|
|
else
|
|
|
|
type = GetTypeFromRole(aProxy->Role());
|
|
|
|
|
2015-05-29 20:42:23 +03:00
|
|
|
uintptr_t accWrap = reinterpret_cast<uintptr_t>(aProxy) | IS_PROXY;
|
|
|
|
mozAccessible* mozWrapper = [[type alloc] initWithAccessible:accWrap];
|
|
|
|
aProxy->SetWrapper(reinterpret_cast<uintptr_t>(mozWrapper));
|
2016-06-10 00:33:48 +03:00
|
|
|
|
2016-06-10 00:33:48 +03:00
|
|
|
mozAccessible* nativeParent = nullptr;
|
2016-06-10 00:33:48 +03:00
|
|
|
if (aProxy->IsDoc() && aProxy->AsDoc()->IsTopLevel()) {
|
2016-06-10 00:33:48 +03:00
|
|
|
// If proxy is top level, the parent we need to invalidate the children of
|
|
|
|
// will be a non-remote accessible.
|
2016-06-10 00:33:48 +03:00
|
|
|
Accessible* outerDoc = aProxy->OuterDocOfRemoteBrowser();
|
|
|
|
if (outerDoc) {
|
2016-06-10 00:33:48 +03:00
|
|
|
nativeParent = GetNativeFromGeckoAccessible(outerDoc);
|
2016-06-10 00:33:48 +03:00
|
|
|
}
|
2016-06-10 00:33:48 +03:00
|
|
|
} else {
|
|
|
|
// Non-top level proxies need proxy parents' children invalidated.
|
|
|
|
ProxyAccessible* parent = aProxy->Parent();
|
|
|
|
nativeParent = GetNativeFromProxy(parent);
|
|
|
|
NS_ASSERTION(parent, "a non-top-level proxy is missing a parent?");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nativeParent) {
|
|
|
|
[nativeParent invalidateChildren];
|
2016-06-10 00:33:48 +03:00
|
|
|
}
|
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
|
|
|
{
|
2016-06-10 00:33:48 +03:00
|
|
|
mozAccessible* nativeParent = nil;
|
2016-06-10 00:33:48 +03:00
|
|
|
if (aProxy->IsDoc() && aProxy->AsDoc()->IsTopLevel()) {
|
2016-06-10 00:33:48 +03:00
|
|
|
// Invalidate native parent in parent process's children on proxy destruction
|
2016-06-10 00:33:48 +03:00
|
|
|
Accessible* outerDoc = aProxy->OuterDocOfRemoteBrowser();
|
|
|
|
if (outerDoc) {
|
2016-06-10 00:33:48 +03:00
|
|
|
nativeParent = GetNativeFromGeckoAccessible(outerDoc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!aProxy->Document()->IsShutdown()) {
|
|
|
|
// Only do if the document has not been shut down, else parent will return
|
|
|
|
// garbage since we don't shut down children from top down.
|
|
|
|
ProxyAccessible* parent = aProxy->Parent();
|
|
|
|
// Invalidate proxy parent's children.
|
|
|
|
if (parent) {
|
|
|
|
nativeParent = GetNativeFromProxy(parent);
|
|
|
|
}
|
2016-06-10 00:33:48 +03: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);
|
2016-06-10 00:33:48 +03:00
|
|
|
|
|
|
|
if (nativeParent) {
|
|
|
|
[nativeParent invalidateChildren];
|
|
|
|
}
|
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 &&
|
2015-11-02 23:34:51 +03:00
|
|
|
aEventType != nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE &&
|
2015-05-29 20:50:26 +03:00
|
|
|
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
|
|
|
|
2015-06-05 22:43:30 +03:00
|
|
|
void
|
|
|
|
ProxyTextChangeEvent(ProxyAccessible*, const nsString&, int32_t, uint32_t,
|
|
|
|
bool, bool)
|
|
|
|
{
|
|
|
|
}
|
2016-04-06 04:43:04 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
ProxyShowHideEvent(ProxyAccessible*, ProxyAccessible*, bool, bool)
|
|
|
|
{
|
|
|
|
}
|
2016-04-21 22:06:57 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
ProxySelectionEvent(ProxyAccessible*, ProxyAccessible*, uint32_t)
|
|
|
|
{
|
|
|
|
}
|
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
|
|
|
|
|