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

Unified Diff: ui/gfx/render_text_linux.cc

Issue 7841056: fix know issues in RenderText (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: aupdate RenderTextWin. update test for Win platform. upload RenderTextTest that was missed 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
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 {

Powered by Google App Engine
This is Rietveld 408576698