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

Unified Diff: ui/gfx/render_text.cc

Issue 15746013: Fix cursor positioning regression from r201136. GetCursorPos() shouldn't assume (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 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.h ('k') | ui/gfx/render_text_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
===================================================================
--- ui/gfx/render_text.cc (revision 201137)
+++ ui/gfx/render_text.cc (working copy)
@@ -664,19 +664,17 @@
// overtype the next character.
LogicalCursorDirection caret_affinity =
insert_mode ? caret.caret_affinity() : CURSOR_FORWARD;
- int x = 0, width = 1, height = 0;
+ int x = 0, width = 1;
+ Size size = GetStringSize();
if (caret_pos == (caret_affinity == CURSOR_BACKWARD ? 0 : text().length())) {
// The caret is attached to the boundary. Always return a 1-dip width caret,
// since there is nothing to overtype.
- Size size = GetStringSize();
if ((GetTextDirection() == base::i18n::RIGHT_TO_LEFT) == (caret_pos == 0))
x = size.width();
- height = size.height();
} else {
size_t grapheme_start = (caret_affinity == CURSOR_FORWARD) ?
caret_pos : IndexOfAdjacentGrapheme(caret_pos, CURSOR_BACKWARD);
- ui::Range xspan;
- GetGlyphBounds(grapheme_start, &xspan, &height);
+ ui::Range xspan(GetGlyphBounds(grapheme_start));
if (insert_mode) {
x = (caret_affinity == CURSOR_BACKWARD) ? xspan.end() : xspan.start();
} else { // overtype mode
@@ -684,9 +682,7 @@
width = xspan.length();
}
}
- height = std::min(height, display_rect().height());
- int y = (display_rect().height() - height) / 2;
- return Rect(ToViewPoint(Point(x, y)), Size(width, height));
+ return Rect(ToViewPoint(Point(x, 0)), Size(width, size.height()));
}
const Rect& RenderText::GetUpdatedCursorBounds() {
« no previous file with comments | « ui/gfx/render_text.h ('k') | ui/gfx/render_text_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698