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

Unified Diff: ui/gfx/render_text_win.cc

Issue 21140002: Consolidate RenderText adjacent word selection model code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup comments and add a unit test.~ Created 7 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/gfx/render_text_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_win.cc
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index 80fdffc04ac6e63999558b8260fdd8db9d5a7781..8ff322a85fc0f023d130cfc8e37f643e80330d78 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -317,54 +317,6 @@ SelectionModel RenderTextWin::AdjacentCharSelectionModel(
LastSelectionModelInsideRun(run);
}
-// TODO(msw): Implement word breaking for Windows.
-SelectionModel RenderTextWin::AdjacentWordSelectionModel(
- const SelectionModel& selection,
- VisualCursorDirection direction) {
- if (obscured())
- return EdgeSelectionModel(direction);
-
- base::i18n::BreakIterator iter(text(), base::i18n::BreakIterator::BREAK_WORD);
- bool success = iter.Init();
- DCHECK(success);
- if (!success)
- return selection;
-
- size_t pos;
- if (direction == CURSOR_RIGHT) {
- pos = std::min(selection.caret_pos() + 1, text().length());
- while (iter.Advance()) {
- pos = iter.pos();
- if (iter.IsWord() && pos > selection.caret_pos())
- break;
- }
- } else { // direction == CURSOR_LEFT
- // Notes: We always iterate words from the beginning.
- // This is probably fast enough for our usage, but we may
- // want to modify WordIterator so that it can start from the
- // middle of string and advance backwards.
- pos = std::max<int>(selection.caret_pos() - 1, 0);
- while (iter.Advance()) {
- if (iter.IsWord()) {
- size_t begin = iter.pos() - iter.GetString().length();
- if (begin == selection.caret_pos()) {
- // The cursor is at the beginning of a word.
- // Move to previous word.
- break;
- } else if (iter.pos() >= selection.caret_pos()) {
- // The cursor is in the middle or at the end of a word.
- // Move to the top of current word.
- pos = begin;
- break;
- } else {
- pos = iter.pos() - iter.GetString().length();
- }
- }
- }
- }
- return SelectionModel(pos, CURSOR_FORWARD);
-}
-
ui::Range RenderTextWin::GetGlyphBounds(size_t index) {
const size_t run_index =
GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD));
« no previous file with comments | « ui/gfx/render_text_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698