1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_a11y_xpcAccessibleMacInterface_h_
8 #define mozilla_a11y_xpcAccessibleMacInterface_h_
10 #include "mozilla/a11y/Accessible.h"
11 #include "nsIAccessibleMacInterface.h"
13 class nsIAccessibleMacInterface
;
18 class xpcAccessibleMacNSObjectWrapper
: public nsIAccessibleMacNSObjectWrapper
{
20 explicit xpcAccessibleMacNSObjectWrapper(id aTextMarker
);
23 NS_DECL_NSIACCESSIBLEMACNSOBJECTWRAPPER
26 virtual ~xpcAccessibleMacNSObjectWrapper();
31 class xpcAccessibleMacInterface
: public xpcAccessibleMacNSObjectWrapper
,
32 public nsIAccessibleMacInterface
{
34 // Construct an xpcAccessibleMacInterface using this
35 // native object that conforms to the NSAccessibility protocol.
36 explicit xpcAccessibleMacInterface(id aNativeObj
)
37 : xpcAccessibleMacNSObjectWrapper(aNativeObj
) {}
39 // Construct an xpcAccessibleMacInterface using the native object
40 // associated with this accessible.
41 explicit xpcAccessibleMacInterface(Accessible
* aObj
);
43 NS_DECL_ISUPPORTS_INHERITED
44 NS_DECL_NSIACCESSIBLEMACINTERFACE
46 // Convert an NSObject (which can be anything, string, number, array, etc.)
47 // into a properly typed js value populated in the aResult handle.
48 static nsresult
NSObjectToJsValue(id aObj
, JSContext
* aCx
,
49 JS::MutableHandleValue aResult
);
52 virtual ~xpcAccessibleMacInterface() {}
54 // Return true if our native object responds to this selector and
55 // if it implements isAccessibilitySelectorAllowed check that it returns true
57 bool SupportsSelector(SEL aSelector
);
59 // Convert a js value to an NSObject. This is called recursively for arrays.
60 // If the conversion fails, aResult is set to an error and nil is returned.
61 id
JsValueToNSObject(JS::HandleValue aValue
, JSContext
* aCx
,
64 // Convert a js value to an NSValue NSObject. This is called
65 // by JsValueToNSObject when encountering a JS object with
66 // a "value" and "valueType" property.
67 id
JsValueToNSValue(JS::HandleObject aObject
, JSContext
* aCx
,
70 // Convert a js value to a specified NSObject. This is called
71 // by JsValueToNSObject when encountering a JS object with
72 // a "object" and "objcetType" property.
73 id
JsValueToSpecifiedNSObject(JS::HandleObject aObject
, JSContext
* aCx
,
77 xpcAccessibleMacInterface(const xpcAccessibleMacInterface
&) = delete;
78 xpcAccessibleMacInterface
& operator=(const xpcAccessibleMacInterface
&) =
82 class xpcAccessibleMacEvent
: public nsIAccessibleMacEvent
{
84 explicit xpcAccessibleMacEvent(id aNativeObj
, id aData
);
87 NS_DECL_NSIACCESSIBLEMACEVENT
;
89 // This sends notifications via nsIObserverService to be consumed by our
90 // mochitests. aNativeObj is a NSAccessibility protocol object,
91 // and aNotification is a NSString.
92 static void FireEvent(id aNativeObj
, id aNotification
, id aUserInfo
);
95 virtual ~xpcAccessibleMacEvent();
102 } // namespace mozilla