• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Embedded Framework Authors. Portions copyright
2 // 2013 The Chromium Authors. All rights reserved. Use of this source code is
3 // governed by a BSD-style license that can be found in the LICENSE file.
4 
5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_OSR_ACCESSIBILITY_NODE_H_
6 #define CEF_TESTS_CEFCLIENT_BROWSER_OSR_ACCESSIBILITY_NODE_H_
7 #pragma once
8 
9 #include <vector>
10 
11 #include "include/cef_browser.h"
12 
13 #if defined(OS_MAC)
14 typedef void CefNativeAccessible;
15 #if __OBJC__
16 #if __has_feature(objc_arc)
17 #define CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(accessible) \
18   (__bridge NSObject*)accessible
19 #define CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(object) \
20   (__bridge CefNativeAccessible*)object
21 #else  // __has_feature(objc_arc)
22 #define CAST_CEF_NATIVE_ACCESSIBLE_TO_NSOBJECT(accessible) (NSObject*)accessible
23 #define CAST_NSOBJECT_TO_CEF_NATIVE_ACCESSIBLE(object) \
24   (__bridge CefNativeAccessible*)object
25 #endif  // __has_feature(objc_arc)
26 #endif  // __OBJC__
27 #elif defined(OS_WIN)
28 struct IAccessible;
29 typedef IAccessible CefNativeAccessible;
30 #else
31 #error "Unsupported platform"
32 #endif
33 
34 namespace client {
35 
36 class OsrAccessibilityHelper;
37 
38 // OsrAXNode is the base class for implementation for the NSAccessibility
39 // protocol for interacting with VoiceOver and other accessibility clients.
40 class OsrAXNode {
41  public:
42   // Create and return the platform specific OsrAXNode Object.
43   static OsrAXNode* CreateNode(const CefString& treeId,
44                                int nodeId,
45                                CefRefPtr<CefDictionaryValue> value,
46                                OsrAccessibilityHelper* helper);
47 
48   // Update Value.
49   void UpdateValue(CefRefPtr<CefDictionaryValue> value);
50 
51   // UpdateLocation
52   void UpdateLocation(CefRefPtr<CefDictionaryValue> value);
53 
54   // Fire a platform-specific notification that an event has occurred on
55   // this object.
56   void NotifyAccessibilityEvent(std::string event_type) const;
57 
58   // Call Destroy rather than deleting this, because the subclass may
59   // use reference counting.
60   void Destroy();
61 
62   // Return NSAccessibility Object for Mac/ IAccessible for Windows
63   CefNativeAccessible* GetNativeAccessibleObject(OsrAXNode* parent);
64 
GetParentAccessibleObject()65   CefNativeAccessible* GetParentAccessibleObject() const {
66     return parent_ ? parent_->platform_accessibility_ : nullptr;
67   }
68 
GetAccessibilityHelper()69   OsrAccessibilityHelper* GetAccessibilityHelper() const {
70     return accessibility_helper_;
71   }
72 
73   int GetChildCount() const;
74 
75   // Return the Child at the specified index
76   OsrAXNode* ChildAtIndex(int index) const;
77 
AxRole()78   const CefString& AxRole() const { return role_; }
79 
OsrAXTreeId()80   const CefString& OsrAXTreeId() const { return tree_id_; }
81 
OsrAXNodeId()82   int OsrAXNodeId() const { return node_id_; }
83 
AxValue()84   const CefString& AxValue() const { return value_; }
85 
AxName()86   const CefString& AxName() const { return name_; }
87 
AxDescription()88   const CefString& AxDescription() const { return description_; }
89 
90   CefRect AxLocation() const;
91 
92   CefWindowHandle GetWindowHandle() const;
93 
94   CefRefPtr<CefBrowser> GetBrowser() const;
95 
96   void SetParent(OsrAXNode* parent);
97 
98  protected:
99   OsrAXNode(const CefString& treeId,
100             int nodeId,
101             CefRefPtr<CefDictionaryValue> value,
102             OsrAccessibilityHelper* helper);
103 
104   CefString tree_id_;
105   int node_id_;
106   CefString child_tree_id_;
107   CefString role_;
108   CefString value_;
109   CefString name_;
110   CefString description_;
111   CefRect location_;
112   CefPoint scroll_;
113   std::vector<int> child_ids_;
114   CefNativeAccessible* platform_accessibility_;
115   OsrAXNode* parent_;
116   int offset_container_id_;
117   OsrAccessibilityHelper* accessibility_helper_;
118   CefRefPtr<CefDictionaryValue> attributes_;
119 };
120 
121 }  // namespace client
122 
123 #endif  // CEF_TESTS_CEFCLIENT_BROWSER_OSR_ACCESSIBILITY_NODE_H_
124