Chromium Code Reviews| 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() && |
| 231 obj.axID() != root_id) { | 223 obj.axID() != root_id) { |
| 224 if (!obj.isValid()) { | |
| 225 #ifndef NDEBUG | |
| 226 if (logging_) | |
| 227 LOG(WARNING) << "Got notification on invalid object id " << obj.axID() ; | |
| 228 #endif | |
| 229 break; | |
| 230 } | |
| 231 | |
| 232 obj = obj.parentObject(); | 232 obj = obj.parentObject(); |
| 233 includes_children = true; | 233 includes_children = true; |
| 234 if (notification.type == | 234 if (notification.type == |
| 235 WebKit::WebAccessibilityNotificationChildrenChanged) { | 235 WebKit::WebAccessibilityNotificationChildrenChanged) { |
| 236 notification.id = obj.axID(); | 236 notification.id = obj.axID(); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 if (!obj.isValid()) | |
| 241 continue; | |
| 242 | |
| 240 // Another potential problem is that this notification may be on an | 243 // 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 | 244 // 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. | 245 // child of its parent, and if so move the notification to the parent. |
| 243 // TODO(dmazzoni): see if this can be removed after | 246 // TODO(dmazzoni): see if this can be removed after |
| 244 // https://bugs.webkit.org/show_bug.cgi?id=68466 is fixed. | 247 // https://bugs.webkit.org/show_bug.cgi?id=68466 is fixed. |
| 245 if (obj.axID() != root_id) { | 248 if (obj.axID() != root_id) { |
| 246 WebAccessibilityObject parent = obj.parentObject(); | 249 WebAccessibilityObject parent = obj.parentObject(); |
| 247 while (!parent.isNull() && parent.accessibilityIsIgnored()) | 250 while (!parent.isNull() && parent.accessibilityIsIgnored()) |
|
dmazzoni
2011/12/01 18:01:13
Maybe check for validity here, too?
| |
| 248 parent = parent.parentObject(); | 251 parent = parent.parentObject(); |
| 249 if (parent.isNull()) { | 252 if (parent.isNull()) { |
| 250 NOTREACHED(); | 253 NOTREACHED(); |
| 251 } | 254 } |
| 252 bool is_child_of_parent = false; | 255 bool is_child_of_parent = false; |
| 253 for (unsigned int i = 0; i < parent.childCount(); ++i) { | 256 for (unsigned int i = 0; i < parent.childCount(); ++i) { |
| 254 if (parent.childAt(i).equals(obj)) { | 257 if (parent.childAt(i).equals(obj)) { |
| 255 is_child_of_parent = true; | 258 is_child_of_parent = true; |
| 256 break; | 259 break; |
| 257 } | 260 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 | 428 |
| 426 WebDocument RendererAccessibility::GetMainDocument() { | 429 WebDocument RendererAccessibility::GetMainDocument() { |
| 427 WebView* view = render_view()->GetWebView(); | 430 WebView* view = render_view()->GetWebView(); |
| 428 WebFrame* main_frame = view ? view->mainFrame() : NULL; | 431 WebFrame* main_frame = view ? view->mainFrame() : NULL; |
| 429 | 432 |
| 430 if (main_frame) | 433 if (main_frame) |
| 431 return main_frame->document(); | 434 return main_frame->document(); |
| 432 else | 435 else |
| 433 return WebDocument(); | 436 return WebDocument(); |
| 434 } | 437 } |
| OLD | NEW |