Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1393)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_win.h

Issue 2981073002: Move BrowserAccessibilityRelation code to the ui/accessibility/ (Closed)
Patch Set: Force tests to calculate relationships. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ 5 #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ 6 #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 #include <oleacc.h> 10 #include <oleacc.h>
11 #include <vector>
11 12
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/win/scoped_comptr.h"
15 #include "third_party/iaccessible2/ia2_api_all.h" 17 #include "third_party/iaccessible2/ia2_api_all.h"
16 #include "ui/accessibility/ax_export.h" 18 #include "ui/accessibility/ax_export.h"
17 #include "ui/accessibility/ax_text_utils.h" 19 #include "ui/accessibility/ax_text_utils.h"
18 #include "ui/accessibility/platform/ax_platform_node_base.h" 20 #include "ui/accessibility/platform/ax_platform_node_base.h"
19 21
20 // IMPORTANT! 22 // IMPORTANT!
21 // These values are written to logs. Do not renumber or delete 23 // These values are written to logs. Do not renumber or delete
22 // existing items; add new entries to the end of the list. 24 // existing items; add new entries to the end of the list.
23 enum { 25 enum {
24 UMA_API_ACC_DO_DEFAULT_ACTION = 0, 26 UMA_API_ACC_DO_DEFAULT_ACTION = 0,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 184
183 // This must always be the last enum. It's okay for its value to 185 // This must always be the last enum. It's okay for its value to
184 // increase, but none of the other enum values may change. 186 // increase, but none of the other enum values may change.
185 UMA_API_MAX 187 UMA_API_MAX
186 }; 188 };
187 189
188 #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \ 190 #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \
189 UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX) 191 UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX)
190 192
191 namespace ui { 193 namespace ui {
194 class AXPlatformNodeWin;
192 195
193 // A simple interface for a class that wants to be notified when IAccessible2 196 // A simple interface for a class that wants to be notified when IAccessible2
194 // is used by a client, a strong indication that full accessibility support 197 // is used by a client, a strong indication that full accessibility support
195 // should be enabled. 198 // should be enabled.
196 class AX_EXPORT IAccessible2UsageObserver { 199 class AX_EXPORT IAccessible2UsageObserver {
197 public: 200 public:
198 IAccessible2UsageObserver(); 201 IAccessible2UsageObserver();
199 virtual ~IAccessible2UsageObserver(); 202 virtual ~IAccessible2UsageObserver();
200 virtual void OnIAccessible2Used() = 0; 203 virtual void OnIAccessible2Used() = 0;
201 }; 204 };
202 205
203 // Get an observer list that allows modules across the codebase to 206 // Get an observer list that allows modules across the codebase to
204 // listen to when usage of IAccessible2 is detected. 207 // listen to when usage of IAccessible2 is detected.
205 extern AX_EXPORT base::ObserverList<IAccessible2UsageObserver>& 208 extern AX_EXPORT base::ObserverList<IAccessible2UsageObserver>&
206 GetIAccessible2UsageObserverList(); 209 GetIAccessible2UsageObserverList();
207 210
211 //
212 // AXPlatformNodeRelationWin
213 //
214 // A simple implementation of IAccessibleRelation, used to represent
215 // a relationship between two accessible nodes in the tree.
216 //
217 class AXPlatformNodeRelationWin : public CComObjectRootEx<CComMultiThreadModel>,
218 public IAccessibleRelation {
219 public:
220 BEGIN_COM_MAP(AXPlatformNodeRelationWin)
221 COM_INTERFACE_ENTRY(IAccessibleRelation)
222 END_COM_MAP()
223
224 AXPlatformNodeRelationWin();
225 virtual ~AXPlatformNodeRelationWin();
226
227 void Initialize(ui::AXPlatformNodeWin* owner, const base::string16& type);
228 void AddTarget(int target_id);
229 void RemoveTarget(int target_id);
230
231 // IAccessibleRelation methods.
232 STDMETHODIMP get_relationType(BSTR* relation_type) override;
233 STDMETHODIMP get_nTargets(long* n_targets) override;
234 STDMETHODIMP get_target(long target_index, IUnknown** target) override;
235 STDMETHODIMP get_targets(long max_targets,
236 IUnknown** targets,
237 long* n_targets) override;
238 STDMETHODIMP get_localizedRelationType(BSTR* relation_type) override;
239
240 // Accessors.
241 const base::string16& get_type() const { return type_; }
242 const std::vector<int>& get_target_ids() const { return target_ids_; }
243
244 private:
245 base::string16 type_;
246 base::win::ScopedComPtr<ui::AXPlatformNodeWin> owner_;
247 std::vector<int> target_ids_;
248 };
249
208 class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) 250 class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
209 AXPlatformNodeWin 251 AXPlatformNodeWin
210 : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>), 252 : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>),
211 public IDispatchImpl<IAccessible2_2, 253 public IDispatchImpl<IAccessible2_2,
212 &IID_IAccessible2, 254 &IID_IAccessible2,
213 &LIBID_IAccessible2Lib>, 255 &LIBID_IAccessible2Lib>,
214 public IAccessibleText, 256 public IAccessibleText,
215 public IAccessibleTable, 257 public IAccessibleTable,
216 public IAccessibleTable2, 258 public IAccessibleTable2,
217 public IAccessibleTableCell, 259 public IAccessibleTableCell,
218 public IServiceProvider, 260 public IServiceProvider,
219 public AXPlatformNodeBase { 261 public AXPlatformNodeBase {
220 public: 262 public:
221 BEGIN_COM_MAP(AXPlatformNodeWin) 263 BEGIN_COM_MAP(AXPlatformNodeWin)
222 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2) 264 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2)
223 COM_INTERFACE_ENTRY(AXPlatformNodeWin) 265 COM_INTERFACE_ENTRY(AXPlatformNodeWin)
224 COM_INTERFACE_ENTRY(IAccessible) 266 COM_INTERFACE_ENTRY(IAccessible)
225 COM_INTERFACE_ENTRY(IAccessible2) 267 COM_INTERFACE_ENTRY(IAccessible2)
226 COM_INTERFACE_ENTRY(IAccessible2_2) 268 COM_INTERFACE_ENTRY(IAccessible2_2)
227 COM_INTERFACE_ENTRY(IAccessibleText) 269 COM_INTERFACE_ENTRY(IAccessibleText)
228 COM_INTERFACE_ENTRY(IAccessibleTable) 270 COM_INTERFACE_ENTRY(IAccessibleTable)
229 COM_INTERFACE_ENTRY(IAccessibleTable2) 271 COM_INTERFACE_ENTRY(IAccessibleTable2)
230 COM_INTERFACE_ENTRY(IAccessibleTableCell) 272 COM_INTERFACE_ENTRY(IAccessibleTableCell)
231 COM_INTERFACE_ENTRY(IServiceProvider) 273 COM_INTERFACE_ENTRY(IServiceProvider)
232 END_COM_MAP() 274 END_COM_MAP()
233 275
234 ~AXPlatformNodeWin() override; 276 ~AXPlatformNodeWin() override;
235 277
278 // Clear node's current relationships and set them to the default values.
279 void CalculateRelationships();
280
236 // AXPlatformNode overrides. 281 // AXPlatformNode overrides.
237 gfx::NativeViewAccessible GetNativeViewAccessible() override; 282 gfx::NativeViewAccessible GetNativeViewAccessible() override;
238 void NotifyAccessibilityEvent(ui::AXEvent event_type) override; 283 void NotifyAccessibilityEvent(ui::AXEvent event_type) override;
239 284
240 // AXPlatformNodeBase overrides. 285 // AXPlatformNodeBase overrides.
241 void Destroy() override; 286 void Destroy() override;
242 int GetIndexInParent() override; 287 int GetIndexInParent() override;
243 288
244 // 289 //
245 // IAccessible methods. 290 // IAccessible methods.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 369
325 STDMETHODIMP get_relationTargetsOfType(BSTR type, 370 STDMETHODIMP get_relationTargetsOfType(BSTR type,
326 long max_targets, 371 long max_targets,
327 IUnknown*** targets, 372 IUnknown*** targets,
328 long* n_targets) override; 373 long* n_targets) override;
329 374
330 STDMETHODIMP get_attributes(BSTR* attributes) override; 375 STDMETHODIMP get_attributes(BSTR* attributes) override;
331 376
332 STDMETHODIMP get_indexInParent(LONG* index_in_parent) override; 377 STDMETHODIMP get_indexInParent(LONG* index_in_parent) override;
333 378
379 STDMETHODIMP get_nRelations(LONG* n_relations) override;
380
381 STDMETHODIMP get_relation(LONG relation_index,
382 IAccessibleRelation** relation) override;
383
384 STDMETHODIMP get_relations(LONG max_relations,
385 IAccessibleRelation** relations,
386 LONG* n_relations) override;
334 // 387 //
335 // IAccessible2 methods not implemented. 388 // IAccessible2 methods not implemented.
336 // 389 //
337 390
338 STDMETHODIMP get_attribute(BSTR name, VARIANT* attribute) override; 391 STDMETHODIMP get_attribute(BSTR name, VARIANT* attribute) override;
339 STDMETHODIMP get_extendedRole(BSTR* extended_role) override; 392 STDMETHODIMP get_extendedRole(BSTR* extended_role) override;
340 STDMETHODIMP get_nRelations(LONG* n_relations) override;
341 STDMETHODIMP get_relation(LONG relation_index,
342 IAccessibleRelation** relation) override;
343 STDMETHODIMP get_relations(LONG max_relations,
344 IAccessibleRelation** relations,
345 LONG* n_relations) override;
346 STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override; 393 STDMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override;
347 STDMETHODIMP scrollToPoint(enum IA2CoordinateType coordinate_type, 394 STDMETHODIMP scrollToPoint(enum IA2CoordinateType coordinate_type,
348 LONG x, 395 LONG x,
349 LONG y) override; 396 LONG y) override;
350 STDMETHODIMP get_groupPosition(LONG* group_level, 397 STDMETHODIMP get_groupPosition(LONG* group_level,
351 LONG* similar_items_in_group, 398 LONG* similar_items_in_group,
352 LONG* position_in_group) override; 399 LONG* position_in_group) override;
353 STDMETHODIMP get_localizedExtendedRole( 400 STDMETHODIMP get_localizedExtendedRole(
354 BSTR* localized_extended_role) override; 401 BSTR* localized_extended_role) override;
355 STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) override; 402 STDMETHODIMP get_nExtendedStates(LONG* n_extended_states) override;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 708
662 // Many MSAA methods take a var_id parameter indicating that the operation 709 // Many MSAA methods take a var_id parameter indicating that the operation
663 // should be performed on a particular child ID, rather than this object. 710 // should be performed on a particular child ID, rather than this object.
664 // This method tries to figure out the target object from |var_id| and 711 // This method tries to figure out the target object from |var_id| and
665 // returns a pointer to the target object if it exists, otherwise nullptr. 712 // returns a pointer to the target object if it exists, otherwise nullptr.
666 // Does not return a new reference. 713 // Does not return a new reference.
667 AXPlatformNodeWin* GetTargetFromChildID(const VARIANT& var_id); 714 AXPlatformNodeWin* GetTargetFromChildID(const VARIANT& var_id);
668 715
669 // Returns true if this node is in a treegrid. 716 // Returns true if this node is in a treegrid.
670 bool IsInTreeGrid(); 717 bool IsInTreeGrid();
718
719 //
720 // For adding / removing IA2 relations.
721 //
722 void AddRelation(const base::string16& relation_type, int target_id);
723 void AddBidirectionalRelations(const base::string16& relation_type,
724 const base::string16& reverse_relation_type,
725 ui::AXIntListAttribute attribute);
726 void AddBidirectionalRelations(const base::string16& relation_type,
727 const base::string16& reverse_relation_type,
728 const std::vector<int32_t>& target_ids);
729 // Clears all the forward relations from this object to any other object and
730 // the associated reverse relations on the other objects, but leaves any
731 // reverse relations on this object alone.
732 void ClearOwnRelations();
733 void RemoveBidirectionalRelationsOfType(
734 const base::string16& relation_type,
735 const base::string16& reverse_relation_type);
736 void RemoveTargetFromRelation(const base::string16& relation_type,
737 int target_id);
738
739 // Relationships between this node and other nodes.
740 std::vector<ui::AXPlatformNodeRelationWin*> relations_;
671 }; 741 };
672 742
673 } // namespace ui 743 } // namespace ui
674 744
675 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_ 745 #endif // UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_com_win.cc ('k') | ui/accessibility/platform/ax_platform_node_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698