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

Unified Diff: ui/gfx/render_text_win.cc

Issue 7841056: fix know issues in RenderText (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix a capitalization in break_iterator.h Created 9 years, 3 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') | views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_win.cc
===================================================================
--- ui/gfx/render_text_win.cc (revision 102037)
+++ ui/gfx/render_text_win.cc (working copy)
@@ -237,10 +237,6 @@
return SelectionModel(cursor, caret, placement);
}
-size_t RenderTextWin::GetIndexOfPreviousGrapheme(size_t position) {
- return IndexOfAdjacentGrapheme(position, false);
-}
-
std::vector<Rect> RenderTextWin::GetSubstringBounds(size_t from, size_t to) {
ui::Range range(from, to);
DCHECK(ui::Range(0, text().length()).Contains(range));
@@ -295,6 +291,41 @@
return bounds;
}
+bool RenderTextWin::IsCursorablePosition(size_t position) {
+ if (position == 0 || position == text().length())
+ return true;
+
+ size_t run_index = GetRunContainingPosition(position);
+ if (run_index >= runs_.size())
+ return false;
+
+ internal::TextRun* run = runs_[run_index];
+ size_t start = run->range.start();
+ if (position == start)
+ return true;
+ return run->logical_clusters[position - start] !=
+ run->logical_clusters[position - start - 1];
+}
+
+size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) {
+ size_t run_index = GetRunContainingPosition(index);
+ internal::TextRun* run = run_index < runs_.size() ? runs_[run_index] : NULL;
+ long start = run ? run->range.start() : 0;
+ long length = run ? run->range.length() : text().length();
+ long ch = index - start;
+ WORD cluster = run ? run->logical_clusters[ch] : 0;
+
+ if (!next) {
+ do {
+ ch--;
+ } while (ch >= 0 && run && run->logical_clusters[ch] == cluster);
+ } else {
+ while (ch < length && run && run->logical_clusters[ch] == cluster)
+ ch++;
+ }
+ return std::max(static_cast<long>(std::min(ch, length) + start), 0L);
+}
+
void RenderTextWin::ItemizeLogicalText() {
text_is_dirty_ = false;
STLDeleteContainerPointers(runs_.begin(), runs_.end());
@@ -461,34 +492,16 @@
return run;
}
-size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) const {
- size_t run_index = GetRunContainingPosition(index);
- internal::TextRun* run = run_index < runs_.size() ? runs_[run_index] : NULL;
- long start = run ? run->range.start() : 0;
- long length = run ? run->range.length() : text().length();
- long ch = index - start;
- WORD cluster = run ? run->logical_clusters[ch] : 0;
- if (!next) {
- do {
- ch--;
- } while (ch >= 0 && run && run->logical_clusters[ch] == cluster);
- } else {
- while (ch < length && run && run->logical_clusters[ch] == cluster)
- ch++;
- }
- return std::max(static_cast<long>(std::min(ch, length) + start), 0L);
-}
-
SelectionModel RenderTextWin::FirstSelectionModelInsideRun(
- internal::TextRun* run) const {
+ internal::TextRun* run) {
size_t caret = run->range.start();
size_t cursor = IndexOfAdjacentGrapheme(caret, true);
return SelectionModel(cursor, caret, SelectionModel::TRAILING);
}
SelectionModel RenderTextWin::LastSelectionModelInsideRun(
- internal::TextRun* run) const {
+ internal::TextRun* run) {
size_t caret = IndexOfAdjacentGrapheme(run->range.end(), false);
return SelectionModel(caret, caret, SelectionModel::LEADING);
}
« no previous file with comments | « ui/gfx/render_text_win.h ('k') | views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698