OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ | |
6 #define CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/containers/hash_tables.h" | |
10 #include "base/memory/singleton.h" | |
11 #include "content/browser/accessibility/browser_accessibility_manager.h" | |
12 #include "content/common/content_export.h" | |
13 | |
14 #if defined(COMPILER_GCC) | |
15 namespace BASE_HASH_NAMESPACE { | |
16 | |
17 template<> | |
18 struct hash<content::BrowserAccessibilityDelegate*> { | |
19 std::size_t operator()(content::BrowserAccessibilityDelegate* const& ptr) | |
20 const { | |
21 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | |
22 } | |
23 }; | |
24 | |
25 } // namespace __gnu_cxx | |
aboxhall
2014/05/06 15:41:27
BASE_HASH_NAMESPACE?
| |
26 | |
27 #elif defined(COMPILER_MSVC) | |
28 namespace stdext { | |
29 | |
30 template<> | |
31 inline size_t hash_value(content::BrowserAccessibilityDelegate* const& ptr) { | |
32 return hash_value(reinterpret_cast<size_t>(ptr)); | |
33 } | |
34 | |
35 } // namespace stdext | |
36 | |
37 #endif // COMPILER | |
38 | |
39 namespace content { | |
40 | |
41 extern const uint32 kNoFrameId; | |
42 | |
43 // This singleton manages relationships between accessibility trees that are | |
44 // nested in other accessibility trees, due to a <webview> element or | |
45 // an out-of-process iframe. Every accessible frame is identified by its | |
46 // host BrowserAccessibilityDelegate and given a unique id. | |
47 class CONTENT_EXPORT FrameTreeAccessibility { | |
48 public: | |
49 // Get the single instance of this class. | |
50 static FrameTreeAccessibility* GetInstance(); | |
51 | |
52 // The class that implements BrowserAccessibilityDelegate registers each | |
53 // frame on creation and unregisters it on deletion, and associates a | |
54 // BrowserAccessibilityManager with a frame. | |
55 void OnFrameCreated(BrowserAccessibilityDelegate* frame); | |
56 void OnFrameDeleted(BrowserAccessibilityDelegate* frame); | |
57 void SetFrameAccessibilityManager(BrowserAccessibilityDelegate* frame, | |
58 BrowserAccessibilityManager* manager); | |
59 | |
60 // When a node in an accessible tree contains a reference to an accessible | |
61 // frame, it can be looked up here. Note that it's not safe to hold onto a | |
62 // reference to a BrowserAccessibilityDelegate or BrowserAccessibilityManager | |
63 // because they could be subsequently deleted. | |
64 uint32 GetFrameId(BrowserAccessibilityDelegate* frame); | |
65 BrowserAccessibilityDelegate* FindFrameById(uint32 id); | |
66 BrowserAccessibilityManager* FindAccessibilityManagerById(uint32 id); | |
67 | |
68 protected: | |
69 FrameTreeAccessibility(); | |
70 ~FrameTreeAccessibility(); | |
71 | |
72 private: | |
73 uint32 next_id_; | |
74 base::hash_map<BrowserAccessibilityDelegate*, uint32> frame_to_id_; | |
75 base::hash_map<uint32, BrowserAccessibilityDelegate*> id_to_frame_; | |
76 base::hash_map<uint32, BrowserAccessibilityManager*> id_to_manager_; | |
77 | |
78 friend struct DefaultSingletonTraits<FrameTreeAccessibility>; | |
79 }; | |
80 | |
81 } // namespace content | |
82 | |
83 #endif // CONTENT_BROWSER_ACCESSIBILITY_FRAME_TREE_ACCESSIBILITY_H_ | |
OLD | NEW |