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

Side by Side Diff: content/renderer/accessibility/renderer_accessibility_complete.h

Issue 23651003: Use Blink accessibility enums in Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ 5 #ifndef CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_
6 #define CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ 6 #define CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "content/common/accessibility_node_data.h" 12 #include "content/common/accessibility_node_data.h"
13 #include "content/public/renderer/render_view_observer.h" 13 #include "content/public/renderer/render_view_observer.h"
14 #include "content/renderer/accessibility/renderer_accessibility.h" 14 #include "content/renderer/accessibility/renderer_accessibility.h"
15 #include "third_party/WebKit/public/web/WebAccessibilityNotification.h" 15 #include "third_party/WebKit/public/web/WebAXEnums.h"
16 #include "third_party/WebKit/public/web/WebAXObject.h"
16 17
17 namespace WebKit { 18 namespace WebKit {
18 class WebAccessibilityObject;
19 class WebDocument; 19 class WebDocument;
20 class WebNode; 20 class WebNode;
21 }; 21 };
22 22
23 namespace content { 23 namespace content {
24 class RenderViewImpl; 24 class RenderViewImpl;
25 25
26 // This is the subclass of RendererAccessibility that implements 26 // This is the subclass of RendererAccessibility that implements
27 // complete accessibility support for assistive technology (as opposed to 27 // complete accessibility support for assistive technology (as opposed to
28 // partial support - see RendererAccessibilityFocusOnly). 28 // partial support - see RendererAccessibilityFocusOnly).
29 // 29 //
30 // This version turns on WebKit's accessibility code and sends 30 // This version turns on WebKit's accessibility code and sends
31 // a serialized representation of that tree whenever it changes. It also 31 // a serialized representation of that tree whenever it changes. It also
32 // handles requests from the browser to perform accessibility actions on 32 // handles requests from the browser to perform accessibility actions on
33 // nodes in the tree (e.g., change focus, or click on a button). 33 // nodes in the tree (e.g., change focus, or click on a button).
34 class CONTENT_EXPORT RendererAccessibilityComplete 34 class CONTENT_EXPORT RendererAccessibilityComplete
35 : public RendererAccessibility { 35 : public RendererAccessibility {
36 public: 36 public:
37 explicit RendererAccessibilityComplete(RenderViewImpl* render_view); 37 explicit RendererAccessibilityComplete(RenderViewImpl* render_view);
38 virtual ~RendererAccessibilityComplete(); 38 virtual ~RendererAccessibilityComplete();
39 39
40 // RenderView::Observer implementation. 40 // RenderView::Observer implementation.
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
42 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; 42 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;
43 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; 43 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
44 44
45 // RendererAccessibility. 45 // RendererAccessibility.
46 virtual void HandleWebAccessibilityNotification( 46 virtual void HandleWebAccessibilityEvent(
47 const WebKit::WebAccessibilityObject& obj, 47 const WebKit::WebAXObject& obj, WebKit::WebAXEvent event) OVERRIDE;
48 WebKit::WebAccessibilityNotification notification) OVERRIDE;
49 48
50 // In order to keep track of what nodes the browser knows about, we keep a 49 // In order to keep track of what nodes the browser knows about, we keep a
51 // representation of the browser tree - just IDs and parent/child 50 // representation of the browser tree - just IDs and parent/child
52 // relationships. 51 // relationships.
53 struct CONTENT_EXPORT BrowserTreeNode { 52 struct CONTENT_EXPORT BrowserTreeNode {
54 BrowserTreeNode(); 53 BrowserTreeNode();
55 virtual ~BrowserTreeNode(); 54 virtual ~BrowserTreeNode();
56 int32 id; 55 int32 id;
57 gfx::Rect location; 56 gfx::Rect location;
58 BrowserTreeNode* parent; 57 BrowserTreeNode* parent;
59 std::vector<BrowserTreeNode*> children; 58 std::vector<BrowserTreeNode*> children;
60 }; 59 };
61 60
62 virtual BrowserTreeNode* CreateBrowserTreeNode(); 61 virtual BrowserTreeNode* CreateBrowserTreeNode();
63 62
64 protected: 63 protected:
65 // Send queued notifications from the renderer to the browser. 64 // Send queued events from the renderer to the browser.
66 void SendPendingAccessibilityNotifications(); 65 void SendPendingAccessibilityEvents();
67 66
68 // Check the entire accessibility tree to see if any nodes have 67 // Check the entire accessibility tree to see if any nodes have
69 // changed location, by comparing their locations to the cached 68 // changed location, by comparing their locations to the cached
70 // versions. If any have moved, append a notification to |notifications| 69 // versions. If any have moved, append a event to |events|
71 // that updates the coordinates of these objects. 70 // that updates the coordinates of these objects.
72 void AppendLocationChangeNotifications( 71 void AppendLocationChangeEvents(
73 std::vector<AccessibilityHostMsg_NotificationParams>* notifications); 72 std::vector<AccessibilityHostMsg_EventParams>* events);
74 73
75 private: 74 private:
76 // Handle an accessibility notification to be sent to the browser process.
77 void HandleAccessibilityNotification(
78 const WebKit::WebAccessibilityObject& obj,
79 AccessibilityNotification notification);
80
81 // Serialize the given accessibility object |obj| and append it to 75 // Serialize the given accessibility object |obj| and append it to
82 // |dst|, and then recursively also serialize any *new* children of 76 // |dst|, and then recursively also serialize any *new* children of
83 // |obj|, based on what object ids we know the browser already has. 77 // |obj|, based on what object ids we know the browser already has.
84 void SerializeChangedNodes(const WebKit::WebAccessibilityObject& obj, 78 void SerializeChangedNodes(const WebKit::WebAXObject& obj,
85 std::vector<AccessibilityNodeData>* dst); 79 std::vector<AccessibilityNodeData>* dst);
86 80
87 // Clear the given node and recursively delete all of its descendants 81 // Clear the given node and recursively delete all of its descendants
88 // from the browser tree. (Does not delete |browser_node|). 82 // from the browser tree. (Does not delete |browser_node|).
89 void ClearBrowserTreeNode(BrowserTreeNode* browser_node); 83 void ClearBrowserTreeNode(BrowserTreeNode* browser_node);
90 84
91 // Handlers for messages from the browser to the renderer. 85 // Handlers for messages from the browser to the renderer.
92 void OnDoDefaultAction(int acc_obj_id); 86 void OnDoDefaultAction(int acc_obj_id);
93 void OnNotificationsAck(); 87 void OnEventsAck();
94 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y); 88 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y);
95 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus); 89 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus);
96 void OnScrollToPoint(int acc_obj_id, gfx::Point point); 90 void OnScrollToPoint(int acc_obj_id, gfx::Point point);
97 void OnSetFocus(int acc_obj_id); 91 void OnSetFocus(int acc_obj_id);
98 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset); 92 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset);
99 void OnFatalError(); 93 void OnFatalError();
100 94
101 // Checks if a WebKit accessibility object is an editable text node. 95 // Checks if a WebKit accessibility object is an editable text node.
102 bool IsEditableText(const WebKit::WebAccessibilityObject& node); 96 bool IsEditableText(const WebKit::WebAXObject& node);
103 97
104 // Recursively explore the tree of WebKit accessibility objects rooted 98 // Recursively explore the tree of WebKit accessibility objects rooted
105 // at |src|, and for each editable text node encountered, add a 99 // at |src|, and for each editable text node encountered, add a
106 // corresponding WebAccessibility node as a child of |dst|. 100 // corresponding WebAccessibility node as a child of |dst|.
107 void RecursiveAddEditableTextNodesToTree( 101 void RecursiveAddEditableTextNodesToTree(
108 const WebKit::WebAccessibilityObject& src, 102 const WebKit::WebAXObject& src,
109 AccessibilityNodeData* dst); 103 AccessibilityNodeData* dst);
110 104
111 // Build a tree of serializable AccessibilityNodeData nodes to send to the 105 // Build a tree of serializable AccessibilityNodeData nodes to send to the
112 // browser process, given a WebAccessibilityObject node from WebKit. 106 // browser process, given a WebAXObject node from WebKit.
113 // Modifies |dst| in-place, it's assumed to be empty. 107 // Modifies |dst| in-place, it's assumed to be empty.
114 void BuildAccessibilityTree(const WebKit::WebAccessibilityObject& src, 108 void BuildAccessibilityTree(const WebKit::WebAXObject& src,
115 bool include_children, 109 bool include_children,
116 AccessibilityNodeData* dst); 110 AccessibilityNodeData* dst);
117 111
118 // So we can queue up tasks to be executed later. 112 // So we can queue up tasks to be executed later.
119 base::WeakPtrFactory<RendererAccessibilityComplete> weak_factory_; 113 base::WeakPtrFactory<RendererAccessibilityComplete> weak_factory_;
120 114
121 // Notifications from WebKit are collected until they are ready to be 115 // Events from WebKit are collected until they are ready to be
122 // sent to the browser. 116 // sent to the browser.
123 std::vector<AccessibilityHostMsg_NotificationParams> pending_notifications_; 117 std::vector<AccessibilityHostMsg_EventParams> pending_events_;
124 118
125 // Our representation of the browser tree. 119 // Our representation of the browser tree.
126 BrowserTreeNode* browser_root_; 120 BrowserTreeNode* browser_root_;
127 121
128 // A map from IDs to nodes in the browser tree. 122 // A map from IDs to nodes in the browser tree.
129 base::hash_map<int32, BrowserTreeNode*> browser_id_map_; 123 base::hash_map<int32, BrowserTreeNode*> browser_id_map_;
130 124
131 // The most recently observed scroll offset of the root document element. 125 // The most recently observed scroll offset of the root document element.
132 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460 126 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460
133 // is fixed. 127 // is fixed.
134 gfx::Size last_scroll_offset_; 128 gfx::Size last_scroll_offset_;
135 129
136 // The current accessibility mode. 130 // The current accessibility mode.
137 AccessibilityMode mode_; 131 AccessibilityMode mode_;
138 132
139 // Set if we are waiting for an accessibility notification ack. 133 // Set if we are waiting for an accessibility event ack.
140 bool ack_pending_; 134 bool ack_pending_;
141 135
142 // True if verbose logging of accessibility events is on. 136 // True if verbose logging of accessibility events is on.
143 bool logging_; 137 bool logging_;
144 138
145 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityComplete); 139 DISALLOW_COPY_AND_ASSIGN(RendererAccessibilityComplete);
146 }; 140 };
147 141
148 #endif // CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_ 142 #endif // CONTENT_RENDERER_ACCESSIBILITY_RENDERER_ACCESSIBILITY_COMPLETE_H_
149 143
150 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698