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

Unified Diff: ui/accessibility/ax_text_utils.cc

Issue 1780473002: Workaround for navigating by word in the omnibox on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed base from deps and fixed build.gn file (hopefully). Created 4 years, 9 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/accessibility.gyp ('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 1e68559027ec8faf455b80440fda9e60b46b0bd5..698e53b961342c5a363443cdb83e89bcd6cfc52b 100644
--- a/ui/accessibility/ax_text_utils.cc
+++ b/ui/accessibility/ax_text_utils.cc
@@ -4,6 +4,7 @@
#include "ui/accessibility/ax_text_utils.h"
+#include "base/i18n/break_iterator.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
@@ -25,7 +26,16 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
return start_offset + 1;
else
return start_offset;
- } else if (boundary == LINE_BOUNDARY) {
+ }
+
+ base::i18n::BreakIterator word_iter(text,
+ base::i18n::BreakIterator::BREAK_WORD);
+ if (boundary == WORD_BOUNDARY) {
+ if (!word_iter.Init())
+ return start_offset;
+ }
+
+ if (boundary == LINE_BOUNDARY) {
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;
@@ -62,8 +72,12 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
NOTREACHED(); // These are handled above.
break;
case WORD_BOUNDARY:
- if (base::IsUnicodeWhitespace(text[pos]))
- return result;
+ if (word_iter.IsStartOfWord(result)) {
+ // If we are searching forward and we are still at the start offset,
+ // we need to find the next word.
+ if (direction == BACKWARDS_DIRECTION || result != start_offset)
+ return result;
+ }
break;
case PARAGRAPH_BOUNDARY:
if (text[pos] == '\n')
@@ -89,4 +103,4 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
}
}
-} // Namespace ui
+} // namespace ui
« no previous file with comments | « ui/accessibility/accessibility.gyp ('k') | ui/accessibility/ax_text_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698