]> khamidou — GitHub mirrors - electron.git/commitdiff
views: Fix calculating underline's position.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 18 Aug 2014 07:36:29 +0000 (15:36 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 18 Aug 2014 07:36:29 +0000 (15:36 +0800)
atom/browser/ui/views/submenu_button.cc

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