| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 // CComObjectRootEx methods. | 702 // CComObjectRootEx methods. |
| 703 // | 703 // |
| 704 | 704 |
| 705 // Called by BEGIN_COM_MAP() / END_COM_MAP(). | 705 // Called by BEGIN_COM_MAP() / END_COM_MAP(). |
| 706 static CONTENT_EXPORT HRESULT WINAPI | 706 static CONTENT_EXPORT HRESULT WINAPI |
| 707 InternalQueryInterface(void* this_ptr, | 707 InternalQueryInterface(void* this_ptr, |
| 708 const _ATL_INTMAP_ENTRY* entries, | 708 const _ATL_INTMAP_ENTRY* entries, |
| 709 REFIID iid, | 709 REFIID iid, |
| 710 void** object); | 710 void** object); |
| 711 | 711 |
| 712 // Computes and caches the IA2 text style attributes for the text and other |
| 713 // embedded child objects. |
| 714 CONTENT_EXPORT void ComputeStylesIfNeeded(); |
| 715 |
| 712 CONTENT_EXPORT base::string16 GetText() const override; | 716 CONTENT_EXPORT base::string16 GetText() const override; |
| 713 | 717 |
| 714 // Accessors. | 718 // Accessors. |
| 715 int32_t ia_role() const { return win_attributes_->ia_role; } | 719 int32_t ia_role() const { return win_attributes_->ia_role; } |
| 716 int32_t ia_state() const { return win_attributes_->ia_state; } | 720 int32_t ia_state() const { return win_attributes_->ia_state; } |
| 717 const base::string16& role_name() const { return win_attributes_->role_name; } | 721 const base::string16& role_name() const { return win_attributes_->role_name; } |
| 718 int32_t ia2_role() const { return win_attributes_->ia2_role; } | 722 int32_t ia2_role() const { return win_attributes_->ia2_role; } |
| 719 int32_t ia2_state() const { return win_attributes_->ia2_state; } | 723 int32_t ia2_state() const { return win_attributes_->ia2_state; } |
| 720 const std::vector<base::string16>& ia2_attributes() const { | 724 const std::vector<base::string16>& ia2_attributes() const { |
| 721 return win_attributes_->ia2_attributes; | 725 return win_attributes_->ia2_attributes; |
| 722 } | 726 } |
| 723 base::string16 name() const { return win_attributes_->name; } | 727 base::string16 name() const { return win_attributes_->name; } |
| 724 base::string16 description() const { return win_attributes_->description; } | 728 base::string16 description() const { return win_attributes_->description; } |
| 725 base::string16 value() const { return win_attributes_->value; } | 729 base::string16 value() const { return win_attributes_->value; } |
| 730 const std::map<int, std::vector<base::string16>>& offset_to_text_attributes() |
| 731 const { |
| 732 return win_attributes_->offset_to_text_attributes; |
| 733 } |
| 726 std::map<int32_t, int32_t>& hyperlink_offset_to_index() const { | 734 std::map<int32_t, int32_t>& hyperlink_offset_to_index() const { |
| 727 return win_attributes_->hyperlink_offset_to_index; | 735 return win_attributes_->hyperlink_offset_to_index; |
| 728 } | 736 } |
| 729 std::vector<int32_t>& hyperlinks() const { | 737 std::vector<int32_t>& hyperlinks() const { |
| 730 return win_attributes_->hyperlinks; | 738 return win_attributes_->hyperlinks; |
| 731 } | 739 } |
| 732 | 740 |
| 733 private: | 741 private: |
| 742 // Returns the IA2 text attributes for this object. |
| 743 std::vector<base::string16> ComputeTextAttributes() const; |
| 744 |
| 734 // Add one to the reference count and return the same object. Always | 745 // Add one to the reference count and return the same object. Always |
| 735 // use this method when returning a BrowserAccessibilityWin object as | 746 // use this method when returning a BrowserAccessibilityWin object as |
| 736 // an output parameter to a COM interface, never use it otherwise. | 747 // an output parameter to a COM interface, never use it otherwise. |
| 737 BrowserAccessibilityWin* NewReference(); | 748 BrowserAccessibilityWin* NewReference(); |
| 738 | 749 |
| 739 // Many MSAA methods take a var_id parameter indicating that the operation | 750 // Many MSAA methods take a var_id parameter indicating that the operation |
| 740 // should be performed on a particular child ID, rather than this object. | 751 // should be performed on a particular child ID, rather than this object. |
| 741 // This method tries to figure out the target object from |var_id| and | 752 // This method tries to figure out the target object from |var_id| and |
| 742 // returns a pointer to the target object if it exists, otherwise NULL. | 753 // returns a pointer to the target object if it exists, otherwise NULL. |
| 743 // Does not return a new reference. | 754 // Does not return a new reference. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 790 |
| 780 // | 791 // |
| 781 // Helper methods for IA2 hyperlinks. | 792 // Helper methods for IA2 hyperlinks. |
| 782 // | 793 // |
| 783 // Hyperlink is an IA2 misnomer. It refers to objects embedded within other | 794 // Hyperlink is an IA2 misnomer. It refers to objects embedded within other |
| 784 // objects, such as a numbered list within a contenteditable div. | 795 // objects, such as a numbered list within a contenteditable div. |
| 785 // Also, in IA2, text that includes embedded objects is called hypertext. | 796 // Also, in IA2, text that includes embedded objects is called hypertext. |
| 786 | 797 |
| 787 // Returns true if the current object is an IA2 hyperlink. | 798 // Returns true if the current object is an IA2 hyperlink. |
| 788 bool IsHyperlink() const; | 799 bool IsHyperlink() const; |
| 800 // Returns the hyperlink at the given text position, or nullptr if no |
| 801 // hyperlink can be found. |
| 802 BrowserAccessibilityWin* GetHyperlinkFromHypertextOffset(int offset) const; |
| 789 | 803 |
| 790 // Functions for retrieving offsets for hyperlinks and hypertext. | 804 // Functions for retrieving offsets for hyperlinks and hypertext. |
| 791 // Return -1 in case of failure. | 805 // Return -1 in case of failure. |
| 792 int32_t GetHyperlinkIndexFromChild( | 806 int32_t GetHyperlinkIndexFromChild( |
| 793 const BrowserAccessibilityWin& child) const; | 807 const BrowserAccessibilityWin& child) const; |
| 794 int32_t GetHypertextOffsetFromHyperlinkIndex(int32_t hyperlink_index) const; | 808 int32_t GetHypertextOffsetFromHyperlinkIndex(int32_t hyperlink_index) const; |
| 795 int32_t GetHypertextOffsetFromChild( | 809 int32_t GetHypertextOffsetFromChild( |
| 796 const BrowserAccessibilityWin& child) const; | 810 const BrowserAccessibilityWin& child) const; |
| 797 int32_t GetHypertextOffsetFromDescendant( | 811 int32_t GetHypertextOffsetFromDescendant( |
| 798 const BrowserAccessibilityWin& descendant) const; | 812 const BrowserAccessibilityWin& descendant) const; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); | 854 ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); |
| 841 | 855 |
| 842 // Search forwards (direction == 1) or backwards (direction == -1) | 856 // Search forwards (direction == 1) or backwards (direction == -1) |
| 843 // from the given offset until the given boundary is found, and | 857 // from the given offset until the given boundary is found, and |
| 844 // return the offset of that boundary. | 858 // return the offset of that boundary. |
| 845 LONG FindBoundary(const base::string16& text, | 859 LONG FindBoundary(const base::string16& text, |
| 846 IA2TextBoundaryType ia2_boundary, | 860 IA2TextBoundaryType ia2_boundary, |
| 847 LONG start_offset, | 861 LONG start_offset, |
| 848 ui::TextBoundaryDirection direction); | 862 ui::TextBoundaryDirection direction); |
| 849 | 863 |
| 850 // Return a pointer to the object corresponding to the given id, | 864 // Searches forward from the given offset until the start of the next style |
| 851 // does not make a new reference. | 865 // is found, or searches backward from the given offset until the start of the |
| 852 BrowserAccessibilityWin* GetFromID(int32_t id); | 866 // current style is found. |
| 867 LONG FindStartOfStyle(LONG start_offset, |
| 868 ui::TextBoundaryDirection direction) const; |
| 869 |
| 870 // ID refers to the node ID in the current tree, not the globally unique ID. |
| 871 // TODO(nektar): Could we use globally unique IDs everywhere? |
| 872 // TODO(nektar): Rename this function to GetFromNodeID. |
| 873 BrowserAccessibilityWin* GetFromID(int32_t id) const; |
| 853 | 874 |
| 854 // Returns true if this is a list box option with a parent of type list box, | 875 // Returns true if this is a list box option with a parent of type list box, |
| 855 // or a menu list option with a parent of type menu list popup. | 876 // or a menu list option with a parent of type menu list popup. |
| 856 bool IsListBoxOptionOrMenuListOption(); | 877 bool IsListBoxOptionOrMenuListOption(); |
| 857 | 878 |
| 858 // Updates object attributes of IA2 with html attributes. | |
| 859 void UpdateRequiredAttributes(); | |
| 860 | |
| 861 // Given an int list attribute containing the ids of related elements, | 879 // Given an int list attribute containing the ids of related elements, |
| 862 // add a new IAccessibleRelation for this object with the given type name. | 880 // add a new IAccessibleRelation for this object with the given type name. |
| 863 void AddRelations(ui::AXIntListAttribute src_attr, | 881 void AddRelations(ui::AXIntListAttribute src_attr, |
| 864 const base::string16& iaccessiblerelation_type); | 882 const base::string16& iaccessiblerelation_type); |
| 865 | 883 |
| 884 // Updates object attributes of IA2 with html attributes. |
| 885 void UpdateRequiredAttributes(); |
| 886 |
| 887 // Updates the IA2 text style attributes. |
| 888 void UpdateTextAttributes(); |
| 889 |
| 866 struct WinAttributes { | 890 struct WinAttributes { |
| 867 WinAttributes(); | 891 WinAttributes(); |
| 868 ~WinAttributes(); | 892 ~WinAttributes(); |
| 869 | 893 |
| 870 // IAccessible role and state. | 894 // IAccessible role and state. |
| 871 int32_t ia_role; | 895 int32_t ia_role; |
| 872 int32_t ia_state; | 896 int32_t ia_state; |
| 873 base::string16 role_name; | 897 base::string16 role_name; |
| 874 | 898 |
| 875 // IAccessible name, description, help, value. | 899 // IAccessible name, description, help, value. |
| 876 base::string16 name; | 900 base::string16 name; |
| 877 base::string16 description; | 901 base::string16 description; |
| 878 base::string16 value; | 902 base::string16 value; |
| 879 | 903 |
| 880 // IAccessible2 role and state. | 904 // IAccessible2 role and state. |
| 881 int32_t ia2_role; | 905 int32_t ia2_role; |
| 882 int32_t ia2_state; | 906 int32_t ia2_state; |
| 883 | 907 |
| 884 // IAccessible2 attributes. | 908 // IAccessible2 attributes. |
| 885 std::vector<base::string16> ia2_attributes; | 909 std::vector<base::string16> ia2_attributes; |
| 886 | 910 |
| 887 // Hypertext. | 911 // Hypertext. |
| 888 base::string16 hypertext; | 912 base::string16 hypertext; |
| 889 | 913 |
| 914 // Maps each style span to its start offset in hypertext. |
| 915 std::map<int, std::vector<base::string16>> offset_to_text_attributes; |
| 916 |
| 890 // Maps the |hypertext_| embedded character offset to an index in | 917 // Maps the |hypertext_| embedded character offset to an index in |
| 891 // |hyperlinks_|. | 918 // |hyperlinks_|. |
| 892 std::map<int32_t, int32_t> hyperlink_offset_to_index; | 919 std::map<int32_t, int32_t> hyperlink_offset_to_index; |
| 893 | 920 |
| 894 // The id of a BrowserAccessibilityWin for each hyperlink. | 921 // The id of a BrowserAccessibilityWin for each hyperlink. |
| 895 // TODO(nektar): Replace object IDs with child indices. | 922 // TODO(nektar): Replace object IDs with child indices. |
| 896 std::vector<int32_t> hyperlinks; | 923 std::vector<int32_t> hyperlinks; |
| 897 }; | 924 }; |
| 898 | 925 |
| 899 scoped_ptr<WinAttributes> win_attributes_; | 926 scoped_ptr<WinAttributes> win_attributes_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 918 | 945 |
| 919 CONTENT_EXPORT BrowserAccessibilityWin* | 946 CONTENT_EXPORT BrowserAccessibilityWin* |
| 920 ToBrowserAccessibilityWin(BrowserAccessibility* obj); | 947 ToBrowserAccessibilityWin(BrowserAccessibility* obj); |
| 921 | 948 |
| 922 CONTENT_EXPORT const BrowserAccessibilityWin* | 949 CONTENT_EXPORT const BrowserAccessibilityWin* |
| 923 ToBrowserAccessibilityWin(const BrowserAccessibility* obj); | 950 ToBrowserAccessibilityWin(const BrowserAccessibility* obj); |
| 924 | 951 |
| 925 } // namespace content | 952 } // namespace content |
| 926 | 953 |
| 927 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 954 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
| OLD | NEW |