tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

xpcAccessibleMacInterface.h (3591B)


      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/. */
      6 
      7 #ifndef mozilla_a11y_xpcAccessibleMacInterface_h_
      8 #define mozilla_a11y_xpcAccessibleMacInterface_h_
      9 
     10 #include "mozilla/a11y/Accessible.h"
     11 #include "nsIAccessibleMacInterface.h"
     12 
     13 class nsIAccessibleMacInterface;
     14 
     15 namespace mozilla {
     16 namespace a11y {
     17 
     18 class xpcAccessibleMacNSObjectWrapper : public nsIAccessibleMacNSObjectWrapper {
     19 public:
     20  explicit xpcAccessibleMacNSObjectWrapper(id aTextMarker);
     21 
     22  NS_DECL_ISUPPORTS
     23  NS_DECL_NSIACCESSIBLEMACNSOBJECTWRAPPER
     24 
     25 protected:
     26  virtual ~xpcAccessibleMacNSObjectWrapper();
     27 
     28  id mNativeObject;
     29 };
     30 
     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) {}
     38 
     39  // Construct an xpcAccessibleMacInterface using the native object
     40  // associated with this accessible.
     41  explicit xpcAccessibleMacInterface(Accessible* aObj);
     42 
     43  NS_DECL_ISUPPORTS_INHERITED
     44  NS_DECL_NSIACCESSIBLEMACINTERFACE
     45 
     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);
     50 
     51 protected:
     52  virtual ~xpcAccessibleMacInterface() {}
     53 
     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);
     58 
     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);
     63 
     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);
     69 
     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);
     75 
     76 private:
     77  xpcAccessibleMacInterface(const xpcAccessibleMacInterface&) = delete;
     78  xpcAccessibleMacInterface& operator=(const xpcAccessibleMacInterface&) =
     79      delete;
     80 };
     81 
     82 class xpcAccessibleMacEvent : public nsIAccessibleMacEvent {
     83 public:
     84  explicit xpcAccessibleMacEvent(id aNativeObj, id aData);
     85 
     86  NS_DECL_ISUPPORTS
     87  NS_DECL_NSIACCESSIBLEMACEVENT;
     88 
     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);
     93 
     94 protected:
     95  virtual ~xpcAccessibleMacEvent();
     96 
     97  id mNativeObject;
     98  id mData;
     99 };
    100 
    101 }  // namespace a11y
    102 }  // namespace mozilla
    103 
    104 #endif