diff options
author | nektar <nektar@chromium.org> | 2015-02-24 22:22:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-25 06:23:09 +0000 |
commit | 6baff46f520e31ff92669890207be5708064d16e (patch) | |
tree | 78dcaf61c4313e414358db637e229f6c4733cba7 /content/browser/accessibility/browser_accessibility_win.cc | |
parent | eaffcdbc813caebe3160789ed9ecc503b5276926 (diff) | |
download | chromium_src-6baff46f520e31ff92669890207be5708064d16e.zip chromium_src-6baff46f520e31ff92669890207be5708064d16e.tar.gz chromium_src-6baff46f520e31ff92669890207be5708064d16e.tar.bz2 |
Fixed IAccessibleText::TextAtOffset with IA2_TEXT_BOUNDARY_WORD to return text that spans from the start of one word to the start of the next.
BUG=347852
R=dmazzoni@chromium.org
Review URL: https://codereview.chromium.org/660633002
Cr-Commit-Position: refs/heads/master@{#317996}
Diffstat (limited to 'content/browser/accessibility/browser_accessibility_win.cc')
-rw-r--r-- | content/browser/accessibility/browser_accessibility_win.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index 3dc424a..228fb63 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -2091,6 +2091,15 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( if (!start_offset || !end_offset || !text) return E_INVALIDARG; + const base::string16& text_str = TextForIAccessibleText(); + HandleSpecialTextOffset(text_str, &offset); + if (offset < 0) + return E_INVALIDARG; + + LONG text_len = text_str.length(); + if (offset > text_len) + return E_INVALIDARG; + // The IAccessible2 spec says we don't have to implement the "sentence" // boundary type, we can just let the screenreader handle it. if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { @@ -2100,7 +2109,14 @@ STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( return S_FALSE; } - const base::string16& text_str = TextForIAccessibleText(); + // According to the IA2 Spec, only line boundaries should succeed when + // the offset is one past the end of the text. + if (offset == text_len && boundary_type != IA2_TEXT_BOUNDARY_LINE) { + *start_offset = 0; + *end_offset = 0; + *text = nullptr; + return S_FALSE; + } *start_offset = FindBoundary( text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); @@ -3560,6 +3576,11 @@ LONG BrowserAccessibilityWin::FindBoundary( LONG start_offset, ui::TextBoundaryDirection direction) { HandleSpecialTextOffset(text, &start_offset); + if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD && + GetRole() == ui::AX_ROLE_TEXT_FIELD) { + return GetWordStartBoundary(static_cast<int>(start_offset), direction); + } + ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); const std::vector<int32>& line_breaks = GetIntListAttribute( ui::AX_ATTR_LINE_BREAKS); |