diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-06 07:07:18 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-06 07:07:18 +0000 |
commit | 6a054ffaae82f5ac8d6b876d7c85f0d87d892e42 (patch) | |
tree | 86b4d5a0c5386f3d50742af099b5009ad1dad14d /chrome/browser/views/accessibility_event_router_views.h | |
parent | 6ca800b9b2618e6ae4b92e189a9b1ae73746e49f (diff) | |
download | chromium_src-6a054ffaae82f5ac8d6b876d7c85f0d87d892e42.zip chromium_src-6a054ffaae82f5ac8d6b876d7c85f0d87d892e42.tar.gz chromium_src-6a054ffaae82f5ac8d6b876d7c85f0d87d892e42.tar.bz2 |
Improvements to accessibility extension api support for "views":
1. Handles the new wrench menu.
2. Uses NotifyAccessibilityEvent to find out when focus changes, rather
than installing focus change listeners that need to be cleaned up.
BUG=none
TEST=Updated AccessibilityEventRouterViewsTest.TestFocusNotification
Review URL: http://codereview.chromium.org/3056045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/accessibility_event_router_views.h')
-rw-r--r-- | chrome/browser/views/accessibility_event_router_views.h | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/chrome/browser/views/accessibility_event_router_views.h b/chrome/browser/views/accessibility_event_router_views.h index 403e011..aa2054f 100644 --- a/chrome/browser/views/accessibility_event_router_views.h +++ b/chrome/browser/views/accessibility_event_router_views.h @@ -9,6 +9,7 @@ #include <string> #include "base/basictypes.h" +#include "base/gtest_prod_util.h" #include "base/hash_tables.h" #include "base/singleton.h" #include "base/task.h" @@ -18,16 +19,10 @@ class Profile; -// Allows us to use (View*) and (FocusManager*) in a hash_map with gcc. +// Allows us to use (View*) in a hash_map with gcc. #if defined(COMPILER_GCC) namespace __gnu_cxx { template<> -struct hash<views::FocusManager*> { - size_t operator()(views::FocusManager* focus_manager) const { - return reinterpret_cast<size_t>(focus_manager); - } -}; -template<> struct hash<views::View*> { size_t operator()(views::View* view) const { return reinterpret_cast<size_t>(view); @@ -51,23 +46,18 @@ struct hash<views::View*> { // // You can use Profile::PauseAccessibilityEvents to prevent a flurry // of accessibility events when a window is being created or initialized. -class AccessibilityEventRouterViews - : public views::FocusChangeListener { +class AccessibilityEventRouterViews { public: // Internal information about a particular view to override the // information we get directly from the view. struct ViewInfo { - ViewInfo() : ignore(false), focus_manager(NULL) {} + ViewInfo() : ignore(false) {} // If nonempty, will use this name instead of the view's label. std::string name; // If true, will ignore this widget and not send accessibility events. bool ignore; - - // The focus manager that this view is part of - saved because - // GetFocusManager may not succeed while a view is being deleted. - views::FocusManager* focus_manager; }; // Get the single instance of this class. @@ -94,11 +84,18 @@ class AccessibilityEventRouterViews // Forget all information about this view. void RemoveView(views::View* view); - // Implementation of views::FocusChangeListener: - virtual void FocusWillChange( - views::View* focused_before, views::View* focused_now); + // Handle an accessibility event generated by a view. + void HandleAccessibilityEvent( + views::View* view, AccessibilityTypes::Event event_type); private: + AccessibilityEventRouterViews(); + virtual ~AccessibilityEventRouterViews(); + + friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; + FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, + TestFocusNotification); + // Given a view, determine if it's part of a view tree that's mapped to // a profile and if so, if it's marked as accessible. void FindView(views::View* view, Profile** profile, bool* is_accessible); @@ -119,12 +116,19 @@ class AccessibilityEventRouterViews views::View* view, NotificationType type, Profile* profile); void SendMenuNotification( views::View* view, NotificationType type, Profile* profile); + void SendMenuItemNotification( + views::View* view, NotificationType type, Profile* profile); - private: - AccessibilityEventRouterViews(); - virtual ~AccessibilityEventRouterViews(); + // Return true if it's an event on a menu. + bool IsMenuEvent(views::View* view, NotificationType type); - friend struct DefaultSingletonTraits<AccessibilityEventRouterViews>; + // Recursively explore all menu items of |menu| and return in |count| + // the total number of items, and in |index| the 0-based index of + // |item|, if found. Initialize |count| to zero before calling this + // method. |index| will be unchanged if the item is not found, so + // initialize it to -1 to detect this case. + void RecursiveGetMenuItemIndexAndCount( + views::View* menu, views::View* item, int* index, int* count); // The set of all view tree roots; only descendants of these will generate // accessibility notifications. @@ -133,8 +137,10 @@ class AccessibilityEventRouterViews // Extra information about specific views. base::hash_map<views::View*, ViewInfo> view_info_map_; - // Count of the number of references to each focus manager. - base::hash_map<views::FocusManager*, int> focus_manager_ref_count_; + // The profile associated with the most recent window event - used to + // figure out where to route a few events that can't be directly traced + // to a window with a profile (like menu events). + Profile* most_recent_profile_; // Used to defer handling of some events until the next time // through the event loop. |