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

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

Issue 660633002: Fixed IAccessibleText::TextAtOffset with IA2_TEXT_BOUNDARY_WORD to return text that spans from the … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved manual test changes to another branch. 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 #include "content/browser/accessibility/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_win.h"
6 6
7 #include <UIAutomationClient.h> 7 #include <UIAutomationClient.h>
8 #include <UIAutomationCoreApi.h> 8 #include <UIAutomationCoreApi.h>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 // No need to check |instance_active()| because this interface is 923 // No need to check |instance_active()| because this interface is
924 // global, and doesn't depend on any local state. 924 // global, and doesn't depend on any local state.
925 925
926 if (!app_name) 926 if (!app_name)
927 return E_INVALIDARG; 927 return E_INVALIDARG;
928 928
929 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out 929 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
930 // the part before the "/". 930 // the part before the "/".
931 std::vector<std::string> product_components; 931 std::vector<std::string> product_components;
932 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components); 932 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components);
933 DCHECK_EQ(2U, product_components.size()); 933 //DCHECK_EQ(2U, product_components.size());
dmazzoni 2015/02/20 18:16:21 if these checks are failing, please file a bug and
934 if (product_components.size() != 2) 934 if (product_components.size() != 2)
935 return E_FAIL; 935 return E_FAIL;
936 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); 936 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str());
937 DCHECK(*app_name); 937 //DCHECK(*app_name);
938 return *app_name ? S_OK : E_FAIL; 938 return *app_name ? S_OK : E_FAIL;
939 } 939 }
940 940
941 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { 941 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) {
942 // No need to check |instance_active()| because this interface is 942 // No need to check |instance_active()| because this interface is
943 // global, and doesn't depend on any local state. 943 // global, and doesn't depend on any local state.
944 944
945 if (!app_version) 945 if (!app_version)
946 return E_INVALIDARG; 946 return E_INVALIDARG;
947 947
948 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out 948 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out
949 // the part after the "/". 949 // the part after the "/".
950 std::vector<std::string> product_components; 950 std::vector<std::string> product_components;
951 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components); 951 base::SplitString(GetContentClient()->GetProduct(), '/', &product_components);
952 DCHECK_EQ(2U, product_components.size()); 952 //DCHECK_EQ(2U, product_components.size());
953 if (product_components.size() != 2) 953 if (product_components.size() != 2)
954 return E_FAIL; 954 return E_FAIL;
955 *app_version = 955 *app_version =
956 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); 956 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str());
957 DCHECK(*app_version); 957 //DCHECK(*app_version);
958 return *app_version ? S_OK : E_FAIL; 958 return *app_version ? S_OK : E_FAIL;
959 } 959 }
960 960
961 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { 961 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) {
962 // No need to check |instance_active()| because this interface is 962 // No need to check |instance_active()| because this interface is
963 // global, and doesn't depend on any local state. 963 // global, and doesn't depend on any local state.
964 964
965 if (!toolkit_name) 965 if (!toolkit_name)
966 return E_INVALIDARG; 966 return E_INVALIDARG;
967 967
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 enum IA2TextBoundaryType boundary_type, 2084 enum IA2TextBoundaryType boundary_type,
2085 LONG* start_offset, 2085 LONG* start_offset,
2086 LONG* end_offset, 2086 LONG* end_offset,
2087 BSTR* text) { 2087 BSTR* text) {
2088 if (!instance_active()) 2088 if (!instance_active())
2089 return E_FAIL; 2089 return E_FAIL;
2090 2090
2091 if (!start_offset || !end_offset || !text) 2091 if (!start_offset || !end_offset || !text)
2092 return E_INVALIDARG; 2092 return E_INVALIDARG;
2093 2093
2094 const base::string16& text_str = TextForIAccessibleText();
2095 HandleSpecialTextOffset(text_str, &offset);
2096 if (offset < 0)
2097 return E_INVALIDARG;
2098
2099 LONG text_len = text_str.length();
2100 if (offset > text_len)
2101 return E_INVALIDARG;
2102
2094 // The IAccessible2 spec says we don't have to implement the "sentence" 2103 // The IAccessible2 spec says we don't have to implement the "sentence"
2095 // boundary type, we can just let the screenreader handle it. 2104 // boundary type, we can just let the screenreader handle it.
2096 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { 2105 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) {
2097 *start_offset = 0; 2106 *start_offset = 0;
2098 *end_offset = 0; 2107 *end_offset = 0;
2099 *text = NULL; 2108 *text = NULL;
2100 return S_FALSE; 2109 return S_FALSE;
2101 } 2110 }
2102 2111
2103 const base::string16& text_str = TextForIAccessibleText(); 2112 // According to the IA2 Spec, only line boundaries should succeed when
2113 // the offset is one past the end of the text.
2114 if (offset == text_len && boundary_type != IA2_TEXT_BOUNDARY_LINE) {
2115 *start_offset = 0;
2116 *end_offset = 0;
2117 *text = nullptr;
2118 return S_FALSE;
2119 }
2104 2120
2105 *start_offset = FindBoundary( 2121 *start_offset = FindBoundary(
2106 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); 2122 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
2107 *end_offset = FindBoundary( 2123 *end_offset = FindBoundary(
2108 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); 2124 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
2109 return get_text(*start_offset, *end_offset, text); 2125 return get_text(*start_offset, *end_offset, text);
2110 } 2126 }
2111 2127
2112 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( 2128 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset(
2113 LONG offset, 2129 LONG offset,
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 } 3569 }
3554 return ui::CHAR_BOUNDARY; 3570 return ui::CHAR_BOUNDARY;
3555 } 3571 }
3556 3572
3557 LONG BrowserAccessibilityWin::FindBoundary( 3573 LONG BrowserAccessibilityWin::FindBoundary(
3558 const base::string16& text, 3574 const base::string16& text,
3559 IA2TextBoundaryType ia2_boundary, 3575 IA2TextBoundaryType ia2_boundary,
3560 LONG start_offset, 3576 LONG start_offset,
3561 ui::TextBoundaryDirection direction) { 3577 ui::TextBoundaryDirection direction) {
3562 HandleSpecialTextOffset(text, &start_offset); 3578 HandleSpecialTextOffset(text, &start_offset);
3579 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD && IsEditableText())
3580 return GetWordStartBoundary(static_cast<int>(start_offset), direction);
3581
3563 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); 3582 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
3564 const std::vector<int32>& line_breaks = GetIntListAttribute( 3583 const std::vector<int32>& line_breaks = GetIntListAttribute(
3565 ui::AX_ATTR_LINE_BREAKS); 3584 ui::AX_ATTR_LINE_BREAKS);
3566 return ui::FindAccessibleTextBoundary( 3585 return ui::FindAccessibleTextBoundary(
3567 text, line_breaks, boundary, start_offset, direction); 3586 text, line_breaks, boundary, start_offset, direction);
3568 } 3587 }
3569 3588
3570 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) { 3589 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) {
3571 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); 3590 return manager()->GetFromID(id)->ToBrowserAccessibilityWin();
3572 } 3591 }
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 ia2_role = ia_role; 4130 ia2_role = ia_role;
4112 4131
4113 win_attributes_->ia_role = ia_role; 4132 win_attributes_->ia_role = ia_role;
4114 win_attributes_->ia_state = ia_state; 4133 win_attributes_->ia_state = ia_state;
4115 win_attributes_->role_name = role_name; 4134 win_attributes_->role_name = role_name;
4116 win_attributes_->ia2_role = ia2_role; 4135 win_attributes_->ia2_role = ia2_role;
4117 win_attributes_->ia2_state = ia2_state; 4136 win_attributes_->ia2_state = ia2_state;
4118 } 4137 }
4119 4138
4120 } // namespace content 4139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698