Index: ui/gfx/render_text.cc |
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc |
index 87e650b8cf3107637f407cad49850905f17fac68..add661d64c9d5edc34449ac3b0cf53bc7d102756 100644 |
--- a/ui/gfx/render_text.cc |
+++ b/ui/gfx/render_text.cc |
@@ -722,7 +722,9 @@ SizeF RenderText::GetStringSizeF() { |
} |
float RenderText::GetContentWidth() { |
- return GetStringSizeF().width() + (cursor_enabled_ ? 1 : 0); |
+ // The cursor is drawn one pixel beyond the int-enclosed text bounds. |
+ return cursor_enabled_ ? |
+ std::ceil(GetStringSizeF().width()) + 1 : GetStringSizeF().width(); |
} |
int RenderText::GetBaseline() { |
@@ -1071,7 +1073,7 @@ Vector2d RenderText::GetAlignmentOffset(size_t line_number) { |
HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); |
if (horizontal_alignment != ALIGN_LEFT) { |
#if defined(OS_WIN) |
- const int width = lines_[line_number].size.width() + |
+ const int width = std::ceil(lines_[line_number].size.width()) + |
(cursor_enabled_ ? 1 : 0); |
#else |
const int width = GetContentWidth(); |