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

Unified Diff: ui/gfx/render_text.cc

Issue 7607018: Remove PREVIOUS_GRAPHEME_TRAILING. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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.h ('k') | views/controls/textfield/textfield_views_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
===================================================================
--- ui/gfx/render_text.cc (revision 96870)
+++ ui/gfx/render_text.cc (working copy)
@@ -87,13 +87,17 @@
}
SelectionModel::SelectionModel() {
- Init(0, 0, 0, PREVIOUS_GRAPHEME_TRAILING);
+ Init(0, 0, 0, LEADING);
}
SelectionModel::SelectionModel(size_t pos) {
- Init(pos, pos, pos, PREVIOUS_GRAPHEME_TRAILING);
+ Init(pos, pos, pos, LEADING);
}
+SelectionModel::SelectionModel(size_t start, size_t end) {
+ Init(start, end, end, LEADING);
+}
+
SelectionModel::SelectionModel(size_t end,
size_t pos,
CaretPlacement placement) {
@@ -266,6 +270,8 @@
SetSelectionModel(sel);
}
+// TODO(xji): it does not work for languages do not use space as word breaker,
+// such as Chinese. Should use BreakIterator.
void RenderText::SelectWord() {
size_t selection_start = GetSelectionStart();
size_t cursor_position = GetCursorPosition();
@@ -305,7 +311,8 @@
SelectionModel sel(selection_model());
sel.set_selection_start(selection_start);
sel.set_selection_end(cursor_position);
- sel.set_caret_placement(SelectionModel::PREVIOUS_GRAPHEME_TRAILING);
+ sel.set_caret_pos(GetIndexOfPreviousGrapheme(cursor_position));
+ sel.set_caret_placement(SelectionModel::TRAILING);
SetSelectionModel(sel);
}
@@ -542,7 +549,7 @@
return SelectionModel(pos, pos, SelectionModel::LEADING);
}
-size_t RenderText::GetIndexOfPreviousGrapheme(size_t position) const {
+size_t RenderText::GetIndexOfPreviousGrapheme(size_t position) {
// TODO(msw): Handle complex script.
return std::max(static_cast<int>(position - 1), static_cast<int>(0));
}
« no previous file with comments | « ui/gfx/render_text.h ('k') | views/controls/textfield/textfield_views_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698