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 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 5 #ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 6 #define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <oleacc.h> | 10 #include <oleacc.h> |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 // If the bool attribute |attribute| is present, add its value as an | 759 // If the bool attribute |attribute| is present, add its value as an |
760 // IAccessible2 attribute with the name |ia2_attr|. | 760 // IAccessible2 attribute with the name |ia2_attr|. |
761 void BoolAttributeToIA2(ui::AXBoolAttribute attribute, | 761 void BoolAttributeToIA2(ui::AXBoolAttribute attribute, |
762 const char* ia2_attr); | 762 const char* ia2_attr); |
763 | 763 |
764 // If the int attribute |attribute| is present, add its value as an | 764 // If the int attribute |attribute| is present, add its value as an |
765 // IAccessible2 attribute with the name |ia2_attr|. | 765 // IAccessible2 attribute with the name |ia2_attr|. |
766 void IntAttributeToIA2(ui::AXIntAttribute attribute, | 766 void IntAttributeToIA2(ui::AXIntAttribute attribute, |
767 const char* ia2_attr); | 767 const char* ia2_attr); |
768 | 768 |
769 // Functions that help when retrieving hyperlinks. Return -1 in case of | 769 // Functions that help in retrieving hyperlinks. Return -1 in case of failure. |
770 // failure. | |
771 // (Hyperlink is an IA2 misnomer. It refers to objects embedded within other | 770 // (Hyperlink is an IA2 misnomer. It refers to objects embedded within other |
772 // objects, such as a numbered list within a contenteditable div.) | 771 // objects, such as a numbered list within a contenteditable div.) |
773 int32 GetHyperlinkIndexFromChild(const BrowserAccessibilityWin& child) const; | 772 int32 GetHyperlinkIndexFromChild(const BrowserAccessibilityWin& child) const; |
774 int32 GetHypertextOffsetFromHyperlinkIndex(int32 hyperlink_index) const; | 773 int32 GetHypertextOffsetFromHyperlinkIndex(int32 hyperlink_index) const; |
775 int32 GetHypertextOffsetFromChild(const BrowserAccessibilityWin& child) const; | 774 int32 GetHypertextOffsetFromChild(const BrowserAccessibilityWin& child) const; |
776 int32 GetHypertextOffsetFromDescendant( | 775 int32 GetHypertextOffsetFromDescendant( |
777 const BrowserAccessibilityWin& descendant) const; | 776 const BrowserAccessibilityWin& descendant) const; |
778 | 777 |
779 // If the selection endpoint is either equal to or an ancestor of this object, | |
780 // returns endpoint_offset. | |
781 // If the selection endpoint is a descendant of this object, returns its | |
782 // embedded character offset. Otherwise, returns either 0 or the length of the | |
783 // hypertext, depending on the direction of the selection. | |
784 // Returns -1 in case of unexpected failure, e.g. the selection endpoint | |
785 // cannot be located in the accessibility tree. | |
786 int GetHypertextOffsetFromEndpoint( | |
787 const BrowserAccessibilityWin& endpoint_object, | |
788 int endpoint_offset) const; | |
789 | |
790 // The following functions retrieve the endpoints of the current selection. | 778 // The following functions retrieve the endpoints of the current selection. |
791 // First they check for a local selection found on the current control, e.g. | 779 // First they checks for a local selection found on the current control, e.g. |
792 // when querying the selection on a textarea. | 780 // when querying the selection on a textarea. |
793 // If not found they retrieve the global selection found on the current frame. | 781 // If not found they retrieve the global selection found on the current frame. |
794 int GetSelectionAnchor() const; | 782 int GetSelectionAnchor() const; |
795 int GetSelectionFocus() const; | 783 int GetSelectionFocus() const; |
796 // Retrieves the selection offsets in the way required by the IA2 APIs. | 784 // Retrieves the selection offsets in the way required by the IA2 APIs. |
797 // selection_start and selection_end are -1 when there is no selection active | 785 // (Selection_start is always <= selection_end and |
798 // inside this object. | 786 // selection_end is one past the last character of the selection.) |
799 // The greatest of the two offsets is one past the last character of the | |
800 // selection.) | |
801 void GetSelectionOffsets(int* selection_start, int* selection_end) const; | 787 void GetSelectionOffsets(int* selection_start, int* selection_end) const; |
802 | 788 |
803 // Append the accessible name from this node and its children. | 789 // Append the accessible name from this node and its children. |
804 base::string16 GetNameRecursive() const; | 790 base::string16 GetNameRecursive() const; |
805 | 791 |
806 // Get the value text, which might come from the floating-point | 792 // Get the value text, which might come from the floating-point |
807 // value for some roles. | 793 // value for some roles. |
808 base::string16 GetValueText(); | 794 base::string16 GetValueText(); |
809 | 795 |
810 // Get the text of this node for the purposes of IAccessibleText - it may | 796 // Get the text of this node for the purposes of IAccessibleText - it may |
811 // be the name, it may be the value, etc. depending on the role. | 797 // be the name, it may be the value, etc. depending on the role. |
812 base::string16 TextForIAccessibleText() const; | 798 base::string16 TextForIAccessibleText(); |
813 | 799 |
814 bool IsSameHypertextCharacter(size_t old_char_index, size_t new_char_index); | 800 bool IsSameHypertextCharacter(size_t old_char_index, size_t new_char_index); |
815 void ComputeHypertextRemovedAndInserted( | 801 void ComputeHypertextRemovedAndInserted( |
816 int* start, int* old_len, int* new_len); | 802 int* start, int* old_len, int* new_len); |
817 | 803 |
818 // If offset is a member of IA2TextSpecialOffsets this function updates the | 804 // If offset is a member of IA2TextSpecialOffsets this function updates the |
819 // value of offset and returns, otherwise offset remains unchanged. | 805 // value of offset and returns, otherwise offset remains unchanged. |
820 void HandleSpecialTextOffset(const base::string16& text, LONG* offset); | 806 void HandleSpecialTextOffset(const base::string16& text, LONG* offset); |
821 | 807 |
822 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. | 808 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 int32 ia2_state; | 849 int32 ia2_state; |
864 | 850 |
865 // IAccessible2 attributes. | 851 // IAccessible2 attributes. |
866 std::vector<base::string16> ia2_attributes; | 852 std::vector<base::string16> ia2_attributes; |
867 | 853 |
868 // Hypertext. | 854 // Hypertext. |
869 base::string16 hypertext; | 855 base::string16 hypertext; |
870 | 856 |
871 // Maps the |hypertext_| embedded character offset to an index in | 857 // Maps the |hypertext_| embedded character offset to an index in |
872 // |hyperlinks_|. | 858 // |hyperlinks_|. |
| 859 // TODO(nektar): Replace map with vector of offsets. |
873 std::map<int32, int32> hyperlink_offset_to_index; | 860 std::map<int32, int32> hyperlink_offset_to_index; |
874 | 861 |
875 // The id of a BrowserAccessibilityWin for each hyperlink. | 862 // The id of a BrowserAccessibilityWin for each hyperlink. |
876 // TODO(nektar): Replace object IDs with child indices. | 863 // TODO(nektar): Replace object IDs with child indices. |
877 std::vector<int32> hyperlinks; | 864 std::vector<int32> hyperlinks; |
878 }; | 865 }; |
879 | 866 |
880 scoped_ptr<WinAttributes> win_attributes_; | 867 scoped_ptr<WinAttributes> win_attributes_; |
881 | 868 |
882 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or | 869 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or |
(...skipping 13 matching lines...) Expand all Loading... |
896 // Give BrowserAccessibility::Create access to our constructor. | 883 // Give BrowserAccessibility::Create access to our constructor. |
897 friend class BrowserAccessibility; | 884 friend class BrowserAccessibility; |
898 friend class BrowserAccessibilityRelation; | 885 friend class BrowserAccessibilityRelation; |
899 | 886 |
900 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); | 887 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
901 }; | 888 }; |
902 | 889 |
903 } // namespace content | 890 } // namespace content |
904 | 891 |
905 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 892 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
OLD | NEW |