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> |
| 11 #include <stddef.h> |
| 12 #include <stdint.h> |
11 #include <UIAutomationCore.h> | 13 #include <UIAutomationCore.h> |
12 | 14 |
13 #include <vector> | 15 #include <vector> |
14 | 16 |
15 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
16 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" |
17 #include "content/browser/accessibility/browser_accessibility.h" | 20 #include "content/browser/accessibility/browser_accessibility.h" |
18 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
19 #include "third_party/iaccessible2/ia2_api_all.h" | 22 #include "third_party/iaccessible2/ia2_api_all.h" |
20 #include "third_party/isimpledom/ISimpleDOMDocument.h" | 23 #include "third_party/isimpledom/ISimpleDOMDocument.h" |
21 #include "third_party/isimpledom/ISimpleDOMNode.h" | 24 #include "third_party/isimpledom/ISimpleDOMNode.h" |
22 #include "third_party/isimpledom/ISimpleDOMText.h" | 25 #include "third_party/isimpledom/ISimpleDOMText.h" |
23 | 26 |
24 namespace ui { | 27 namespace ui { |
25 enum TextBoundaryDirection; | 28 enum TextBoundaryDirection; |
26 enum TextBoundaryType; | 29 enum TextBoundaryType; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 COM_INTERFACE_ENTRY(ISimpleDOMText) | 83 COM_INTERFACE_ENTRY(ISimpleDOMText) |
81 END_COM_MAP() | 84 END_COM_MAP() |
82 | 85 |
83 // Represents a non-static text node in IAccessibleHypertext. This character | 86 // Represents a non-static text node in IAccessibleHypertext. This character |
84 // is embedded in the response to IAccessibleText::get_text, indicating the | 87 // is embedded in the response to IAccessibleText::get_text, indicating the |
85 // position where a non-static text child object appears. | 88 // position where a non-static text child object appears. |
86 CONTENT_EXPORT static const base::char16 kEmbeddedCharacter; | 89 CONTENT_EXPORT static const base::char16 kEmbeddedCharacter; |
87 | 90 |
88 // Mappings from roles and states to human readable strings. Initialize | 91 // Mappings from roles and states to human readable strings. Initialize |
89 // with |InitializeStringMaps|. | 92 // with |InitializeStringMaps|. |
90 static std::map<int32, base::string16> role_string_map; | 93 static std::map<int32_t, base::string16> role_string_map; |
91 static std::map<int32, base::string16> state_string_map; | 94 static std::map<int32_t, base::string16> state_string_map; |
92 | 95 |
93 CONTENT_EXPORT BrowserAccessibilityWin(); | 96 CONTENT_EXPORT BrowserAccessibilityWin(); |
94 | 97 |
95 CONTENT_EXPORT ~BrowserAccessibilityWin() override; | 98 CONTENT_EXPORT ~BrowserAccessibilityWin() override; |
96 | 99 |
97 // The Windows-specific unique ID, used as the child ID for MSAA methods | 100 // The Windows-specific unique ID, used as the child ID for MSAA methods |
98 // like NotifyWinEvent, and as the unique ID for IAccessible2 and ISimpleDOM. | 101 // like NotifyWinEvent, and as the unique ID for IAccessible2 and ISimpleDOM. |
99 LONG unique_id_win() const { return unique_id_win_; } | 102 LONG unique_id_win() const { return unique_id_win_; } |
100 | 103 |
101 // Called after an atomic tree update completes. See | 104 // Called after an atomic tree update completes. See |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 // | 707 // |
705 | 708 |
706 // Called by BEGIN_COM_MAP() / END_COM_MAP(). | 709 // Called by BEGIN_COM_MAP() / END_COM_MAP(). |
707 static CONTENT_EXPORT HRESULT WINAPI | 710 static CONTENT_EXPORT HRESULT WINAPI |
708 InternalQueryInterface(void* this_ptr, | 711 InternalQueryInterface(void* this_ptr, |
709 const _ATL_INTMAP_ENTRY* entries, | 712 const _ATL_INTMAP_ENTRY* entries, |
710 REFIID iid, | 713 REFIID iid, |
711 void** object); | 714 void** object); |
712 | 715 |
713 // Accessors. | 716 // Accessors. |
714 int32 ia_role() const { return win_attributes_->ia_role; } | 717 int32_t ia_role() const { return win_attributes_->ia_role; } |
715 int32 ia_state() const { return win_attributes_->ia_state; } | 718 int32_t ia_state() const { return win_attributes_->ia_state; } |
716 const base::string16& role_name() const { return win_attributes_->role_name; } | 719 const base::string16& role_name() const { return win_attributes_->role_name; } |
717 int32 ia2_role() const { return win_attributes_->ia2_role; } | 720 int32_t ia2_role() const { return win_attributes_->ia2_role; } |
718 int32 ia2_state() const { return win_attributes_->ia2_state; } | 721 int32_t ia2_state() const { return win_attributes_->ia2_state; } |
719 const std::vector<base::string16>& ia2_attributes() const { | 722 const std::vector<base::string16>& ia2_attributes() const { |
720 return win_attributes_->ia2_attributes; | 723 return win_attributes_->ia2_attributes; |
721 } | 724 } |
722 base::string16 name() const { return win_attributes_->name; } | 725 base::string16 name() const { return win_attributes_->name; } |
723 base::string16 description() const { return win_attributes_->description; } | 726 base::string16 description() const { return win_attributes_->description; } |
724 base::string16 value() const { return win_attributes_->value; } | 727 base::string16 value() const { return win_attributes_->value; } |
725 base::string16 hypertext() const { return win_attributes_->hypertext; } | 728 base::string16 hypertext() const { return win_attributes_->hypertext; } |
726 std::map<int32, int32>& hyperlink_offset_to_index() const { | 729 std::map<int32_t, int32_t>& hyperlink_offset_to_index() const { |
727 return win_attributes_->hyperlink_offset_to_index; | 730 return win_attributes_->hyperlink_offset_to_index; |
728 } | 731 } |
729 std::vector<int32>& hyperlinks() const { return win_attributes_->hyperlinks; } | 732 std::vector<int32_t>& hyperlinks() const { |
| 733 return win_attributes_->hyperlinks; |
| 734 } |
730 | 735 |
731 private: | 736 private: |
732 // Add one to the reference count and return the same object. Always | 737 // Add one to the reference count and return the same object. Always |
733 // use this method when returning a BrowserAccessibilityWin object as | 738 // use this method when returning a BrowserAccessibilityWin object as |
734 // an output parameter to a COM interface, never use it otherwise. | 739 // an output parameter to a COM interface, never use it otherwise. |
735 BrowserAccessibilityWin* NewReference(); | 740 BrowserAccessibilityWin* NewReference(); |
736 | 741 |
737 // Many MSAA methods take a var_id parameter indicating that the operation | 742 // Many MSAA methods take a var_id parameter indicating that the operation |
738 // should be performed on a particular child ID, rather than this object. | 743 // should be performed on a particular child ID, rather than this object. |
739 // This method tries to figure out the target object from |var_id| and | 744 // This method tries to figure out the target object from |var_id| and |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 // | 785 // |
781 // Hyperlink is an IA2 misnomer. It refers to objects embedded within other | 786 // Hyperlink is an IA2 misnomer. It refers to objects embedded within other |
782 // objects, such as a numbered list within a contenteditable div. | 787 // objects, such as a numbered list within a contenteditable div. |
783 // Also, in IA2, text that includes embedded objects is called hypertext. | 788 // Also, in IA2, text that includes embedded objects is called hypertext. |
784 | 789 |
785 // Returns true if the current object is an IA2 hyperlink. | 790 // Returns true if the current object is an IA2 hyperlink. |
786 bool IsHyperlink() const; | 791 bool IsHyperlink() const; |
787 | 792 |
788 // Functions for retrieving offsets for hyperlinks and hypertext. | 793 // Functions for retrieving offsets for hyperlinks and hypertext. |
789 // Return -1 in case of failure. | 794 // Return -1 in case of failure. |
790 int32 GetHyperlinkIndexFromChild(const BrowserAccessibilityWin& child) const; | 795 int32_t GetHyperlinkIndexFromChild( |
791 int32 GetHypertextOffsetFromHyperlinkIndex(int32 hyperlink_index) const; | 796 const BrowserAccessibilityWin& child) const; |
792 int32 GetHypertextOffsetFromChild(const BrowserAccessibilityWin& child) const; | 797 int32_t GetHypertextOffsetFromHyperlinkIndex(int32_t hyperlink_index) const; |
793 int32 GetHypertextOffsetFromDescendant( | 798 int32_t GetHypertextOffsetFromChild( |
| 799 const BrowserAccessibilityWin& child) const; |
| 800 int32_t GetHypertextOffsetFromDescendant( |
794 const BrowserAccessibilityWin& descendant) const; | 801 const BrowserAccessibilityWin& descendant) const; |
795 | 802 |
796 // If the selection endpoint is either equal to or an ancestor of this object, | 803 // If the selection endpoint is either equal to or an ancestor of this object, |
797 // returns endpoint_offset. | 804 // returns endpoint_offset. |
798 // If the selection endpoint is a descendant of this object, returns its | 805 // If the selection endpoint is a descendant of this object, returns its |
799 // offset. Otherwise, returns either 0 or the length of the hypertext | 806 // offset. Otherwise, returns either 0 or the length of the hypertext |
800 // depending on the direction of the selection. | 807 // depending on the direction of the selection. |
801 // Returns -1 in case of unexpected failure, e.g. the selection endpoint | 808 // Returns -1 in case of unexpected failure, e.g. the selection endpoint |
802 // cannot be found in the accessibility tree. | 809 // cannot be found in the accessibility tree. |
803 int GetHypertextOffsetFromEndpoint( | 810 int GetHypertextOffsetFromEndpoint( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 // Search forwards (direction == 1) or backwards (direction == -1) | 845 // Search forwards (direction == 1) or backwards (direction == -1) |
839 // from the given offset until the given boundary is found, and | 846 // from the given offset until the given boundary is found, and |
840 // return the offset of that boundary. | 847 // return the offset of that boundary. |
841 LONG FindBoundary(const base::string16& text, | 848 LONG FindBoundary(const base::string16& text, |
842 IA2TextBoundaryType ia2_boundary, | 849 IA2TextBoundaryType ia2_boundary, |
843 LONG start_offset, | 850 LONG start_offset, |
844 ui::TextBoundaryDirection direction); | 851 ui::TextBoundaryDirection direction); |
845 | 852 |
846 // Return a pointer to the object corresponding to the given id, | 853 // Return a pointer to the object corresponding to the given id, |
847 // does not make a new reference. | 854 // does not make a new reference. |
848 BrowserAccessibilityWin* GetFromID(int32 id); | 855 BrowserAccessibilityWin* GetFromID(int32_t id); |
849 | 856 |
850 // Returns true if this is a list box option with a parent of type list box, | 857 // Returns true if this is a list box option with a parent of type list box, |
851 // or a menu list option with a parent of type menu list popup. | 858 // or a menu list option with a parent of type menu list popup. |
852 bool IsListBoxOptionOrMenuListOption(); | 859 bool IsListBoxOptionOrMenuListOption(); |
853 | 860 |
854 // Updates object attributes of IA2 with html attributes. | 861 // Updates object attributes of IA2 with html attributes. |
855 void UpdateRequiredAttributes(); | 862 void UpdateRequiredAttributes(); |
856 | 863 |
857 // Given an int list attribute containing the ids of related elements, | 864 // Given an int list attribute containing the ids of related elements, |
858 // add a new IAccessibleRelation for this object with the given type name. | 865 // add a new IAccessibleRelation for this object with the given type name. |
859 void AddRelations(ui::AXIntListAttribute src_attr, | 866 void AddRelations(ui::AXIntListAttribute src_attr, |
860 const base::string16& iaccessiblerelation_type); | 867 const base::string16& iaccessiblerelation_type); |
861 | 868 |
862 // Windows-specific unique ID (unique within the browser process), | 869 // Windows-specific unique ID (unique within the browser process), |
863 // used for get_accChild, NotifyWinEvent, and as the unique ID for | 870 // used for get_accChild, NotifyWinEvent, and as the unique ID for |
864 // IAccessible2 and ISimpleDOM. | 871 // IAccessible2 and ISimpleDOM. |
865 LONG unique_id_win_; | 872 LONG unique_id_win_; |
866 | 873 |
867 struct WinAttributes { | 874 struct WinAttributes { |
868 WinAttributes(); | 875 WinAttributes(); |
869 ~WinAttributes(); | 876 ~WinAttributes(); |
870 | 877 |
871 // IAccessible role and state. | 878 // IAccessible role and state. |
872 int32 ia_role; | 879 int32_t ia_role; |
873 int32 ia_state; | 880 int32_t ia_state; |
874 base::string16 role_name; | 881 base::string16 role_name; |
875 | 882 |
876 // IAccessible name, description, help, value. | 883 // IAccessible name, description, help, value. |
877 base::string16 name; | 884 base::string16 name; |
878 base::string16 description; | 885 base::string16 description; |
879 base::string16 value; | 886 base::string16 value; |
880 | 887 |
881 // IAccessible2 role and state. | 888 // IAccessible2 role and state. |
882 int32 ia2_role; | 889 int32_t ia2_role; |
883 int32 ia2_state; | 890 int32_t ia2_state; |
884 | 891 |
885 // IAccessible2 attributes. | 892 // IAccessible2 attributes. |
886 std::vector<base::string16> ia2_attributes; | 893 std::vector<base::string16> ia2_attributes; |
887 | 894 |
888 // Hypertext. | 895 // Hypertext. |
889 base::string16 hypertext; | 896 base::string16 hypertext; |
890 | 897 |
891 // Maps the |hypertext_| embedded character offset to an index in | 898 // Maps the |hypertext_| embedded character offset to an index in |
892 // |hyperlinks_|. | 899 // |hyperlinks_|. |
893 std::map<int32, int32> hyperlink_offset_to_index; | 900 std::map<int32_t, int32_t> hyperlink_offset_to_index; |
894 | 901 |
895 // The id of a BrowserAccessibilityWin for each hyperlink. | 902 // The id of a BrowserAccessibilityWin for each hyperlink. |
896 // TODO(nektar): Replace object IDs with child indices. | 903 // TODO(nektar): Replace object IDs with child indices. |
897 std::vector<int32> hyperlinks; | 904 std::vector<int32_t> hyperlinks; |
898 }; | 905 }; |
899 | 906 |
900 scoped_ptr<WinAttributes> win_attributes_; | 907 scoped_ptr<WinAttributes> win_attributes_; |
901 | 908 |
902 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or | 909 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or |
903 // IA2_EVENT_TEXT_INSERTED event. | 910 // IA2_EVENT_TEXT_INSERTED event. |
904 scoped_ptr<WinAttributes> old_win_attributes_; | 911 scoped_ptr<WinAttributes> old_win_attributes_; |
905 | 912 |
906 // Relationships between this node and other nodes. | 913 // Relationships between this node and other nodes. |
907 std::vector<BrowserAccessibilityRelation*> relations_; | 914 std::vector<BrowserAccessibilityRelation*> relations_; |
908 | 915 |
909 // The previous scroll position, so we can tell if this object scrolled. | 916 // The previous scroll position, so we can tell if this object scrolled. |
910 int previous_scroll_x_; | 917 int previous_scroll_x_; |
911 int previous_scroll_y_; | 918 int previous_scroll_y_; |
912 | 919 |
913 // The next unique id to use. | 920 // The next unique id to use. |
914 static LONG next_unique_id_win_; | 921 static LONG next_unique_id_win_; |
915 | 922 |
916 // Give BrowserAccessibility::Create access to our constructor. | 923 // Give BrowserAccessibility::Create access to our constructor. |
917 friend class BrowserAccessibility; | 924 friend class BrowserAccessibility; |
918 friend class BrowserAccessibilityRelation; | 925 friend class BrowserAccessibilityRelation; |
919 | 926 |
920 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); | 927 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
921 }; | 928 }; |
922 | 929 |
923 } // namespace content | 930 } // namespace content |
924 | 931 |
925 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 932 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
OLD | NEW |