Index: ui/gfx/render_text.cc |
=================================================================== |
--- ui/gfx/render_text.cc (revision 111944) |
+++ ui/gfx/render_text.cc (working copy) |
@@ -67,8 +67,9 @@ |
} else if (i->range.end() > new_range.end()) { |
i->range.set_start(new_range.end()); |
break; |
- } else |
+ } else { |
NOTREACHED(); |
+ } |
} |
// Add the new range in its sorted location. |
style_ranges->insert(i, style_range); |
@@ -186,8 +187,8 @@ |
MoveCursorTo(position); |
} |
-bool RenderText::MoveCursorTo(const SelectionModel& selection_model) { |
- SelectionModel sel(selection_model); |
+bool RenderText::MoveCursorTo(const SelectionModel& model) { |
+ SelectionModel sel(model); |
size_t text_length = text().length(); |
// Enforce valid selection model components. |
if (sel.selection_start() > text_length) |
@@ -205,10 +206,12 @@ |
sel.set_caret_placement(end.caret_placement()); |
} |
- if (!IsCursorablePosition(sel.selection_start()) || |
- !IsCursorablePosition(sel.selection_end()) || |
- !IsCursorablePosition(sel.caret_pos())) |
+ if (!IsCursorablePosition(sel.selection_start(), false) || |
+ !IsCursorablePosition(sel.selection_end(), false) || |
+ !IsCursorablePosition(sel.caret_pos(), |
+ (sel.caret_placement() == SelectionModel::TRAILING))) { |
xji
2011/11/29 21:15:48
I did not quite get the reason of introducing "boo
|
return false; |
+ } |
bool changed = !sel.Equals(selection_model_); |
SetSelectionModel(sel); |
@@ -227,7 +230,7 @@ |
size_t start = std::min(range.start(), text_length); |
size_t end = std::min(range.end(), text_length); |
- if (!IsCursorablePosition(start) || !IsCursorablePosition(end)) |
+ if (!IsCursorablePosition(start, false) || !IsCursorablePosition(end, false)) |
return false; |
size_t pos = end; |
@@ -410,7 +413,7 @@ |
// binary searching the cursor position. |
// TODO(oshima): use the center of character instead of edge. |
// Binary search may not work for language like Arabic. |
- while (std::abs(static_cast<long>(right_pos - left_pos)) > 1) { |
+ while (std::abs(right_pos - left_pos) > 1) { |
int pivot_pos = left_pos + (right_pos - left_pos) / 2; |
int pivot = font.GetStringWidth(text().substr(0, pivot_pos)); |
if (pivot < x) { |
@@ -479,8 +482,7 @@ |
BreakType break_type) { |
if (break_type == LINE_BREAK) |
return LeftEndSelectionModel(); |
- size_t pos = std::max(static_cast<long>(current.selection_end() - 1), |
- static_cast<long>(0)); |
+ size_t pos = std::max<int>(current.selection_end() - 1, 0); |
if (break_type == CHARACTER_BREAK) |
return SelectionModel(pos, pos, SelectionModel::LEADING); |
@@ -610,8 +612,7 @@ |
selection_model_.set_selection_start(selection_model.selection_start()); |
DCHECK_LE(selection_model.selection_end(), text().length()); |
selection_model_.set_selection_end(selection_model.selection_end()); |
- DCHECK_LT(selection_model.caret_pos(), |
- std::max(text().length(), static_cast<size_t>(1))); |
+ DCHECK_LT(selection_model.caret_pos(), std::max<size_t>(text().length(), 1)); |
selection_model_.set_caret_pos(selection_model.caret_pos()); |
selection_model_.set_caret_placement(selection_model.caret_placement()); |
@@ -625,7 +626,7 @@ |
SelectionModel::CaretPlacement placement = (caret_pos == cursor) ? |
SelectionModel::LEADING : SelectionModel::TRAILING; |
size_t selection_start = select ? GetSelectionStart() : cursor; |
- if (IsCursorablePosition(cursor)) { |
+ if (IsCursorablePosition(cursor, false)) { |
SelectionModel sel(selection_start, cursor, caret_pos, placement); |
SetSelectionModel(sel); |
} |