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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 421053002: Enable RenderTextHarfBuzz by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 6 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.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_harfbuzz.cc
diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc
index a1aced102e8d93dface016e39cc224fa58edd455..b1387d8414012168698ae4783a2b1a6d832bdd6c 100644
--- a/ui/gfx/render_text_harfbuzz.cc
+++ b/ui/gfx/render_text_harfbuzz.cc
@@ -651,8 +651,6 @@ SelectionModel RenderTextHarfBuzz::AdjacentCharSelectionModel(
SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel(
const SelectionModel& selection,
VisualCursorDirection direction) {
- // TODO(ckocagil): This implementation currently matches RenderTextWin, but it
- // should match the native behavior on other platforms.
if (obscured())
return EdgeSelectionModel(direction);
@@ -662,6 +660,8 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel(
if (!success)
return selection;
+ // Match OS specific word break behavior.
+#if defined(OS_WIN)
size_t pos;
if (direction == CURSOR_RIGHT) {
pos = std::min(selection.caret_pos() + 1, text().length());
@@ -694,6 +694,20 @@ SelectionModel RenderTextHarfBuzz::AdjacentWordSelectionModel(
}
}
return SelectionModel(pos, CURSOR_FORWARD);
+#else
+ SelectionModel cur(selection);
+ for (;;) {
+ cur = AdjacentCharSelectionModel(cur, direction);
+ size_t run = GetRunContainingCaret(cur);
+ if (run == runs_.size())
+ break;
+ const bool is_forward = runs_[run]->is_rtl == (direction == CURSOR_LEFT);
+ size_t cursor = cur.caret_pos();
+ if (is_forward ? iter.IsEndOfWord(cursor) : iter.IsStartOfWord(cursor))
+ break;
+ }
+ return cur;
+#endif
}
std::vector<Rect> RenderTextHarfBuzz::GetSubstringBounds(const Range& range) {
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698