OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/common/view_messages.h" | 6 #include "content/common/view_messages.h" |
7 #include "content/public/common/content_switches.h" | 7 #include "content/public/common/content_switches.h" |
8 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
9 #include "content/renderer/renderer_accessibility.h" | 9 #include "content/renderer/renderer_accessibility.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 | 206 |
207 // Send all pending accessibility notifications. | 207 // Send all pending accessibility notifications. |
208 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; | 208 std::vector<ViewHostMsg_AccessibilityNotification_Params> notifications; |
209 for (size_t i = 0; i < pending_notifications_.size(); ++i) { | 209 for (size_t i = 0; i < pending_notifications_.size(); ++i) { |
210 Notification& notification = pending_notifications_[i]; | 210 Notification& notification = pending_notifications_[i]; |
211 | 211 |
212 bool includes_children = ShouldIncludeChildren(notification); | 212 bool includes_children = ShouldIncludeChildren(notification); |
213 WebAccessibilityObject obj = document.accessibilityObjectFromID( | 213 WebAccessibilityObject obj = document.accessibilityObjectFromID( |
214 notification.id); | 214 notification.id); |
215 | 215 |
216 if (!obj.isValid()) { | |
217 #ifndef NDEBUG | |
218 if (logging_) | |
219 LOG(WARNING) << "Got notification on invalid object id " << obj.axID(); | |
220 #endif | |
221 continue; | |
222 } | |
223 | |
224 // The browser may not have this object yet, for example if we get a | 216 // The browser may not have this object yet, for example if we get a |
225 // notification on an object that was recently added, or if we get a | 217 // notification on an object that was recently added, or if we get a |
226 // notification on a node before the page has loaded. Work our way | 218 // notification on a node before the page has loaded. Work our way |
227 // up the parent chain until we find a node the browser has, or until | 219 // up the parent chain until we find a node the browser has, or until |
228 // we reach the root. | 220 // we reach the root. |
229 int root_id = document.accessibilityObject().axID(); | 221 int root_id = document.accessibilityObject().axID(); |
230 while (browser_id_map_.find(obj.axID()) == browser_id_map_.end() && | 222 while (browser_id_map_.find(obj.axID()) == browser_id_map_.end() && |
223 obj.isValid() && | |
231 obj.axID() != root_id) { | 224 obj.axID() != root_id) { |
232 obj = obj.parentObject(); | 225 obj = obj.parentObject(); |
233 includes_children = true; | 226 includes_children = true; |
234 if (notification.type == | 227 if (notification.type == |
235 WebKit::WebAccessibilityNotificationChildrenChanged) { | 228 WebKit::WebAccessibilityNotificationChildrenChanged) { |
236 notification.id = obj.axID(); | 229 notification.id = obj.axID(); |
237 } | 230 } |
238 } | 231 } |
239 | 232 |
233 if (!obj.isValid()) { | |
234 #ifndef NDEBUG | |
235 if (logging_) | |
236 LOG(WARNING) << "Got notification on invalid object id " << obj.axID(); | |
dmazzoni
2011/12/01 18:59:56
Maybe the warning should say that the we got a not
David Tseng
2011/12/01 19:48:57
Done.
| |
237 #endif | |
238 continue; | |
239 } | |
240 | |
240 // Another potential problem is that this notification may be on an | 241 // Another potential problem is that this notification may be on an |
241 // object that is detached from the tree. Determine if this node is not a | 242 // object that is detached from the tree. Determine if this node is not a |
242 // child of its parent, and if so move the notification to the parent. | 243 // child of its parent, and if so move the notification to the parent. |
243 // TODO(dmazzoni): see if this can be removed after | 244 // TODO(dmazzoni): see if this can be removed after |
244 // https://bugs.webkit.org/show_bug.cgi?id=68466 is fixed. | 245 // https://bugs.webkit.org/show_bug.cgi?id=68466 is fixed. |
245 if (obj.axID() != root_id) { | 246 if (obj.axID() != root_id) { |
246 WebAccessibilityObject parent = obj.parentObject(); | 247 WebAccessibilityObject parent = obj.parentObject(); |
247 while (!parent.isNull() && parent.accessibilityIsIgnored()) | 248 while (!parent.isNull() && |
249 parent.isValid() && | |
250 parent.accessibilityIsIgnored()) { | |
248 parent = parent.parentObject(); | 251 parent = parent.parentObject(); |
252 } | |
253 | |
249 if (parent.isNull()) { | 254 if (parent.isNull()) { |
dmazzoni
2011/12/01 18:59:56
I think if parent is null or invalid we should con
David Tseng
2011/12/01 19:48:57
Done.
| |
250 NOTREACHED(); | 255 NOTREACHED(); |
251 } | 256 } |
252 bool is_child_of_parent = false; | 257 bool is_child_of_parent = false; |
253 for (unsigned int i = 0; i < parent.childCount(); ++i) { | 258 for (unsigned int i = 0; i < parent.childCount(); ++i) { |
254 if (parent.childAt(i).equals(obj)) { | 259 if (parent.childAt(i).equals(obj)) { |
255 is_child_of_parent = true; | 260 is_child_of_parent = true; |
256 break; | 261 break; |
257 } | 262 } |
258 } | 263 } |
259 if (!is_child_of_parent) { | 264 if (!is_child_of_parent) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 | 430 |
426 WebDocument RendererAccessibility::GetMainDocument() { | 431 WebDocument RendererAccessibility::GetMainDocument() { |
427 WebView* view = render_view()->GetWebView(); | 432 WebView* view = render_view()->GetWebView(); |
428 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 433 WebFrame* main_frame = view ? view->mainFrame() : NULL; |
429 | 434 |
430 if (main_frame) | 435 if (main_frame) |
431 return main_frame->document(); | 436 return main_frame->document(); |
432 else | 437 else |
433 return WebDocument(); | 438 return WebDocument(); |
434 } | 439 } |
OLD | NEW |