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

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

Issue 1377733002: Fixes for contenteditable caret and selection handling in Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed selection offsets when selection focus is not a direct sibling of the nearest non-text ancest… Created 5 years, 2 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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 in retrieving hyperlinks. Return -1 in case of failure. 769 // Functions that help when retrieving hyperlinks. Return -1 in case of
770 // failure.
770 // (Hyperlink is an IA2 misnomer. It refers to objects embedded within other 771 // (Hyperlink is an IA2 misnomer. It refers to objects embedded within other
771 // objects, such as a numbered list within a contenteditable div.) 772 // objects, such as a numbered list within a contenteditable div.)
772 int32 GetHyperlinkIndexFromChild(const BrowserAccessibilityWin& child) const; 773 int32 GetHyperlinkIndexFromChild(const BrowserAccessibilityWin& child) const;
773 int32 GetHypertextOffsetFromHyperlinkIndex(int32 hyperlink_index) const; 774 int32 GetHypertextOffsetFromHyperlinkIndex(int32 hyperlink_index) const;
774 int32 GetHypertextOffsetFromChild(const BrowserAccessibilityWin& child) const; 775 int32 GetHypertextOffsetFromChild(const BrowserAccessibilityWin& child) const;
775 int32 GetHypertextOffsetFromDescendant( 776 int32 GetHypertextOffsetFromDescendant(
776 const BrowserAccessibilityWin& descendant) const; 777 const BrowserAccessibilityWin& descendant) const;
777 778
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
778 // The following functions retrieve the endpoints of the current selection. 790 // The following functions retrieve the endpoints of the current selection.
779 // First they checks for a local selection found on the current control, e.g. 791 // First they check for a local selection found on the current control, e.g.
780 // when querying the selection on a textarea. 792 // when querying the selection on a textarea.
781 // If not found they retrieve the global selection found on the current frame. 793 // If not found they retrieve the global selection found on the current frame.
782 int GetSelectionAnchor() const; 794 int GetSelectionAnchor() const;
783 int GetSelectionFocus() const; 795 int GetSelectionFocus() const;
784 // Retrieves the selection offsets in the way required by the IA2 APIs. 796 // Retrieves the selection offsets in the way required by the IA2 APIs.
785 // (Selection_start is always <= selection_end and 797 // selection_start and selection_end are -1 when there is no selection active
786 // selection_end is one past the last character of the selection.) 798 // inside this object.
799 // The greatest of the two offsets is one past the last character of the
800 // selection.)
787 void GetSelectionOffsets(int* selection_start, int* selection_end) const; 801 void GetSelectionOffsets(int* selection_start, int* selection_end) const;
788 802
789 // Append the accessible name from this node and its children. 803 // Append the accessible name from this node and its children.
790 base::string16 GetNameRecursive() const; 804 base::string16 GetNameRecursive() const;
791 805
792 // Get the value text, which might come from the floating-point 806 // Get the value text, which might come from the floating-point
793 // value for some roles. 807 // value for some roles.
794 base::string16 GetValueText(); 808 base::string16 GetValueText();
795 809
796 // Get the text of this node for the purposes of IAccessibleText - it may 810 // Get the text of this node for the purposes of IAccessibleText - it may
797 // be the name, it may be the value, etc. depending on the role. 811 // be the name, it may be the value, etc. depending on the role.
798 base::string16 TextForIAccessibleText(); 812 base::string16 TextForIAccessibleText() const;
799 813
800 bool IsSameHypertextCharacter(size_t old_char_index, size_t new_char_index); 814 bool IsSameHypertextCharacter(size_t old_char_index, size_t new_char_index);
801 void ComputeHypertextRemovedAndInserted( 815 void ComputeHypertextRemovedAndInserted(
802 int* start, int* old_len, int* new_len); 816 int* start, int* old_len, int* new_len);
803 817
804 // If offset is a member of IA2TextSpecialOffsets this function updates the 818 // If offset is a member of IA2TextSpecialOffsets this function updates the
805 // value of offset and returns, otherwise offset remains unchanged. 819 // value of offset and returns, otherwise offset remains unchanged.
806 void HandleSpecialTextOffset(const base::string16& text, LONG* offset); 820 void HandleSpecialTextOffset(const base::string16& text, LONG* offset);
807 821
808 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType. 822 // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 int32 ia2_state; 863 int32 ia2_state;
850 864
851 // IAccessible2 attributes. 865 // IAccessible2 attributes.
852 std::vector<base::string16> ia2_attributes; 866 std::vector<base::string16> ia2_attributes;
853 867
854 // Hypertext. 868 // Hypertext.
855 base::string16 hypertext; 869 base::string16 hypertext;
856 870
857 // Maps the |hypertext_| embedded character offset to an index in 871 // Maps the |hypertext_| embedded character offset to an index in
858 // |hyperlinks_|. 872 // |hyperlinks_|.
859 // TODO(nektar): Replace map with vector of offsets.
860 std::map<int32, int32> hyperlink_offset_to_index; 873 std::map<int32, int32> hyperlink_offset_to_index;
861 874
862 // The id of a BrowserAccessibilityWin for each hyperlink. 875 // The id of a BrowserAccessibilityWin for each hyperlink.
863 // TODO(nektar): Replace object IDs with child indices. 876 // TODO(nektar): Replace object IDs with child indices.
864 std::vector<int32> hyperlinks; 877 std::vector<int32> hyperlinks;
865 }; 878 };
866 879
867 scoped_ptr<WinAttributes> win_attributes_; 880 scoped_ptr<WinAttributes> win_attributes_;
868 881
869 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or 882 // Only valid during the scope of a IA2_EVENT_TEXT_REMOVED or
(...skipping 13 matching lines...) Expand all
883 // Give BrowserAccessibility::Create access to our constructor. 896 // Give BrowserAccessibility::Create access to our constructor.
884 friend class BrowserAccessibility; 897 friend class BrowserAccessibility;
885 friend class BrowserAccessibilityRelation; 898 friend class BrowserAccessibilityRelation;
886 899
887 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); 900 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin);
888 }; 901 };
889 902
890 } // namespace content 903 } // namespace content
891 904
892 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ 905 #endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility_mac.mm ('k') | content/browser/accessibility/browser_accessibility_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698