OLD | NEW |
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 #include "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/accessibility/browser_accessibility.h" | 7 #include "content/browser/accessibility/browser_accessibility.h" |
8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 8 #include "content/browser/accessibility/browser_accessibility_manager.h" |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "content/browser/accessibility/browser_accessibility_win.h" | 10 #include "content/browser/accessibility/browser_accessibility_win.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 641 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
642 static_text.location = gfx::Rect(100, 100, 29, 18); | 642 static_text.location = gfx::Rect(100, 100, 29, 18); |
643 root.child_ids.push_back(2); | 643 root.child_ids.push_back(2); |
644 | 644 |
645 ui::AXNodeData inline_text1; | 645 ui::AXNodeData inline_text1; |
646 inline_text1.id = 3; | 646 inline_text1.id = 3; |
647 inline_text1.SetValue("Hello, "); | 647 inline_text1.SetValue("Hello, "); |
648 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 648 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
649 inline_text1.location = gfx::Rect(100, 100, 29, 9); | 649 inline_text1.location = gfx::Rect(100, 100, 29, 9); |
650 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 650 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
651 ui::AX_TEXT_DIRECTION_LR); | 651 ui::AX_TEXT_DIRECTION_LTR); |
652 std::vector<int32> character_offsets1; | 652 std::vector<int32> character_offsets1; |
653 character_offsets1.push_back(6); // 0 | 653 character_offsets1.push_back(6); // 0 |
654 character_offsets1.push_back(11); // 1 | 654 character_offsets1.push_back(11); // 1 |
655 character_offsets1.push_back(16); // 2 | 655 character_offsets1.push_back(16); // 2 |
656 character_offsets1.push_back(21); // 3 | 656 character_offsets1.push_back(21); // 3 |
657 character_offsets1.push_back(26); // 4 | 657 character_offsets1.push_back(26); // 4 |
658 character_offsets1.push_back(29); // 5 | 658 character_offsets1.push_back(29); // 5 |
659 character_offsets1.push_back(29); // 6 (note that the space has no width) | 659 character_offsets1.push_back(29); // 6 (note that the space has no width) |
660 inline_text1.AddIntListAttribute( | 660 inline_text1.AddIntListAttribute( |
661 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 661 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
662 static_text.child_ids.push_back(3); | 662 static_text.child_ids.push_back(3); |
663 | 663 |
664 ui::AXNodeData inline_text2; | 664 ui::AXNodeData inline_text2; |
665 inline_text2.id = 4; | 665 inline_text2.id = 4; |
666 inline_text2.SetValue("world."); | 666 inline_text2.SetValue("world."); |
667 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 667 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
668 inline_text2.location = gfx::Rect(100, 109, 28, 9); | 668 inline_text2.location = gfx::Rect(100, 109, 28, 9); |
669 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 669 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
670 ui::AX_TEXT_DIRECTION_LR); | 670 ui::AX_TEXT_DIRECTION_LTR); |
671 std::vector<int32> character_offsets2; | 671 std::vector<int32> character_offsets2; |
672 character_offsets2.push_back(5); | 672 character_offsets2.push_back(5); |
673 character_offsets2.push_back(10); | 673 character_offsets2.push_back(10); |
674 character_offsets2.push_back(15); | 674 character_offsets2.push_back(15); |
675 character_offsets2.push_back(20); | 675 character_offsets2.push_back(20); |
676 character_offsets2.push_back(25); | 676 character_offsets2.push_back(25); |
677 character_offsets2.push_back(28); | 677 character_offsets2.push_back(28); |
678 inline_text2.AddIntListAttribute( | 678 inline_text2.AddIntListAttribute( |
679 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 679 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
680 static_text.child_ids.push_back(4); | 680 static_text.child_ids.push_back(4); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 736 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
737 static_text.location = gfx::Rect(100, 100, 60, 20); | 737 static_text.location = gfx::Rect(100, 100, 60, 20); |
738 root.child_ids.push_back(2); | 738 root.child_ids.push_back(2); |
739 | 739 |
740 ui::AXNodeData inline_text1; | 740 ui::AXNodeData inline_text1; |
741 inline_text1.id = 3; | 741 inline_text1.id = 3; |
742 inline_text1.SetValue("123"); | 742 inline_text1.SetValue("123"); |
743 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 743 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
744 inline_text1.location = gfx::Rect(100, 100, 30, 20); | 744 inline_text1.location = gfx::Rect(100, 100, 30, 20); |
745 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 745 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
746 ui::AX_TEXT_DIRECTION_LR); | 746 ui::AX_TEXT_DIRECTION_LTR); |
747 std::vector<int32> character_offsets1; | 747 std::vector<int32> character_offsets1; |
748 character_offsets1.push_back(10); // 0 | 748 character_offsets1.push_back(10); // 0 |
749 character_offsets1.push_back(20); // 1 | 749 character_offsets1.push_back(20); // 1 |
750 character_offsets1.push_back(30); // 2 | 750 character_offsets1.push_back(30); // 2 |
751 inline_text1.AddIntListAttribute( | 751 inline_text1.AddIntListAttribute( |
752 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 752 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
753 static_text.child_ids.push_back(3); | 753 static_text.child_ids.push_back(3); |
754 | 754 |
755 ui::AXNodeData inline_text2; | 755 ui::AXNodeData inline_text2; |
756 inline_text2.id = 4; | 756 inline_text2.id = 4; |
757 inline_text2.SetValue("abc"); | 757 inline_text2.SetValue("abc"); |
758 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 758 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
759 inline_text2.location = gfx::Rect(130, 100, 30, 20); | 759 inline_text2.location = gfx::Rect(130, 100, 30, 20); |
760 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 760 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
761 ui::AX_TEXT_DIRECTION_RL); | 761 ui::AX_TEXT_DIRECTION_RTL); |
762 std::vector<int32> character_offsets2; | 762 std::vector<int32> character_offsets2; |
763 character_offsets2.push_back(10); | 763 character_offsets2.push_back(10); |
764 character_offsets2.push_back(20); | 764 character_offsets2.push_back(20); |
765 character_offsets2.push_back(30); | 765 character_offsets2.push_back(30); |
766 inline_text2.AddIntListAttribute( | 766 inline_text2.AddIntListAttribute( |
767 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 767 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
768 static_text.child_ids.push_back(4); | 768 static_text.child_ids.push_back(4); |
769 | 769 |
770 scoped_ptr<BrowserAccessibilityManager> manager( | 770 scoped_ptr<BrowserAccessibilityManager> manager( |
771 BrowserAccessibilityManager::Create( | 771 BrowserAccessibilityManager::Create( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 static_text.role = ui::AX_ROLE_STATIC_TEXT; | 811 static_text.role = ui::AX_ROLE_STATIC_TEXT; |
812 static_text.location = gfx::Rect(100, 100, 16, 9); | 812 static_text.location = gfx::Rect(100, 100, 16, 9); |
813 root.child_ids.push_back(2); | 813 root.child_ids.push_back(2); |
814 | 814 |
815 ui::AXNodeData inline_text; | 815 ui::AXNodeData inline_text; |
816 inline_text.id = 3; | 816 inline_text.id = 3; |
817 inline_text.SetValue("ABC"); | 817 inline_text.SetValue("ABC"); |
818 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 818 inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
819 inline_text.location = gfx::Rect(100, 100, 16, 9); | 819 inline_text.location = gfx::Rect(100, 100, 16, 9); |
820 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 820 inline_text.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
821 ui::AX_TEXT_DIRECTION_LR); | 821 ui::AX_TEXT_DIRECTION_LTR); |
822 std::vector<int32> character_offsets1; | 822 std::vector<int32> character_offsets1; |
823 character_offsets1.push_back(6); // 0 | 823 character_offsets1.push_back(6); // 0 |
824 character_offsets1.push_back(11); // 1 | 824 character_offsets1.push_back(11); // 1 |
825 character_offsets1.push_back(16); // 2 | 825 character_offsets1.push_back(16); // 2 |
826 inline_text.AddIntListAttribute( | 826 inline_text.AddIntListAttribute( |
827 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 827 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
828 static_text.child_ids.push_back(3); | 828 static_text.child_ids.push_back(3); |
829 | 829 |
830 scoped_ptr<BrowserAccessibilityManager> manager( | 830 scoped_ptr<BrowserAccessibilityManager> manager( |
831 BrowserAccessibilityManager::Create( | 831 BrowserAccessibilityManager::Create( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 static_text2.role = ui::AX_ROLE_STATIC_TEXT; | 884 static_text2.role = ui::AX_ROLE_STATIC_TEXT; |
885 static_text2.location = gfx::Rect(160, 100, 40, 20); | 885 static_text2.location = gfx::Rect(160, 100, 40, 20); |
886 static_text2.child_ids.push_back(7); | 886 static_text2.child_ids.push_back(7); |
887 | 887 |
888 ui::AXNodeData inline_text1; | 888 ui::AXNodeData inline_text1; |
889 inline_text1.id = 6; | 889 inline_text1.id = 6; |
890 inline_text1.SetValue("AB"); | 890 inline_text1.SetValue("AB"); |
891 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 891 inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
892 inline_text1.location = gfx::Rect(100, 100, 40, 20); | 892 inline_text1.location = gfx::Rect(100, 100, 40, 20); |
893 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 893 inline_text1.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
894 ui::AX_TEXT_DIRECTION_LR); | 894 ui::AX_TEXT_DIRECTION_LTR); |
895 std::vector<int32> character_offsets1; | 895 std::vector<int32> character_offsets1; |
896 character_offsets1.push_back(20); // 0 | 896 character_offsets1.push_back(20); // 0 |
897 character_offsets1.push_back(40); // 1 | 897 character_offsets1.push_back(40); // 1 |
898 inline_text1.AddIntListAttribute( | 898 inline_text1.AddIntListAttribute( |
899 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); | 899 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); |
900 | 900 |
901 ui::AXNodeData inline_text2; | 901 ui::AXNodeData inline_text2; |
902 inline_text2.id = 7; | 902 inline_text2.id = 7; |
903 inline_text2.SetValue("CD"); | 903 inline_text2.SetValue("CD"); |
904 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; | 904 inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; |
905 inline_text2.location = gfx::Rect(160, 100, 40, 20); | 905 inline_text2.location = gfx::Rect(160, 100, 40, 20); |
906 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, | 906 inline_text2.AddIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, |
907 ui::AX_TEXT_DIRECTION_LR); | 907 ui::AX_TEXT_DIRECTION_LTR); |
908 std::vector<int32> character_offsets2; | 908 std::vector<int32> character_offsets2; |
909 character_offsets2.push_back(20); // 0 | 909 character_offsets2.push_back(20); // 0 |
910 character_offsets2.push_back(40); // 1 | 910 character_offsets2.push_back(40); // 1 |
911 inline_text2.AddIntListAttribute( | 911 inline_text2.AddIntListAttribute( |
912 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); | 912 ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); |
913 | 913 |
914 scoped_ptr<BrowserAccessibilityManager> manager( | 914 scoped_ptr<BrowserAccessibilityManager> manager( |
915 BrowserAccessibilityManager::Create( | 915 BrowserAccessibilityManager::Create( |
916 MakeAXTreeUpdate( | 916 MakeAXTreeUpdate( |
917 root, div, static_text1, img, | 917 root, div, static_text1, img, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 ASSERT_EQ(NULL, manager->NextInTreeOrder(node5_accessible)); | 981 ASSERT_EQ(NULL, manager->NextInTreeOrder(node5_accessible)); |
982 | 982 |
983 ASSERT_EQ(NULL, manager->PreviousInTreeOrder(NULL)); | 983 ASSERT_EQ(NULL, manager->PreviousInTreeOrder(NULL)); |
984 ASSERT_EQ(node4_accessible, manager->PreviousInTreeOrder(node5_accessible)); | 984 ASSERT_EQ(node4_accessible, manager->PreviousInTreeOrder(node5_accessible)); |
985 ASSERT_EQ(node3_accessible, manager->PreviousInTreeOrder(node4_accessible)); | 985 ASSERT_EQ(node3_accessible, manager->PreviousInTreeOrder(node4_accessible)); |
986 ASSERT_EQ(node2_accessible, manager->PreviousInTreeOrder(node3_accessible)); | 986 ASSERT_EQ(node2_accessible, manager->PreviousInTreeOrder(node3_accessible)); |
987 ASSERT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible)); | 987 ASSERT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible)); |
988 } | 988 } |
989 | 989 |
990 } // namespace content | 990 } // namespace content |
OLD | NEW |