| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/accessibility/blink_ax_tree_source.h" | 5 #include "content/renderer/accessibility/blink_ax_tree_source.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 using blink::WebNode; | 47 using blink::WebNode; |
| 48 using blink::WebPlugin; | 48 using blink::WebPlugin; |
| 49 using blink::WebPluginContainer; | 49 using blink::WebPluginContainer; |
| 50 using blink::WebVector; | 50 using blink::WebVector; |
| 51 using blink::WebView; | 51 using blink::WebView; |
| 52 | 52 |
| 53 namespace content { | 53 namespace content { |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 WebAXObject ParentObjectUnignored(WebAXObject child) { |
| 58 WebAXObject parent = child.parentObject(); |
| 59 while (!parent.isDetached() && parent.accessibilityIsIgnored()) |
| 60 parent = parent.parentObject(); |
| 61 return parent; |
| 62 } |
| 63 |
| 57 // Returns true if |ancestor| is the first unignored parent of |child|, | 64 // Returns true if |ancestor| is the first unignored parent of |child|, |
| 58 // which means that when walking up the parent chain from |child|, | 65 // which means that when walking up the parent chain from |child|, |
| 59 // |ancestor| is the *first* ancestor that isn't marked as | 66 // |ancestor| is the *first* ancestor that isn't marked as |
| 60 // accessibilityIsIgnored(). | 67 // accessibilityIsIgnored(). |
| 61 bool IsParentUnignoredOf(WebAXObject ancestor, | 68 bool IsParentUnignoredOf(WebAXObject ancestor, |
| 62 WebAXObject child) { | 69 WebAXObject child) { |
| 63 WebAXObject parent = child.parentObject(); | 70 WebAXObject parent = ParentObjectUnignored(child); |
| 64 while (!parent.isDetached() && parent.accessibilityIsIgnored()) | |
| 65 parent = parent.parentObject(); | |
| 66 return parent.equals(ancestor); | 71 return parent.equals(ancestor); |
| 67 } | 72 } |
| 68 | 73 |
| 69 std::string GetEquivalentAriaRoleString(const ui::AXRole role) { | 74 std::string GetEquivalentAriaRoleString(const ui::AXRole role) { |
| 70 switch (role) { | 75 switch (role) { |
| 71 case ui::AX_ROLE_ARTICLE: | 76 case ui::AX_ROLE_ARTICLE: |
| 72 return "article"; | 77 return "article"; |
| 73 case ui::AX_ROLE_BANNER: | 78 case ui::AX_ROLE_BANNER: |
| 74 return "banner"; | 79 return "banner"; |
| 75 case ui::AX_ROLE_BUTTON: | 80 case ui::AX_ROLE_BUTTON: |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); | 357 dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.colorValue()); |
| 353 | 358 |
| 354 | 359 |
| 355 // Text attributes. | 360 // Text attributes. |
| 356 if (src.backgroundColor()) | 361 if (src.backgroundColor()) |
| 357 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); | 362 dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.backgroundColor()); |
| 358 | 363 |
| 359 if (src.color()) | 364 if (src.color()) |
| 360 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); | 365 dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.color()); |
| 361 | 366 |
| 367 WebAXObject parent = ParentObjectUnignored(src); |
| 362 if (src.fontFamily().length()) { | 368 if (src.fontFamily().length()) { |
| 363 WebAXObject parent = src.parentObject(); | |
| 364 if (parent.isNull() || parent.fontFamily() != src.fontFamily()) | 369 if (parent.isNull() || parent.fontFamily() != src.fontFamily()) |
| 365 dst->AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, src.fontFamily().utf8()); | 370 dst->AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, src.fontFamily().utf8()); |
| 366 } | 371 } |
| 367 | 372 |
| 368 // Font size is in pixels. | 373 // Font size is in pixels. |
| 369 if (src.fontSize()) | 374 if (src.fontSize()) |
| 370 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); | 375 dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.fontSize()); |
| 371 | 376 |
| 372 if (src.ariaCurrentState()) { | 377 if (src.ariaCurrentState()) { |
| 373 dst->AddIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, | 378 dst->AddIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 446 |
| 442 if (src.canSetValueAttribute()) | 447 if (src.canSetValueAttribute()) |
| 443 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); | 448 dst->AddBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE, true); |
| 444 | 449 |
| 445 if (src.hasComputedStyle()) { | 450 if (src.hasComputedStyle()) { |
| 446 dst->AddStringAttribute( | 451 dst->AddStringAttribute( |
| 447 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); | 452 ui::AX_ATTR_DISPLAY, src.computedStyleDisplay().utf8()); |
| 448 } | 453 } |
| 449 | 454 |
| 450 if (src.language().length()) { | 455 if (src.language().length()) { |
| 451 WebAXObject parent = src.parentObject(); | |
| 452 if (parent.isNull() || parent.language() != src.language()) | 456 if (parent.isNull() || parent.language() != src.language()) |
| 453 dst->AddStringAttribute(ui::AX_ATTR_LANGUAGE, src.language().utf8()); | 457 dst->AddStringAttribute(ui::AX_ATTR_LANGUAGE, src.language().utf8()); |
| 454 } | 458 } |
| 455 | 459 |
| 456 if (src.keyboardShortcut().length()) { | 460 if (src.keyboardShortcut().length()) { |
| 457 dst->AddStringAttribute( | 461 dst->AddStringAttribute( |
| 458 ui::AX_ATTR_SHORTCUT, | 462 ui::AX_ATTR_SHORTCUT, |
| 459 src.keyboardShortcut().utf8()); | 463 src.keyboardShortcut().utf8()); |
| 460 } | 464 } |
| 461 | 465 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 return WebAXObject(); | 749 return WebAXObject(); |
| 746 | 750 |
| 747 WebDocument document = render_frame_->GetWebFrame()->document(); | 751 WebDocument document = render_frame_->GetWebFrame()->document(); |
| 748 if (!document.isNull()) | 752 if (!document.isNull()) |
| 749 return document.accessibilityObject(); | 753 return document.accessibilityObject(); |
| 750 | 754 |
| 751 return WebAXObject(); | 755 return WebAXObject(); |
| 752 } | 756 } |
| 753 | 757 |
| 754 } // namespace content | 758 } // namespace content |
| OLD | NEW |