Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/browser/accessibility/browser_accessibility_manager_win.h

Issue 3582015: Revert 61704 - Make BrowserAccessibilityManager cross platform. Step 2. In Pr... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Deleted: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_ 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_ 6 #define CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <atlbase.h>
10 #include <atlcom.h>
11 #include <oleacc.h>
12
13 #include <hash_map>
14 #include <vector>
15
16 #include "chrome/browser/accessibility/browser_accessibility_manager.h"
17 #include "base/hash_tables.h"
9 #include "base/scoped_comptr_win.h" 18 #include "base/scoped_comptr_win.h"
10 #include "chrome/browser/accessibility/browser_accessibility_manager.h" 19 #include "base/scoped_ptr.h"
11 #include "chrome/common/render_messages_params.h"
12 #include "webkit/glue/webaccessibility.h" 20 #include "webkit/glue/webaccessibility.h"
13 21
14 class BrowserAccessibilityWin; 22 class BrowserAccessibilityWin;
15 struct ViewHostMsg_AccessibilityNotification_Params; 23 struct ViewHostMsg_AccessibilityNotification_Params;
16 24
17 using webkit_glue::WebAccessibility; 25 class BrowserAccessibilityWinFactory {
26 public:
27 virtual ~BrowserAccessibilityWinFactory() {}
28
29 // Create an instance of BrowserAccessibilityWin and return a new
30 // reference to it.
31 virtual BrowserAccessibilityWin* Create();
32 };
18 33
19 // Manages a tree of BrowserAccessibilityWin objects. 34 // Manages a tree of BrowserAccessibilityWin objects.
20 class BrowserAccessibilityManagerWin : public BrowserAccessibilityManager { 35 class BrowserAccessibilityManagerWin : public BrowserAccessibilityManager {
21 public: 36 public:
37 BrowserAccessibilityManagerWin(
38 HWND parent_window,
39 const webkit_glue::WebAccessibility& src,
40 BrowserAccessibilityDelegate* delegate,
41 BrowserAccessibilityWinFactory* factory =
42 new BrowserAccessibilityWinFactory());
43
22 virtual ~BrowserAccessibilityManagerWin(); 44 virtual ~BrowserAccessibilityManagerWin();
23 45
46 // Return a pointer to the root of the tree, does not make a new reference.
47 BrowserAccessibilityWin* GetRoot();
48
49 // Removes the BrowserAccessibilityWin child_id from the manager.
50 void Remove(LONG child_id);
51
52 // Return a pointer to the object corresponding to the given child_id,
53 // does not make a new reference.
54 BrowserAccessibilityWin* GetFromChildID(LONG child_id);
55
24 // Get a the default IAccessible for the parent window, does not make a 56 // Get a the default IAccessible for the parent window, does not make a
25 // new reference. 57 // new reference.
26 IAccessible* GetParentWindowIAccessible(); 58 IAccessible* GetParentWindowIAccessible();
27 59
28 // BrowserAccessibilityManager methods 60 // Return the object that has focus, if it's a descandant of the
29 virtual void NotifyAccessibilityEvent( 61 // given root (inclusive). Does not make a new reference.
30 ViewHostMsg_AccessibilityNotification_Params::NotificationType n, 62 BrowserAccessibilityWin* GetFocus(BrowserAccessibilityWin* root);
31 BrowserAccessibility* node); 63
64 // Tell the renderer to set focus to this node.
65 void SetFocus(const BrowserAccessibilityWin& node);
66
67 // Tell the renderer to do the default action for this node.
68 void DoDefaultAction(const BrowserAccessibilityWin& node);
69
70 // BrowserAccessibilityManager Methods
71 virtual void GotFocus();
72 virtual IAccessible* GetRootAccessible();
73 virtual void OnAccessibilityObjectStateChange(
74 const webkit_glue::WebAccessibility& acc_obj);
75 virtual void OnAccessibilityObjectChildrenChange(
76 const webkit_glue::WebAccessibility& acc_obj);
77 virtual void OnAccessibilityObjectFocusChange(
78 const webkit_glue::WebAccessibility& acc_obj);
79 virtual void OnAccessibilityObjectLoadComplete(
80 const webkit_glue::WebAccessibility& acc_obj);
81 virtual void OnAccessibilityObjectValueChange(
82 const webkit_glue::WebAccessibility& acc_obj);
83 virtual void OnAccessibilityObjectTextChange(
84 const webkit_glue::WebAccessibility& acc_obj);
32 85
33 private: 86 private:
34 BrowserAccessibilityManagerWin( 87 // Recursively compare the IDs of our subtree to a new subtree received
35 HWND parent_window, 88 // from the renderer and return true if their IDs match exactly.
36 const WebAccessibility& src, 89 bool CanModifyTreeInPlace(
37 BrowserAccessibilityDelegate* delegate, 90 BrowserAccessibilityWin* current_root,
38 BrowserAccessibilityFactory* factory); 91 const webkit_glue::WebAccessibility& new_root);
92
93 // Recursively modify a subtree (by reinitializing) to match a new
94 // subtree received from the renderer process. Should only be called
95 // if CanModifyTreeInPlace returned true.
96 void ModifyTreeInPlace(
97 BrowserAccessibilityWin* current_root,
98 const webkit_glue::WebAccessibility& new_root);
99
100 // Update the accessibility tree with an updated WebAccessibility tree or
101 // subtree received from the renderer process. First attempts to modify
102 // the tree in place, and if that fails, replaces the entire subtree.
103 // Returns the updated node or NULL if no node was updated.
104 BrowserAccessibilityWin* UpdateTree(
105 const webkit_glue::WebAccessibility& acc_obj);
106
107 // Returns the next MSAA child id.
108 static LONG GetNextChildID();
109
110 // Recursively build a tree of BrowserAccessibilityWin objects from
111 // the WebAccessibility tree received from the renderer process.
112 BrowserAccessibilityWin* CreateAccessibilityTree(
113 BrowserAccessibilityWin* parent,
114 int child_id,
115 const webkit_glue::WebAccessibility& src,
116 int index_in_parent);
117
118 // The object that can perform actions on our behalf.
119 BrowserAccessibilityDelegate* delegate_;
120
121 // Factory to create BrowserAccessibility objects (for dependency injection).
122 scoped_ptr<BrowserAccessibilityWinFactory> factory_;
39 123
40 // A default IAccessible instance for the parent window. 124 // A default IAccessible instance for the parent window.
41 ScopedComPtr<IAccessible> window_iaccessible_; 125 ScopedComPtr<IAccessible> window_iaccessible_;
42 126
43 // Give BrowserAccessibilityManager::Create access to our constructor. 127 // The root of the tree of IAccessible objects and the element that
44 friend class BrowserAccessibilityManager; 128 // currently has focus, if any.
129 BrowserAccessibilityWin* root_;
130 BrowserAccessibilityWin* focus_;
131
132 // A mapping from the IDs of objects in the renderer, to the child IDs
133 // we use internally here.
134 base::hash_map<int, LONG> renderer_id_to_child_id_map_;
135
136 // A mapping from child IDs to BrowserAccessibilityWin objects.
137 base::hash_map<LONG, BrowserAccessibilityWin*> child_id_map_;
138
139 // The next child ID to use; static so that they're global to the process.
140 // Screen readers cache these IDs to see if they've seen the same object
141 // before so we should avoid reusing them within the same project.
142 static LONG next_child_id_;
45 143
46 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin); 144 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerWin);
47 }; 145 };
48 146
49 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_ 147 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698