Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.h

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

Powered by Google App Engine
This is Rietveld 408576698