Index: ui/gfx/render_text_linux.cc |
=================================================================== |
--- ui/gfx/render_text_linux.cc (revision 100008) |
+++ ui/gfx/render_text_linux.cc (working copy) |
@@ -123,13 +123,19 @@ |
} |
SelectionModel RenderTextLinux::FindCursorPosition(const Point& point) { |
- // TODO(xji): when points outside of text, return HOME/END position. |
PangoLayout* layout = EnsureLayout(); |
if (text().empty()) |
return SelectionModel(0, 0, SelectionModel::LEADING); |
Point p(ToTextPoint(point)); |
+ |
+ // When the point is outside of text, return HOME/END position. |
+ if (p.x() < 0) |
+ return LeftEndSelectionModel(); |
+ else if (p.x() > GetStringWidth()) |
+ return RightEndSelectionModel(); |
+ |
int caret_pos, trailing; |
pango_layout_xy_to_index(layout, p.x() * PANGO_SCALE, p.y() * PANGO_SCALE, |
&caret_pos, &trailing); |
@@ -175,6 +181,12 @@ |
return bounds; |
} |
+size_t RenderTextLinux::GetIndexOfNextGrapheme(size_t position) { |
+ EnsureLayout(); |
+ size_t index = Utf16IndexToUtf8Index(position); |
+ return Utf16IndexOfAdjacentGrapheme(index, NEXT); |
+} |
+ |
SelectionModel RenderTextLinux::GetLeftSelectionModel( |
const SelectionModel& current, |
BreakType break_type) { |
@@ -244,10 +256,13 @@ |
return Utf16IndexOfAdjacentGrapheme(index, PREVIOUS); |
} |
-size_t RenderTextLinux::GetIndexOfNextGrapheme(size_t position) { |
+bool RenderTextLinux::IsCursorablePosition(size_t position) { |
+ if (position == 0 && text().empty()) |
+ return true; |
+ |
EnsureLayout(); |
- size_t index = Utf16IndexToUtf8Index(position); |
- return Utf16IndexOfAdjacentGrapheme(index, NEXT); |
+ return (position >= 0 && position < static_cast<size_t>(num_log_attrs_) && |
+ log_attrs_[position].is_cursor_position); |
} |
GSList* RenderTextLinux::GetRunContainingPosition(size_t position) const { |