| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 static std::map<int32, base::string16> state_string_map; | 90 static std::map<int32, base::string16> state_string_map; |
| 91 | 91 |
| 92 CONTENT_EXPORT BrowserAccessibilityWin(); | 92 CONTENT_EXPORT BrowserAccessibilityWin(); |
| 93 | 93 |
| 94 CONTENT_EXPORT virtual ~BrowserAccessibilityWin(); | 94 CONTENT_EXPORT virtual ~BrowserAccessibilityWin(); |
| 95 | 95 |
| 96 // The Windows-specific unique ID, used as the child ID for MSAA methods | 96 // The Windows-specific unique ID, used as the child ID for MSAA methods |
| 97 // like NotifyWinEvent, and as the unique ID for IAccessible2 and ISimpleDOM. | 97 // like NotifyWinEvent, and as the unique ID for IAccessible2 and ISimpleDOM. |
| 98 LONG unique_id_win() const { return unique_id_win_; } | 98 LONG unique_id_win() const { return unique_id_win_; } |
| 99 | 99 |
| 100 CONTENT_EXPORT void UpdateIAccessibleText(); | |
| 101 | |
| 102 // | 100 // |
| 103 // BrowserAccessibility methods. | 101 // BrowserAccessibility methods. |
| 104 // | 102 // |
| 105 CONTENT_EXPORT virtual void OnDataChanged() override; | 103 CONTENT_EXPORT virtual void OnDataChanged() override; |
| 106 CONTENT_EXPORT virtual void OnUpdateFinished() override; | 104 CONTENT_EXPORT virtual void OnUpdateFinished() override; |
| 107 CONTENT_EXPORT virtual void OnSubtreeWillBeDeleted() override; | |
| 108 CONTENT_EXPORT virtual void OnSubtreeCreationFinished() override; | |
| 109 CONTENT_EXPORT virtual void NativeAddReference() override; | 105 CONTENT_EXPORT virtual void NativeAddReference() override; |
| 110 CONTENT_EXPORT virtual void NativeReleaseReference() override; | 106 CONTENT_EXPORT virtual void NativeReleaseReference() override; |
| 111 CONTENT_EXPORT virtual bool IsNative() const override; | 107 CONTENT_EXPORT virtual bool IsNative() const override; |
| 112 CONTENT_EXPORT virtual void OnLocationChanged() override; | 108 CONTENT_EXPORT virtual void OnLocationChanged() override; |
| 113 | 109 |
| 114 // | 110 // |
| 115 // IAccessible methods. | 111 // IAccessible methods. |
| 116 // | 112 // |
| 117 | 113 |
| 118 // Performs the default action on a given object. | 114 // Performs the default action on a given object. |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // | 768 // |
| 773 | 769 |
| 774 // Called by BEGIN_COM_MAP() / END_COM_MAP(). | 770 // Called by BEGIN_COM_MAP() / END_COM_MAP(). |
| 775 static CONTENT_EXPORT HRESULT WINAPI | 771 static CONTENT_EXPORT HRESULT WINAPI |
| 776 InternalQueryInterface(void* this_ptr, | 772 InternalQueryInterface(void* this_ptr, |
| 777 const _ATL_INTMAP_ENTRY* entries, | 773 const _ATL_INTMAP_ENTRY* entries, |
| 778 REFIID iid, | 774 REFIID iid, |
| 779 void** object); | 775 void** object); |
| 780 | 776 |
| 781 // Accessors. | 777 // Accessors. |
| 782 int32 ia_role() const { return win_attributes_->ia_role; } | 778 int32 ia_role() const { return ia_role_; } |
| 783 int32 ia_state() const { return win_attributes_->ia_state; } | 779 int32 ia_state() const { return ia_state_; } |
| 784 const base::string16& role_name() const { return win_attributes_->role_name; } | 780 const base::string16& role_name() const { return role_name_; } |
| 785 int32 ia2_role() const { return win_attributes_->ia2_role; } | 781 int32 ia2_role() const { return ia2_role_; } |
| 786 int32 ia2_state() const { return win_attributes_->ia2_state; } | 782 int32 ia2_state() const { return ia2_state_; } |
| 787 const std::vector<base::string16>& ia2_attributes() const { | 783 const std::vector<base::string16>& ia2_attributes() const { |
| 788 return win_attributes_->ia2_attributes; | 784 return ia2_attributes_; |
| 789 } | 785 } |
| 790 base::string16 name() const { return win_attributes_->name; } | |
| 791 base::string16 description() const { return win_attributes_->description; } | |
| 792 base::string16 help() const { return win_attributes_->help; } | |
| 793 base::string16 value() const { return win_attributes_->value; } | |
| 794 | 786 |
| 795 private: | 787 private: |
| 796 // Add one to the reference count and return the same object. Always | 788 // Add one to the reference count and return the same object. Always |
| 797 // use this method when returning a BrowserAccessibilityWin object as | 789 // use this method when returning a BrowserAccessibilityWin object as |
| 798 // an output parameter to a COM interface, never use it otherwise. | 790 // an output parameter to a COM interface, never use it otherwise. |
| 799 BrowserAccessibilityWin* NewReference(); | 791 BrowserAccessibilityWin* NewReference(); |
| 800 | 792 |
| 801 // Many MSAA methods take a var_id parameter indicating that the operation | 793 // Many MSAA methods take a var_id parameter indicating that the operation |
| 802 // should be performed on a particular child ID, rather than this object. | 794 // should be performed on a particular child ID, rather than this object. |
| 803 // This method tries to figure out the target object from |var_id| and | 795 // This method tries to figure out the target object from |var_id| and |
| (...skipping 20 matching lines...) Expand all Loading... |
| 824 // If the bool attribute |attribute| is present, add its value as an | 816 // If the bool attribute |attribute| is present, add its value as an |
| 825 // IAccessible2 attribute with the name |ia2_attr|. | 817 // IAccessible2 attribute with the name |ia2_attr|. |
| 826 void BoolAttributeToIA2(ui::AXBoolAttribute attribute, | 818 void BoolAttributeToIA2(ui::AXBoolAttribute attribute, |
| 827 const char* ia2_attr); | 819 const char* ia2_attr); |
| 828 | 820 |
| 829 // If the int attribute |attribute| is present, add its value as an | 821 // If the int attribute |attribute| is present, add its value as an |
| 830 // IAccessible2 attribute with the name |ia2_attr|. | 822 // IAccessible2 attribute with the name |ia2_attr|. |
| 831 void IntAttributeToIA2(ui::AXIntAttribute attribute, | 823 void IntAttributeToIA2(ui::AXIntAttribute attribute, |
| 832 const char* ia2_attr); | 824 const char* ia2_attr); |
| 833 | 825 |
| 834 // Append the accessible name from this node and its children. | |
| 835 base::string16 GetNameRecursive() const; | |
| 836 | |
| 837 // Get the value text, which might come from the floating-point | 826 // Get the value text, which might come from the floating-point |
| 838 // value for some roles. | 827 // value for some roles. |
| 839 base::string16 GetValueText(); | 828 base::string16 GetValueText(); |
| 840 | 829 |
| 841 // Get the text of this node for the purposes of IAccessibleText - it may | 830 // Get the text of this node for the purposes of IAccessibleText - it may |
| 842 // be the name, it may be the value, etc. depending on the role. | 831 // be the name, it may be the value, etc. depending on the role. |
| 843 base::string16 TextForIAccessibleText(); | 832 base::string16 TextForIAccessibleText(); |
| 844 | 833 |
| 845 void ComputeHypertextRemovedAndInserted( | |
| 846 int* start, int* old_len, int* new_len); | |
| 847 | |
| 848 // If offset is a member of IA2TextSpecialOffsets this function updates the | 834 // If offset is a member of IA2TextSpecialOffsets this function updates the |
| 849 // value of offset and returns, otherwise offset remains unchanged. | 835 // value of offset and returns, otherwise offset remains unchanged. |
| 850 void HandleSpecialTextOffset(const base::string16& text, LONG* offset); | 836 void HandleSpecialTextOffset(const base::string16& text, LONG* offset); |
| 851 | 837 |
| 852 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. | 838 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. |
| 853 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); | 839 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); |
| 854 | 840 |
| 855 // Search forwards (direction == 1) or backwards (direction == -1) | 841 // Search forwards (direction == 1) or backwards (direction == -1) |
| 856 // from the given offset until the given boundary is found, and | 842 // from the given offset until the given boundary is found, and |
| 857 // return the offset of that boundary. | 843 // return the offset of that boundary. |
| 858 LONG FindBoundary(const base::string16& text, | 844 LONG FindBoundary(const base::string16& text, |
| 859 IA2TextBoundaryType ia2_boundary, | 845 IA2TextBoundaryType ia2_boundary, |
| 860 LONG start_offset, | 846 LONG start_offset, |
| 861 ui::TextBoundaryDirection direction); | 847 ui::TextBoundaryDirection direction); |
| 862 | 848 |
| 863 // Return a pointer to the object corresponding to the given id, | 849 // Return a pointer to the object corresponding to the given id, |
| 864 // does not make a new reference. | 850 // does not make a new reference. |
| 865 BrowserAccessibilityWin* GetFromID(int32 id); | 851 BrowserAccessibilityWin* GetFromID(int32 id); |
| 866 | 852 |
| 867 // Windows-specific unique ID (unique within the browser process), | 853 // Windows-specific unique ID (unique within the browser process), |
| 868 // used for get_accChild, NotifyWinEvent, and as the unique ID for | 854 // used for get_accChild, NotifyWinEvent, and as the unique ID for |
| 869 // IAccessible2 and ISimpleDOM. | 855 // IAccessible2 and ISimpleDOM. |
| 870 LONG unique_id_win_; | 856 LONG unique_id_win_; |
| 871 | 857 |
| 872 struct WinAttributes { | 858 // IAccessible role and state. |
| 873 WinAttributes(); | 859 int32 ia_role_; |
| 860 int32 ia_state_; |
| 861 base::string16 role_name_; |
| 874 | 862 |
| 875 // IAccessible role and state. | 863 // IAccessible2 role and state. |
| 876 int32 ia_role; | 864 int32 ia2_role_; |
| 877 int32 ia_state; | 865 int32 ia2_state_; |
| 878 base::string16 role_name; | |
| 879 | 866 |
| 880 // IAccessible name, description, help, value. | 867 // IAccessible2 attributes. |
| 881 base::string16 name; | 868 std::vector<base::string16> ia2_attributes_; |
| 882 base::string16 description; | |
| 883 base::string16 help; | |
| 884 base::string16 value; | |
| 885 | 869 |
| 886 // IAccessible2 role and state. | 870 // True in Initialize when the object is first created, and false |
| 887 int32 ia2_role; | 871 // subsequent times. |
| 888 int32 ia2_state; | 872 bool first_time_; |
| 889 | 873 |
| 890 // IAccessible2 attributes. | 874 // The previous text, before the last update to this object. |
| 891 std::vector<base::string16> ia2_attributes; | 875 base::string16 previous_text_; |
| 892 }; | |
| 893 | 876 |
| 894 scoped_ptr<WinAttributes> win_attributes_; | 877 // The old text to return in IAccessibleText::get_oldText - this is like |
| 878 // previous_text_ except that it's NOT updated when the object |
| 879 // is initialized again but the text doesn't change. |
| 880 base::string16 old_text_; |
| 895 | 881 |
| 896 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or | 882 // The previous state, used to see if there was a state change. |
| 897 // IA2_EVENT_TEXT_INSERTED event. | 883 int32 old_ia_state_; |
| 898 scoped_ptr<WinAttributes> old_win_attributes_; | |
| 899 | 884 |
| 900 // Relationships between this node and other nodes. | 885 // Relationships between this node and other nodes. |
| 901 std::vector<BrowserAccessibilityRelation*> relations_; | 886 std::vector<BrowserAccessibilityRelation*> relations_; |
| 902 | 887 |
| 903 // IAccessibleText text of this node including | 888 // The text of this node including embedded hyperlink characters. |
| 904 // embedded hyperlink characters. | |
| 905 base::string16 old_hypertext_; | |
| 906 base::string16 hypertext_; | 889 base::string16 hypertext_; |
| 907 | 890 |
| 908 // Maps the |hypertext_| embedded character offset to an index in | 891 // Maps the |hypertext_| embedded character offset to an index in |
| 909 // |hyperlinks_|. | 892 // |hyperlinks_|. |
| 910 std::map<int32, int32> hyperlink_offset_to_index_; | 893 std::map<int32, int32> hyperlink_offset_to_index_; |
| 911 | 894 |
| 912 // Collection of non-static text child indicies, each of which corresponds to | 895 // Collection of non-static text child indicies, each of which corresponds to |
| 913 // a hyperlink. | 896 // a hyperlink. |
| 914 std::vector<int32> hyperlinks_; | 897 std::vector<int32> hyperlinks_; |
| 915 | 898 |
| 916 // The previous scroll position, so we can tell if this object scrolled. | 899 // The previous scroll position, so we can tell if this object scrolled. |
| 917 int previous_scroll_x_; | 900 int previous_scroll_x_; |
| 918 int previous_scroll_y_; | 901 int previous_scroll_y_; |
| 919 | 902 |
| 920 // The next unique id to use. | 903 // The next unique id to use. |
| 921 static LONG next_unique_id_win_; | 904 static LONG next_unique_id_win_; |
| 922 | 905 |
| 923 // Give BrowserAccessibility::Create access to our constructor. | 906 // Give BrowserAccessibility::Create access to our constructor. |
| 924 friend class BrowserAccessibility; | 907 friend class BrowserAccessibility; |
| 925 friend class BrowserAccessibilityRelation; | 908 friend class BrowserAccessibilityRelation; |
| 926 | 909 |
| 927 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); | 910 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
| 928 }; | 911 }; |
| 929 | 912 |
| 930 } // namespace content | 913 } // namespace content |
| 931 | 914 |
| 932 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 915 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
| OLD | NEW |