Bug 1878814: Handle Yelp suggestion as sponsored r=adw,fluent-reviewers
[gecko.git] / accessible / xpcom / xpcAccessibleMacInterface.h
blob18b5955087b010d8288a6847ca0e0e43f8cd4ffc
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;
15 namespace mozilla {
16 namespace a11y {
18 class xpcAccessibleMacNSObjectWrapper : public nsIAccessibleMacNSObjectWrapper {
19 public:
20 explicit xpcAccessibleMacNSObjectWrapper(id aTextMarker);
22 NS_DECL_ISUPPORTS
23 NS_DECL_NSIACCESSIBLEMACNSOBJECTWRAPPER
25 protected:
26 virtual ~xpcAccessibleMacNSObjectWrapper();
28 id mNativeObject;
31 class xpcAccessibleMacInterface : public xpcAccessibleMacNSObjectWrapper,
32 public nsIAccessibleMacInterface {
33 public:
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);
51 protected:
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
56 // too.
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,
62 nsresult* aResult);
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,
68 nsresult* aResult);
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,
74 nsresult* aResult);
76 private:
77 xpcAccessibleMacInterface(const xpcAccessibleMacInterface&) = delete;
78 xpcAccessibleMacInterface& operator=(const xpcAccessibleMacInterface&) =
79 delete;
82 class xpcAccessibleMacEvent : public nsIAccessibleMacEvent {
83 public:
84 explicit xpcAccessibleMacEvent(id aNativeObj, id aData);
86 NS_DECL_ISUPPORTS
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);
94 protected:
95 virtual ~xpcAccessibleMacEvent();
97 id mNativeObject;
98 id mData;
101 } // namespace a11y
102 } // namespace mozilla
104 #endif