views: Fix calculating underline's position.

This commit is contained in:
Cheng Zhao 2014-08-18 15:36:29 +08:00
parent b8bfe8a9ad
commit fedb08899c

View file

@ -71,10 +71,10 @@ void SubmenuButton::OnPaint(gfx::Canvas* canvas) {
bool SubmenuButton::GetUnderlinePosition( bool SubmenuButton::GetUnderlinePosition(
const base::string16& text, int* start, int* end) { const base::string16& text, int* start, int* end) {
int pos, span; int pos, span;
gfx::RemoveAcceleratorChar(text, '&', &pos, &span); base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span);
if (pos > -1 && span != 0) { if (pos > -1 && span != 0) {
GetCharacterPosition(text, pos, start); GetCharacterPosition(trimmed, pos, start);
GetCharacterPosition(text, pos + span, end); GetCharacterPosition(trimmed, pos + span, end);
return true; return true;
} }
@ -83,10 +83,9 @@ bool SubmenuButton::GetUnderlinePosition(
void SubmenuButton::GetCharacterPosition( void SubmenuButton::GetCharacterPosition(
const base::string16& text, int index, int* pos) { const base::string16& text, int index, int* pos) {
int width, height; int height;
gfx::Canvas::SizeStringInt(text.substr(0, index), font_list(), &width, gfx::Canvas::SizeStringInt(text.substr(0, index), font_list(), pos, &height,
&height, 0, 0); 0, 0);
*pos = width;
} }
} // namespace atom } // namespace atom