mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1624729 - Introduce nsIAccessibleMacInterface as mac native xpc interface. r=yzen,morgan
Differential Revision: https://phabricator.services.mozilla.com/D68123 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
325f958e21
commit
95c476b280
@ -7,6 +7,9 @@
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows' and CONFIG['COMPILE_ENVIRONMENT']:
|
||||
DIRS += ['gecko', 'msaa', 'ia2']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
XPIDL_SOURCES += ['nsIAccessibleMacInterface.idl']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIAccessibilityService.idl',
|
||||
'nsIAccessible.idl',
|
||||
|
40
accessible/interfaces/nsIAccessibleMacInterface.idl
Normal file
40
accessible/interfaces/nsIAccessibleMacInterface.idl
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* 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/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#define NS_ACCESSIBLE_MAC_EVENT_TOPIC "accessible-mac-event"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(9d27cf21-66fc-47dc-8a07-98edb18707b1)]
|
||||
interface nsIAccessibleMacInterface : nsISupports
|
||||
{
|
||||
/**
|
||||
* List of available attribute names for tthe object.
|
||||
* Emulates `AXUIElementCopyAttributeNames`.
|
||||
*/
|
||||
readonly attribute Array<AString> attributeNames;
|
||||
|
||||
/**
|
||||
* List of available action names for tthe object.
|
||||
* Emulates `AXUIElementCopyActionNames`.
|
||||
*/
|
||||
readonly attribute Array<AString> actionNames;
|
||||
|
||||
/**
|
||||
* Returns the value of an attribute.
|
||||
* Emulates `AXUIElementCopyAttributeValue`.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
jsval getAttributeValue(in AString attributeName);
|
||||
|
||||
/**
|
||||
* Requests that the accessibility object perform the specified action.
|
||||
* Emulatets `AXUIElementPerformAction`.
|
||||
*/
|
||||
void performAction(in AString actionName);
|
||||
};
|
||||
|
@ -53,6 +53,8 @@ class AccessibleWrap : public Accessible {
|
||||
virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
|
||||
|
||||
protected:
|
||||
friend class xpcAccessibleMacInterface;
|
||||
|
||||
/**
|
||||
* Return true if the parent doesn't have children to expose to AT.
|
||||
*/
|
||||
|
@ -45,8 +45,13 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
|
||||
]
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
LOCAL_INCLUDES += [
|
||||
'/accessible/ipc',
|
||||
'/accessible/ipc/other',
|
||||
'/accessible/mac',
|
||||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'xpcAccessibleMacInterface.mm'
|
||||
]
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||
LOCAL_INCLUDES += [
|
||||
'/accessible/android',
|
||||
|
@ -18,6 +18,10 @@
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsPersistentProperties.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
# include "xpcAccessibleMacInterface.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -385,7 +389,19 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessible::GetNativeInterface(nsISupports** aNativeInterface) {
|
||||
#ifdef MOZ_WIDGET_COCOA
|
||||
NS_ENSURE_ARG_POINTER(aNativeInterface);
|
||||
|
||||
// We don't cache or store this instance anywhere so each get returns a
|
||||
// different instance. So `acc.nativeInterface != acc.nativeInterface`. This
|
||||
// just seems simpler and more robust for now.
|
||||
nsCOMPtr<nsISupports> macIface = new xpcAccessibleMacInterface(IntlGeneric());
|
||||
macIface.swap(*aNativeInterface);
|
||||
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
46
accessible/xpcom/xpcAccessibleMacInterface.h
Normal file
46
accessible/xpcom/xpcAccessibleMacInterface.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: 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/. */
|
||||
|
||||
#ifndef mozilla_a11y_xpcAccessibleMacInterface_h_
|
||||
#define mozilla_a11y_xpcAccessibleMacInterface_h_
|
||||
|
||||
#include "nsIAccessibleMacInterface.h"
|
||||
|
||||
#include "AccessibleOrProxy.h"
|
||||
|
||||
class nsIAccessibleMacInterface;
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
|
||||
class xpcAccessibleMacInterface : public nsIAccessibleMacInterface {
|
||||
public:
|
||||
// Construct an xpcAccessibleMacInterface using the native object
|
||||
// associated with this accessible or proxy.
|
||||
explicit xpcAccessibleMacInterface(AccessibleOrProxy aObj);
|
||||
|
||||
// Construct an xpcAccessibleMacInterface using this
|
||||
// native object that conforms to the NSAccessibility protocol.
|
||||
explicit xpcAccessibleMacInterface(id aNativeObj);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIACCESSIBLEMACINTERFACE
|
||||
|
||||
protected:
|
||||
virtual ~xpcAccessibleMacInterface();
|
||||
|
||||
id mNativeObject;
|
||||
|
||||
private:
|
||||
xpcAccessibleMacInterface(const xpcAccessibleMacInterface&) = delete;
|
||||
xpcAccessibleMacInterface& operator=(const xpcAccessibleMacInterface&) =
|
||||
delete;
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
#endif
|
41
accessible/xpcom/xpcAccessibleMacInterface.mm
Normal file
41
accessible/xpcom/xpcAccessibleMacInterface.mm
Normal file
@ -0,0 +1,41 @@
|
||||
/* -*- Mode: 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/. */
|
||||
|
||||
#include "xpcAccessibleMacInterface.h"
|
||||
|
||||
#import "mozAccessible.h"
|
||||
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
NS_IMPL_ISUPPORTS(xpcAccessibleMacInterface, nsIAccessibleMacInterface)
|
||||
|
||||
xpcAccessibleMacInterface::xpcAccessibleMacInterface(AccessibleOrProxy aObj) {
|
||||
mNativeObject = aObj.IsProxy()
|
||||
? GetNativeFromProxy(aObj.AsProxy())
|
||||
: static_cast<AccessibleWrap*>(aObj.AsAccessible())->GetNativeObject();
|
||||
[mNativeObject retain];
|
||||
}
|
||||
|
||||
xpcAccessibleMacInterface::xpcAccessibleMacInterface(id aNativeObj) : mNativeObject(aNativeObj) {
|
||||
[mNativeObject retain];
|
||||
}
|
||||
|
||||
xpcAccessibleMacInterface::~xpcAccessibleMacInterface() { [mNativeObject release]; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetAttributeNames(nsTArray<nsString>& aAttributeNames) { return NS_OK; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetActionNames(nsTArray<nsString>& aActionNames) { return NS_OK; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::PerformAction(const nsAString& aActionName) { return NS_OK; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleMacInterface::GetAttributeValue(const nsAString& aAttributeName, JSContext* aCx,
|
||||
JS::MutableHandleValue aResult) {
|
||||
return NS_OK;
|
||||
}
|
Loading…
Reference in New Issue
Block a user