OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ | 5 #ifndef WebAccessibilityCacheImpl_h |
6 #define WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ | 6 #define WebAccessibilityCacheImpl_h |
7 | 7 |
8 #include "base/hash_tables.h" | 8 #include "WebAccessibilityCache.h" |
9 #include "webkit/glue/webaccessibilitymanager.h" | 9 #include <wtf/HashMap.h> |
10 #include <wtf/RefPtr.h> | |
10 | 11 |
11 class GlueAccessibilityObject; | 12 namespace WebCore { |
13 class AccessibilityObjectWrapper; | |
darin (slow to review)
2009/11/04 19:17:15
nit: no indentation in namespaces now-a-days
dglazkov
2009/11/04 19:50:05
Done.
| |
14 } | |
12 | 15 |
13 //////////////////////////////////////////////////////////////////////////////// | 16 namespace WebKit { |
14 // | |
15 // WebAccessibilityManagerImpl | |
16 // | |
17 // | |
18 // Implements WebAccessibilityManager. | |
19 // Responds to incoming accessibility requests from the browser side. Retrieves | |
20 // the requested information from the active AccessibilityObject, through the | |
21 // GlueAccessibilityObject. | |
22 //////////////////////////////////////////////////////////////////////////////// | |
23 | 17 |
24 namespace webkit_glue { | 18 class WebAccessibilityCacheImpl : public WebKit::WebAccessibilityCache { |
19 public: | |
20 virtual void initialize(WebView* view); | |
21 virtual bool isInitialized() const { return m_initialized; } | |
25 | 22 |
26 class WebAccessibilityManagerImpl : public WebAccessibilityManager { | 23 virtual WebAccessibilityObject getObjectById(int); |
27 public: | 24 virtual bool isValidId(int) const; |
28 // From WebAccessibilityManager. | 25 virtual int addOrGetId(const WebKit::WebAccessibilityObject&); |
29 bool GetAccObjInfo(WebKit::WebView* view, | |
30 const WebAccessibility::InParams& in_params, | |
31 WebAccessibility::OutParams* out_params); | |
32 bool ClearAccObjMap(int acc_obj_id, bool clear_all); | |
33 int FocusAccObj(const WebKit::WebAccessibilityObject& object); | |
34 | 26 |
35 protected: | 27 virtual void remove(int); |
36 // Needed so WebAccessibilityManager::Create can call our constructor. | 28 virtual void clear(); |
37 friend class WebAccessibilityManager; | |
38 | 29 |
39 // Constructor creates a new GlueAccessibilityObjectRoot, and initializes | 30 protected: |
40 // the root |acc_obj_id_| to 1000, to avoid conflicts with platform-specific | 31 friend class WebKit::WebAccessibilityCache; |
41 // child ids. | |
42 WebAccessibilityManagerImpl(); | |
43 ~WebAccessibilityManagerImpl(); | |
44 | 32 |
45 private: | 33 WebAccessibilityCacheImpl(); |
46 // From WebAccessibilityManager. | 34 ~WebAccessibilityCacheImpl(); |
47 bool InitAccObjRoot(WebKit::WebView* view); | |
48 | 35 |
49 // Wrapper around the pointer that holds the root of the AccessibilityObject | 36 private: |
50 // tree, to allow the use of a scoped_refptr. | 37 // FIXME: This can be just part of Chromium's AccessibilityObjectWrapper. |
51 struct GlueAccessibilityObjectRoot; | 38 class WeakHandle : public WebCore::AccessibilityObjectWrapper { |
52 GlueAccessibilityObjectRoot* root_; | 39 public: |
40 static PassRefPtr<WeakHandle> create(WebCore::AccessibilityObject*); | |
41 virtual void detach(); | |
42 private: | |
43 WeakHandle(WebCore::AccessibilityObject*); | |
44 }; | |
53 | 45 |
54 typedef base::hash_map<int, GlueAccessibilityObject*> IntToGlueAccObjMap; | 46 typedef HashMap<int, RefPtr<WeakHandle> > ObjectMap; |
55 typedef base::hash_map<WebCore::AccessibilityObject*, int> AccObjToIntMap; | 47 typedef HashMap<WebCore::AccessibilityObject*, int> IdMap; |
56 | 48 |
57 // Hashmap for cashing of elements in use by the AT, mapping id (int) to a | 49 // Hashmap for caching of elements in use by the AT, mapping id (int) to |
58 // GlueAccessibilityObject pointer. | 50 // WebAccessibilityObject. |
59 IntToGlueAccObjMap int_to_glue_acc_obj_map_; | 51 ObjectMap m_objectMap; |
60 // Hashmap for cashing of elements in use by the AT, mapping a | 52 // Hashmap for caching of elements in use by the AT, mapping a |
61 // AccessibilityObject pointer to its id (int). Needed for reverse lookup, | 53 // AccessibilityObject pointer to its id (int). Needed for reverse lookup, |
62 // to ensure unnecessary duplicate entries are not created in the | 54 // to ensure unnecessary duplicate entries are not created in the |
63 // IntToGlueAccObjMap (above) and for focus changes in WebKit. | 55 // ObjectMap and for focus changes in WebKit. |
64 AccObjToIntMap acc_obj_to_int_map_; | 56 IdMap m_idMap; |
65 | 57 |
66 // Unique identifier for retrieving an accessibility object from the page's | 58 // Unique identifier for retrieving an accessibility object from the page's |
67 // hashmaps. Id is always 0 for the root of the accessibility object | 59 // hashmaps. Id is always 0 for the root of the accessibility object |
68 // hierarchy (on a per-renderer process basis). | 60 // hierarchy (on a per-renderer process basis). |
69 int acc_obj_id_; | 61 int m_nextNewId; |
70 | 62 |
71 DISALLOW_COPY_AND_ASSIGN(WebAccessibilityManagerImpl); | 63 bool m_initialized; |
72 }; | 64 }; |
73 | 65 |
74 } // namespace webkit_glue | 66 } |
75 | 67 |
76 #endif // WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ | 68 #endif |
OLD | NEW |