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

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: 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 points outside of text, return HOME/END position.
msw 2011/09/09 23:03:24 "When *the point is* outside" or "*For* points out
xji 2011/09/12 21:31:48 Done.
+ 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 < (size_t)num_log_attrs_ &&
msw 2011/09/09 23:03:24 Use c++ style static_cast.
xji 2011/09/12 21:31:48 Done.
+ log_attrs_[position].is_cursor_position);
}
GSList* RenderTextLinux::GetRunContainingPosition(size_t position) const {

Powered by Google App Engine
This is Rietveld 408576698