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

Unified Diff: ui/accessibility/ax_text_utils.cc

Issue 2191833003: Use text affinity to return correct accessible line boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug in browser_accessibility_win.cc Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/accessibility/ax_text_utils.h ('k') | ui/accessibility/ax_text_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/ax_text_utils.cc
diff --git a/ui/accessibility/ax_text_utils.cc b/ui/accessibility/ax_text_utils.cc
index 698e53b961342c5a363443cdb83e89bcd6cfc52b..7c97a9892da831b625cde2c8283d95b65245f660 100644
--- a/ui/accessibility/ax_text_utils.cc
+++ b/ui/accessibility/ax_text_utils.cc
@@ -17,7 +17,8 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
const std::vector<int>& line_breaks,
TextBoundaryType boundary,
size_t start_offset,
- TextBoundaryDirection direction) {
+ TextBoundaryDirection direction,
+ AXTextAffinity affinity) {
size_t text_size = text.size();
DCHECK_LE(start_offset, text_size);
@@ -39,15 +40,23 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
if (direction == FORWARDS_DIRECTION) {
for (size_t j = 0; j < line_breaks.size(); ++j) {
size_t line_break = line_breaks[j] >= 0 ? line_breaks[j] : 0;
- if (line_break > start_offset)
+ if ((affinity == AX_TEXT_AFFINITY_DOWNSTREAM &&
+ line_break > start_offset) ||
+ (affinity == AX_TEXT_AFFINITY_UPSTREAM &&
+ line_break >= start_offset)) {
return line_break;
+ }
}
return text_size;
} else {
for (size_t j = line_breaks.size(); j != 0; --j) {
size_t line_break = line_breaks[j - 1] >= 0 ? line_breaks[j - 1] : 0;
- if (line_break <= start_offset)
+ if ((affinity == AX_TEXT_AFFINITY_DOWNSTREAM &&
+ line_break <= start_offset) ||
+ (affinity == AX_TEXT_AFFINITY_UPSTREAM &&
+ line_break < start_offset)) {
return line_break;
+ }
}
return 0;
}
« no previous file with comments | « ui/accessibility/ax_text_utils.h ('k') | ui/accessibility/ax_text_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698