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

Side by Side Diff: content/renderer/renderer_accessibility.h

Issue 9939011: Add an accessibility mode for editable text fields only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and rebased. Created 8 years, 8 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_RENDERER_ACCESSIBILITY_H_ 5 #ifndef CONTENT_RENDERER_RENDERER_ACCESSIBILITY_H_
6 #define CONTENT_RENDERER_RENDERER_ACCESSIBILITY_H_ 6 #define CONTENT_RENDERER_RENDERER_ACCESSIBILITY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/common/accessibility_messages.h"
13 #include "content/public/renderer/render_view_observer.h" 14 #include "content/public/renderer/render_view_observer.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotif ication.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotif ication.h"
15 16
16 class RenderViewImpl; 17 class RenderViewImpl;
17 18
18 namespace WebKit { 19 namespace WebKit {
19 class WebAccessibilityObject; 20 class WebAccessibilityObject;
20 class WebDocument; 21 class WebDocument;
21 class WebNode; 22 class WebNode;
22 }; 23 };
23 24
24 namespace webkit_glue { 25 namespace webkit_glue {
25 struct WebAccessibility; 26 struct WebAccessibility;
26 }; 27 };
27 28
28 // RendererAccessibility belongs to the RenderView. It's responsible for 29 // RendererAccessibility belongs to the RenderView. It's responsible for
29 // sending a serialized representation of WebKit's accessibility tree from 30 // sending a serialized representation of WebKit's accessibility tree from
30 // the renderer to the browser and sending updates whenever it changes, and 31 // the renderer to the browser and sending updates whenever it changes, and
31 // handling requests from the browser to perform accessibility actions on 32 // handling requests from the browser to perform accessibility actions on
32 // 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).
33 class RendererAccessibility : public content::RenderViewObserver { 34 class RendererAccessibility : public content::RenderViewObserver {
34 public: 35 public:
35 RendererAccessibility(RenderViewImpl* render_view); 36 RendererAccessibility(RenderViewImpl* render_view,
37 AccessibilityMode accessibility_mode);
36 virtual ~RendererAccessibility(); 38 virtual ~RendererAccessibility();
37 39
38 // RenderView::Observer implementation. 40 // RenderView::Observer implementation.
39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
40 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; 42 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;
41 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; 43 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
42 44
43 // Called when an accessibility notification occurs in WebKit. 45 // Called when an accessibility notification occurs in WebKit.
44 virtual void PostAccessibilityNotification( 46 virtual void PostAccessibilityNotification(
45 const WebKit::WebAccessibilityObject& obj, 47 const WebKit::WebAccessibilityObject& obj,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Clear the given node and recursively delete all of its descendants 80 // Clear the given node and recursively delete all of its descendants
79 // from the browser tree. (Does not delete |browser_node|). 81 // from the browser tree. (Does not delete |browser_node|).
80 void ClearBrowserTreeNode(BrowserTreeNode* browser_node); 82 void ClearBrowserTreeNode(BrowserTreeNode* browser_node);
81 83
82 // Handlers for messages from the browser to the renderer. 84 // Handlers for messages from the browser to the renderer.
83 void OnDoDefaultAction(int acc_obj_id); 85 void OnDoDefaultAction(int acc_obj_id);
84 void OnNotificationsAck(); 86 void OnNotificationsAck();
85 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y); 87 void OnChangeScrollPosition(int acc_obj_id, int scroll_x, int scroll_y);
86 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus); 88 void OnScrollToMakeVisible(int acc_obj_id, gfx::Rect subfocus);
87 void OnScrollToPoint(int acc_obj_id, gfx::Point point); 89 void OnScrollToPoint(int acc_obj_id, gfx::Point point);
88 void OnEnable(); 90 void OnSetMode(AccessibilityMode mode);
89 void OnSetFocus(int acc_obj_id); 91 void OnSetFocus(int acc_obj_id);
90 92
91 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset); 93 void OnSetTextSelection(int acc_obj_id, int start_offset, int end_offset);
92 94
93 // Whether or not this notification typically needs to send 95 // Whether or not this notification typically needs to send
94 // updates to its children, too. 96 // updates to its children, too.
95 bool ShouldIncludeChildren(const Notification& notification); 97 bool ShouldIncludeChildren(const Notification& notification);
96 98
97 // Returns the main top-level document for this page, or NULL if there's 99 // Returns the main top-level document for this page, or NULL if there's
98 // no view or frame. 100 // no view or frame.
99 WebKit::WebDocument GetMainDocument(); 101 WebKit::WebDocument GetMainDocument();
100 102
103 // Checks if a WebKit accessibility object is an editable text node.
104 bool IsEditableText(const WebKit::WebAccessibilityObject& node);
105
106 // Recursively explore the tree of WebKit accessibility objects rooted
107 // at |src|, and for each editable text node encountered, add a
108 // corresponding WebAccessibility node as a child of |dst|.
109 void RecursiveAddEditableTextNodesToTree(
110 const WebKit::WebAccessibilityObject& src,
111 webkit_glue::WebAccessibility* dst);
112
113 // Build a tree of serializable WebAccessibility nodes to send to the
114 // browser process, given a WebAccessibilityObject node from WebKit.
115 // Modifies |dst| in-place, it's assumed to be empty.
116 void BuildAccessibilityTree(const WebKit::WebAccessibilityObject& src,
117 bool include_children,
118 webkit_glue::WebAccessibility* dst);
119
101 // So we can queue up tasks to be executed later. 120 // So we can queue up tasks to be executed later.
102 base::WeakPtrFactory<RendererAccessibility> weak_factory_; 121 base::WeakPtrFactory<RendererAccessibility> weak_factory_;
103 122
104 // Notifications from WebKit are collected until they are ready to be 123 // Notifications from WebKit are collected until they are ready to be
105 // sent to the browser. 124 // sent to the browser.
106 std::vector<Notification> pending_notifications_; 125 std::vector<Notification> pending_notifications_;
107 126
108 // Our representation of the browser tree. 127 // Our representation of the browser tree.
109 BrowserTreeNode* browser_root_; 128 BrowserTreeNode* browser_root_;
110 129
111 // A map from IDs to nodes in the browser tree. 130 // A map from IDs to nodes in the browser tree.
112 base::hash_map<int32, BrowserTreeNode*> browser_id_map_; 131 base::hash_map<int32, BrowserTreeNode*> browser_id_map_;
113 132
114 // The most recently observed scroll offset of the root document element. 133 // The most recently observed scroll offset of the root document element.
115 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460 134 // TODO(dmazzoni): remove once https://bugs.webkit.org/show_bug.cgi?id=73460
116 // is fixed. 135 // is fixed.
117 gfx::Size last_scroll_offset_; 136 gfx::Size last_scroll_offset_;
118 137
138 // The current accessibility mode.
139 AccessibilityMode mode_;
140
119 // Set if we are waiting for an accessibility notification ack. 141 // Set if we are waiting for an accessibility notification ack.
120 bool ack_pending_; 142 bool ack_pending_;
121 143
122 // True if verbose logging of accessibility events is on. 144 // True if verbose logging of accessibility events is on.
123 bool logging_; 145 bool logging_;
124 146
125 DISALLOW_COPY_AND_ASSIGN(RendererAccessibility); 147 DISALLOW_COPY_AND_ASSIGN(RendererAccessibility);
126 }; 148 };
127 149
128 #endif // CONTENT_RENDERER_RENDERER_ACCESSIBILITY_H_ 150 #endif // CONTENT_RENDERER_RENDERER_ACCESSIBILITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698