Chromium Code Reviews| Index: webkit/api/src/WebAccessibilityCacheImpl.h |
| =================================================================== |
| --- webkit/api/src/WebAccessibilityCacheImpl.h (revision 30762) |
| +++ webkit/api/src/WebAccessibilityCacheImpl.h (working copy) |
| @@ -2,75 +2,67 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ |
| -#define WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ |
| +#ifndef WebAccessibilityCacheImpl_h |
| +#define WebAccessibilityCacheImpl_h |
| -#include "base/hash_tables.h" |
| -#include "webkit/glue/webaccessibilitymanager.h" |
| +#include "WebAccessibilityCache.h" |
| +#include <wtf/HashMap.h> |
| +#include <wtf/RefPtr.h> |
| -class GlueAccessibilityObject; |
| +namespace WebCore { |
| + 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.
|
| +} |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// |
| -// WebAccessibilityManagerImpl |
| -// |
| -// |
| -// Implements WebAccessibilityManager. |
| -// Responds to incoming accessibility requests from the browser side. Retrieves |
| -// the requested information from the active AccessibilityObject, through the |
| -// GlueAccessibilityObject. |
| -//////////////////////////////////////////////////////////////////////////////// |
| +namespace WebKit { |
| -namespace webkit_glue { |
| +class WebAccessibilityCacheImpl : public WebKit::WebAccessibilityCache { |
| +public: |
| + virtual void initialize(WebView* view); |
| + virtual bool isInitialized() const { return m_initialized; } |
| -class WebAccessibilityManagerImpl : public WebAccessibilityManager { |
| - public: |
| - // From WebAccessibilityManager. |
| - bool GetAccObjInfo(WebKit::WebView* view, |
| - const WebAccessibility::InParams& in_params, |
| - WebAccessibility::OutParams* out_params); |
| - bool ClearAccObjMap(int acc_obj_id, bool clear_all); |
| - int FocusAccObj(const WebKit::WebAccessibilityObject& object); |
| + virtual WebAccessibilityObject getObjectById(int); |
| + virtual bool isValidId(int) const; |
| + virtual int addOrGetId(const WebKit::WebAccessibilityObject&); |
| - protected: |
| - // Needed so WebAccessibilityManager::Create can call our constructor. |
| - friend class WebAccessibilityManager; |
| + virtual void remove(int); |
| + virtual void clear(); |
| - // Constructor creates a new GlueAccessibilityObjectRoot, and initializes |
| - // the root |acc_obj_id_| to 1000, to avoid conflicts with platform-specific |
| - // child ids. |
| - WebAccessibilityManagerImpl(); |
| - ~WebAccessibilityManagerImpl(); |
| +protected: |
| + friend class WebKit::WebAccessibilityCache; |
| - private: |
| - // From WebAccessibilityManager. |
| - bool InitAccObjRoot(WebKit::WebView* view); |
| + WebAccessibilityCacheImpl(); |
| + ~WebAccessibilityCacheImpl(); |
| - // Wrapper around the pointer that holds the root of the AccessibilityObject |
| - // tree, to allow the use of a scoped_refptr. |
| - struct GlueAccessibilityObjectRoot; |
| - GlueAccessibilityObjectRoot* root_; |
| +private: |
| + // FIXME: This can be just part of Chromium's AccessibilityObjectWrapper. |
| + class WeakHandle : public WebCore::AccessibilityObjectWrapper { |
| + public: |
| + static PassRefPtr<WeakHandle> create(WebCore::AccessibilityObject*); |
| + virtual void detach(); |
| + private: |
| + WeakHandle(WebCore::AccessibilityObject*); |
| + }; |
| - typedef base::hash_map<int, GlueAccessibilityObject*> IntToGlueAccObjMap; |
| - typedef base::hash_map<WebCore::AccessibilityObject*, int> AccObjToIntMap; |
| + typedef HashMap<int, RefPtr<WeakHandle> > ObjectMap; |
| + typedef HashMap<WebCore::AccessibilityObject*, int> IdMap; |
| - // Hashmap for cashing of elements in use by the AT, mapping id (int) to a |
| - // GlueAccessibilityObject pointer. |
| - IntToGlueAccObjMap int_to_glue_acc_obj_map_; |
| - // Hashmap for cashing of elements in use by the AT, mapping a |
| - // AccessibilityObject pointer to its id (int). Needed for reverse lookup, |
| - // to ensure unnecessary duplicate entries are not created in the |
| - // IntToGlueAccObjMap (above) and for focus changes in WebKit. |
| - AccObjToIntMap acc_obj_to_int_map_; |
| + // Hashmap for caching of elements in use by the AT, mapping id (int) to |
| + // WebAccessibilityObject. |
| + ObjectMap m_objectMap; |
| + // Hashmap for caching of elements in use by the AT, mapping a |
| + // AccessibilityObject pointer to its id (int). Needed for reverse lookup, |
| + // to ensure unnecessary duplicate entries are not created in the |
| + // ObjectMap and for focus changes in WebKit. |
| + IdMap m_idMap; |
| - // Unique identifier for retrieving an accessibility object from the page's |
| - // hashmaps. Id is always 0 for the root of the accessibility object |
| - // hierarchy (on a per-renderer process basis). |
| - int acc_obj_id_; |
| + // Unique identifier for retrieving an accessibility object from the page's |
| + // hashmaps. Id is always 0 for the root of the accessibility object |
| + // hierarchy (on a per-renderer process basis). |
| + int m_nextNewId; |
| - DISALLOW_COPY_AND_ASSIGN(WebAccessibilityManagerImpl); |
| + bool m_initialized; |
| }; |
| -} // namespace webkit_glue |
| +} |
| -#endif // WEBKIT_GLUE_WEBACCESSIBILITYMANAGER_IMPL_H_ |
| +#endif |