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 "webkit/glue/webaccessibility.h" | 5 #include "webkit/glue/webaccessibility.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache
.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache
.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityRole.
h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityRole.
h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocumentType.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocumentType.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNamedNodeMap.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNamedNodeMap.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" |
28 | 28 |
| 29 #ifndef NDEBUG |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotif
ication.h" |
| 31 #endif |
| 32 |
29 using base::DoubleToString; | 33 using base::DoubleToString; |
30 using base::IntToString; | 34 using base::IntToString; |
31 using WebKit::WebAccessibilityCache; | 35 using WebKit::WebAccessibilityCache; |
32 using WebKit::WebAccessibilityRole; | 36 using WebKit::WebAccessibilityRole; |
33 using WebKit::WebAccessibilityObject; | 37 using WebKit::WebAccessibilityObject; |
34 | 38 |
| 39 #ifndef NDEBUG |
| 40 using WebKit::WebAccessibilityNotification; |
| 41 #endif |
| 42 |
35 namespace { | 43 namespace { |
36 | 44 |
37 std::string IntVectorToString(const std::vector<int>& items) { | 45 std::string IntVectorToString(const std::vector<int>& items) { |
38 std::string str; | 46 std::string str; |
39 for (size_t i = 0; i < items.size(); ++i) { | 47 for (size_t i = 0; i < items.size(); ++i) { |
40 if (i > 0) | 48 if (i > 0) |
41 str += ","; | 49 str += ","; |
42 str += IntToString(items[i]); | 50 str += IntToString(items[i]); |
43 } | 51 } |
44 return str; | 52 return str; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 WebAccessibility::WebAccessibility(const WebKit::WebAccessibilityObject& src, | 336 WebAccessibility::WebAccessibility(const WebKit::WebAccessibilityObject& src, |
329 WebKit::WebAccessibilityCache* cache, | 337 WebKit::WebAccessibilityCache* cache, |
330 bool include_children) { | 338 bool include_children) { |
331 Init(src, cache, include_children); | 339 Init(src, cache, include_children); |
332 } | 340 } |
333 | 341 |
334 WebAccessibility::~WebAccessibility() { | 342 WebAccessibility::~WebAccessibility() { |
335 } | 343 } |
336 | 344 |
337 #ifndef NDEBUG | 345 #ifndef NDEBUG |
338 std::string WebAccessibility::DebugString(bool recursive) { | 346 std::string WebAccessibility::DebugString(bool recursive, |
| 347 int render_routing_id, |
| 348 int notification) { |
339 std::string result; | 349 std::string result; |
340 static int indent = 0; | 350 static int indent = 0; |
341 | 351 |
| 352 if (render_routing_id != 0) { |
| 353 WebKit::WebAccessibilityNotification notification_type = |
| 354 static_cast<WebKit::WebAccessibilityNotification>(notification); |
| 355 result += "routing id="; |
| 356 result += IntToString(render_routing_id); |
| 357 result += " notification="; |
| 358 |
| 359 switch (notification_type) { |
| 360 case WebKit::WebAccessibilityNotificationActiveDescendantChanged: |
| 361 result += "active descendant changed"; |
| 362 break; |
| 363 case WebKit::WebAccessibilityNotificationCheckedStateChanged: |
| 364 result += "check state changed"; |
| 365 break; |
| 366 case WebKit::WebAccessibilityNotificationChildrenChanged: |
| 367 result += "children changed"; |
| 368 break; |
| 369 case WebKit::WebAccessibilityNotificationFocusedUIElementChanged: |
| 370 result += "focus changed"; |
| 371 break; |
| 372 case WebKit::WebAccessibilityNotificationLayoutComplete: |
| 373 result += "layout complete"; |
| 374 break; |
| 375 case WebKit::WebAccessibilityNotificationLiveRegionChanged: |
| 376 result += "live region changed"; |
| 377 break; |
| 378 case WebKit::WebAccessibilityNotificationLoadComplete: |
| 379 result += "load complete"; |
| 380 break; |
| 381 case WebKit::WebAccessibilityNotificationMenuListValueChanged: |
| 382 result += "menu list changed"; |
| 383 break; |
| 384 case WebKit::WebAccessibilityNotificationRowCountChanged: |
| 385 result += "row count changed"; |
| 386 break; |
| 387 case WebKit::WebAccessibilityNotificationRowCollapsed: |
| 388 result += "row collapsed"; |
| 389 break; |
| 390 case WebKit::WebAccessibilityNotificationRowExpanded: |
| 391 result += "row expanded"; |
| 392 break; |
| 393 case WebKit::WebAccessibilityNotificationScrolledToAnchor: |
| 394 result += "scrolled to anchor"; |
| 395 break; |
| 396 case WebKit::WebAccessibilityNotificationSelectedChildrenChanged: |
| 397 result += "selected children changed"; |
| 398 break; |
| 399 case WebKit::WebAccessibilityNotificationSelectedTextChanged: |
| 400 result += "selected text changed"; |
| 401 break; |
| 402 case WebKit::WebAccessibilityNotificationValueChanged: |
| 403 result += "value changed"; |
| 404 break; |
| 405 case WebKit::WebAccessibilityNotificationInvalid: |
| 406 result += "invalid notification"; |
| 407 break; |
| 408 default: |
| 409 NOTREACHED(); |
| 410 } |
| 411 } |
| 412 |
| 413 result += "\n"; |
342 for (int i = 0; i < indent; ++i) | 414 for (int i = 0; i < indent; ++i) |
343 result += " "; | 415 result += " "; |
344 | 416 |
345 result += "id=" + IntToString(id); | 417 result += "id=" + IntToString(id); |
346 | 418 |
347 switch (role) { | 419 switch (role) { |
348 case ROLE_ALERT: result += " ALERT"; break; | 420 case ROLE_ALERT: result += " ALERT"; break; |
349 case ROLE_ALERT_DIALOG: result += " ALERT_DIALOG"; break; | 421 case ROLE_ALERT_DIALOG: result += " ALERT_DIALOG"; break; |
350 case ROLE_ANNOTATION: result += " ANNOTATION"; break; | 422 case ROLE_ANNOTATION: result += " ANNOTATION"; break; |
351 case ROLE_APPLICATION: result += " APPLICATION"; break; | 423 case ROLE_APPLICATION: result += " APPLICATION"; break; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 if (!line_breaks.empty()) | 740 if (!line_breaks.empty()) |
669 result += " line_breaks=" + IntVectorToString(line_breaks); | 741 result += " line_breaks=" + IntVectorToString(line_breaks); |
670 | 742 |
671 if (!cell_ids.empty()) | 743 if (!cell_ids.empty()) |
672 result += " cell_ids=" + IntVectorToString(cell_ids); | 744 result += " cell_ids=" + IntVectorToString(cell_ids); |
673 | 745 |
674 if (recursive) { | 746 if (recursive) { |
675 result += "\n"; | 747 result += "\n"; |
676 ++indent; | 748 ++indent; |
677 for (size_t i = 0; i < children.size(); ++i) | 749 for (size_t i = 0; i < children.size(); ++i) |
678 result += children[i].DebugString(true); | 750 result += children[i].DebugString(true, 0, 0); |
679 --indent; | 751 --indent; |
680 } | 752 } |
681 | 753 |
682 return result; | 754 return result; |
683 } | 755 } |
684 #endif // ifndef NDEBUG | 756 #endif // ifndef NDEBUG |
685 | 757 |
686 void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src, | 758 void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src, |
687 WebKit::WebAccessibilityCache* cache, | 759 WebKit::WebAccessibilityCache* cache, |
688 bool include_children) { | 760 bool include_children) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 bool WebAccessibility::IsParentUnignoredOf( | 1000 bool WebAccessibility::IsParentUnignoredOf( |
929 const WebKit::WebAccessibilityObject& ancestor, | 1001 const WebKit::WebAccessibilityObject& ancestor, |
930 const WebKit::WebAccessibilityObject& child) { | 1002 const WebKit::WebAccessibilityObject& child) { |
931 WebKit::WebAccessibilityObject parent = child.parentObject(); | 1003 WebKit::WebAccessibilityObject parent = child.parentObject(); |
932 while (!parent.isNull() && parent.accessibilityIsIgnored()) | 1004 while (!parent.isNull() && parent.accessibilityIsIgnored()) |
933 parent = parent.parentObject(); | 1005 parent = parent.parentObject(); |
934 return parent.equals(ancestor); | 1006 return parent.equals(ancestor); |
935 } | 1007 } |
936 | 1008 |
937 } // namespace webkit_glue | 1009 } // namespace webkit_glue |
OLD | NEW |