OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility.h" | 5 #include "content/browser/accessibility/browser_accessibility.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 24 matching lines...) Expand all Loading... |
35 // static | 35 // static |
36 BrowserAccessibility* BrowserAccessibility::Create() { | 36 BrowserAccessibility* BrowserAccessibility::Create() { |
37 return new BrowserAccessibility(); | 37 return new BrowserAccessibility(); |
38 } | 38 } |
39 #endif | 39 #endif |
40 | 40 |
41 BrowserAccessibility::BrowserAccessibility() | 41 BrowserAccessibility::BrowserAccessibility() |
42 : manager_(nullptr), | 42 : manager_(nullptr), |
43 node_(nullptr), | 43 node_(nullptr), |
44 unique_id_(ui::GetNextAXPlatformNodeUniqueId()) { | 44 unique_id_(ui::GetNextAXPlatformNodeUniqueId()) { |
45 g_unique_id_map.Get()[unique_id_] = this; | 45 g_unique_id_map.Get()[unique_id()] = this; |
46 } | 46 } |
47 | 47 |
48 BrowserAccessibility::~BrowserAccessibility() { | 48 BrowserAccessibility::~BrowserAccessibility() { |
49 if (unique_id_) | 49 if (unique_id()) |
50 g_unique_id_map.Get().erase(unique_id_); | 50 g_unique_id_map.Get().erase(unique_id()); |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 BrowserAccessibility* BrowserAccessibility::GetFromUniqueID(int32_t unique_id) { | 54 BrowserAccessibility* BrowserAccessibility::GetFromUniqueId(int32_t unique_id) { |
55 auto iter = g_unique_id_map.Get().find(unique_id); | 55 auto iter = g_unique_id_map.Get().find(unique_id); |
56 if (iter == g_unique_id_map.Get().end()) | 56 if (iter == g_unique_id_map.Get().end()) |
57 return nullptr; | 57 return nullptr; |
58 | 58 |
59 return iter->second; | 59 return iter->second; |
60 } | 60 } |
61 | 61 |
62 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager, | 62 void BrowserAccessibility::Init(BrowserAccessibilityManager* manager, |
63 ui::AXNode* node) { | 63 ui::AXNode* node) { |
64 manager_ = manager; | 64 manager_ = manager; |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 566 |
567 void BrowserAccessibility::Destroy() { | 567 void BrowserAccessibility::Destroy() { |
568 // Allow the object to fire a TextRemoved notification. | 568 // Allow the object to fire a TextRemoved notification. |
569 manager()->NotifyAccessibilityEvent( | 569 manager()->NotifyAccessibilityEvent( |
570 BrowserAccessibilityEvent::FromTreeChange, | 570 BrowserAccessibilityEvent::FromTreeChange, |
571 ui::AX_EVENT_HIDE, | 571 ui::AX_EVENT_HIDE, |
572 this); | 572 this); |
573 node_ = NULL; | 573 node_ = NULL; |
574 manager_ = NULL; | 574 manager_ = NULL; |
575 | 575 |
576 if (unique_id_) | 576 if (unique_id()) |
577 g_unique_id_map.Get().erase(unique_id_); | 577 g_unique_id_map.Get().erase(unique_id()); |
578 unique_id_ = 0; | |
579 | 578 |
580 NativeReleaseReference(); | 579 NativeReleaseReference(); |
581 } | 580 } |
582 | 581 |
583 void BrowserAccessibility::NativeReleaseReference() { | 582 void BrowserAccessibility::NativeReleaseReference() { |
584 delete this; | 583 delete this; |
585 } | 584 } |
586 | 585 |
| 586 int32_t BrowserAccessibility::unique_id() const { |
| 587 return unique_id_; |
| 588 } |
| 589 |
587 bool BrowserAccessibility::HasBoolAttribute( | 590 bool BrowserAccessibility::HasBoolAttribute( |
588 ui::AXBoolAttribute attribute) const { | 591 ui::AXBoolAttribute attribute) const { |
589 return GetData().HasBoolAttribute(attribute); | 592 return GetData().HasBoolAttribute(attribute); |
590 } | 593 } |
591 | 594 |
592 bool BrowserAccessibility::GetBoolAttribute( | 595 bool BrowserAccessibility::GetBoolAttribute( |
593 ui::AXBoolAttribute attribute) const { | 596 ui::AXBoolAttribute attribute) const { |
594 return GetData().GetBoolAttribute(attribute); | 597 return GetData().GetBoolAttribute(attribute); |
595 } | 598 } |
596 | 599 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 return false; | 1023 return false; |
1021 } | 1024 } |
1022 | 1025 |
1023 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { | 1026 bool BrowserAccessibility::ShouldIgnoreHoveredStateForTesting() { |
1024 BrowserAccessibilityStateImpl* accessibility_state = | 1027 BrowserAccessibilityStateImpl* accessibility_state = |
1025 BrowserAccessibilityStateImpl::GetInstance(); | 1028 BrowserAccessibilityStateImpl::GetInstance(); |
1026 return accessibility_state->disable_hot_tracking_for_testing(); | 1029 return accessibility_state->disable_hot_tracking_for_testing(); |
1027 } | 1030 } |
1028 | 1031 |
1029 } // namespace content | 1032 } // namespace content |
OLD | NEW |