OLD | NEW |
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 #include <atlbase.h> | 5 #include <atlbase.h> |
6 #include <atlcom.h> | 6 #include <atlcom.h> |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/win/enum_variant.h" | 16 #include "base/win/enum_variant.h" |
17 #include "base/win/scoped_comptr.h" | 17 #include "base/win/scoped_comptr.h" |
18 #include "base/win/scoped_variant.h" | 18 #include "base/win/scoped_variant.h" |
19 #include "third_party/iaccessible2/ia2_api_all.h" | 19 #include "third_party/iaccessible2/ia2_api_all.h" |
20 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
21 #include "ui/accessibility/ax_action_data.h" | 21 #include "ui/accessibility/ax_action_data.h" |
22 #include "ui/accessibility/ax_node_data.h" | 22 #include "ui/accessibility/ax_node_data.h" |
23 #include "ui/accessibility/ax_role_properties.h" | 23 #include "ui/accessibility/ax_role_properties.h" |
24 #include "ui/accessibility/ax_text_utils.h" | 24 #include "ui/accessibility/ax_text_utils.h" |
25 #include "ui/accessibility/ax_tree_data.h" | 25 #include "ui/accessibility/ax_tree_data.h" |
26 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 26 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
27 #include "ui/accessibility/platform/ax_platform_node_win.h" | 27 #include "ui/accessibility/platform/ax_platform_node_win.h" |
28 #include "ui/accessibility/platform/ax_platform_unique_id.h" | |
29 #include "ui/base/win/atl_module.h" | 28 #include "ui/base/win/atl_module.h" |
30 #include "ui/gfx/geometry/rect_conversions.h" | 29 #include "ui/gfx/geometry/rect_conversions.h" |
31 | 30 |
32 // | 31 // |
33 // Macros to use at the top of any AXPlatformNodeWin function that implements | 32 // Macros to use at the top of any AXPlatformNodeWin function that implements |
34 // a COM interface. Because COM objects are reference counted and clients | 33 // a COM interface. Because COM objects are reference counted and clients |
35 // are completely untrusted, it's important to always first check that our | 34 // are completely untrusted, it's important to always first check that our |
36 // object is still valid, and then check that all pointer arguments are | 35 // object is still valid, and then check that all pointer arguments are |
37 // not NULL. | 36 // not NULL. |
38 // | 37 // |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // static | 299 // static |
301 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( | 300 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( |
302 gfx::NativeViewAccessible accessible) { | 301 gfx::NativeViewAccessible accessible) { |
303 if (!accessible) | 302 if (!accessible) |
304 return nullptr; | 303 return nullptr; |
305 base::win::ScopedComPtr<AXPlatformNodeWin> ax_platform_node; | 304 base::win::ScopedComPtr<AXPlatformNodeWin> ax_platform_node; |
306 accessible->QueryInterface(ax_platform_node.GetAddressOf()); | 305 accessible->QueryInterface(ax_platform_node.GetAddressOf()); |
307 return ax_platform_node.Get(); | 306 return ax_platform_node.Get(); |
308 } | 307 } |
309 | 308 |
310 using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>; | |
311 // Map from each AXPlatformNode's unique id to its instance. | |
312 base::LazyInstance<UniqueIdMap>::DestructorAtExit g_unique_id_map = | |
313 LAZY_INSTANCE_INITIALIZER; | |
314 | |
315 // static | |
316 AXPlatformNode* AXPlatformNodeWin::GetFromUniqueId(int32_t unique_id) { | |
317 UniqueIdMap* unique_ids = g_unique_id_map.Pointer(); | |
318 auto iter = unique_ids->find(unique_id); | |
319 if (iter != unique_ids->end()) | |
320 return iter->second; | |
321 | |
322 return nullptr; | |
323 } | |
324 // | 309 // |
325 // AXPlatformNodeWin | 310 // AXPlatformNodeWin |
326 // | 311 // |
327 | 312 |
328 AXPlatformNodeWin::AXPlatformNodeWin() | 313 AXPlatformNodeWin::AXPlatformNodeWin() { |
329 : unique_id_(ui::GetNextAXPlatformNodeUniqueId()) { | |
330 g_unique_id_map.Get()[unique_id_] = this; | |
331 } | 314 } |
332 | 315 |
333 AXPlatformNodeWin::~AXPlatformNodeWin() { | 316 AXPlatformNodeWin::~AXPlatformNodeWin() { |
334 for (ui::AXPlatformNodeRelationWin* relation : relations_) | 317 for (ui::AXPlatformNodeRelationWin* relation : relations_) |
335 relation->Release(); | 318 relation->Release(); |
336 if (unique_id_) | |
337 g_unique_id_map.Get().erase(unique_id_); | |
338 } | 319 } |
339 | 320 |
340 void AXPlatformNodeWin::CalculateRelationships() { | 321 void AXPlatformNodeWin::CalculateRelationships() { |
341 ClearOwnRelations(); | 322 ClearOwnRelations(); |
342 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, | 323 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, |
343 IA2_RELATION_CONTROLLED_BY, | 324 IA2_RELATION_CONTROLLED_BY, |
344 ui::AX_ATTR_CONTROLS_IDS); | 325 ui::AX_ATTR_CONTROLS_IDS); |
345 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, | 326 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, |
346 IA2_RELATION_DESCRIPTION_FOR, | 327 IA2_RELATION_DESCRIPTION_FOR, |
347 ui::AX_ATTR_DESCRIBEDBY_IDS); | 328 ui::AX_ATTR_DESCRIBEDBY_IDS); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 // AXPlatformNodeBase implementation. | 527 // AXPlatformNodeBase implementation. |
547 // | 528 // |
548 | 529 |
549 void AXPlatformNodeWin::Dispose() { | 530 void AXPlatformNodeWin::Dispose() { |
550 Release(); | 531 Release(); |
551 } | 532 } |
552 | 533 |
553 void AXPlatformNodeWin::Destroy() { | 534 void AXPlatformNodeWin::Destroy() { |
554 RemoveAlertTarget(); | 535 RemoveAlertTarget(); |
555 AXPlatformNodeBase::Destroy(); | 536 AXPlatformNodeBase::Destroy(); |
556 g_unique_id_map.Get().erase(unique_id_); | |
557 unique_id_ = 0; | |
558 } | 537 } |
559 | 538 |
560 // | 539 // |
561 // AXPlatformNode implementation. | 540 // AXPlatformNode implementation. |
562 // | 541 // |
563 | 542 |
564 gfx::NativeViewAccessible AXPlatformNodeWin::GetNativeViewAccessible() { | 543 gfx::NativeViewAccessible AXPlatformNodeWin::GetNativeViewAccessible() { |
565 return this; | 544 return this; |
566 } | 545 } |
567 | 546 |
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3389 if (container && container->GetData().role == ui::AX_ROLE_GROUP) | 3368 if (container && container->GetData().role == ui::AX_ROLE_GROUP) |
3390 container = FromNativeViewAccessible(container->GetParent()); | 3369 container = FromNativeViewAccessible(container->GetParent()); |
3391 | 3370 |
3392 if (!container) | 3371 if (!container) |
3393 return false; | 3372 return false; |
3394 | 3373 |
3395 return container->GetData().role == ui::AX_ROLE_TREE_GRID; | 3374 return container->GetData().role == ui::AX_ROLE_TREE_GRID; |
3396 } | 3375 } |
3397 | 3376 |
3398 } // namespace ui | 3377 } // namespace ui |
OLD | NEW |