diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 21:16:24 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 21:16:24 +0000 |
commit | 0d54c2a4ed1c2ec19fdb0c98adb061cfeb618899 (patch) | |
tree | 3a2880e6a6e143fe185ae56faee8e5a4063f8de4 /views/controls/menu | |
parent | fe4866960e8bc4e1afa43c8ad1a9f62716e6a890 (diff) | |
download | chromium_src-0d54c2a4ed1c2ec19fdb0c98adb061cfeb618899.zip chromium_src-0d54c2a4ed1c2ec19fdb0c98adb061cfeb618899.tar.gz chromium_src-0d54c2a4ed1c2ec19fdb0c98adb061cfeb618899.tar.bz2 |
views: Change MenuItemView::GetTitle() to string16.
BUG=68267
R=sky@chromium.org
Review URL: http://codereview.chromium.org/8137026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104172 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu')
-rw-r--r-- | views/controls/menu/menu_controller.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.cc | 11 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view.h | 9 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_linux.cc | 2 | ||||
-rw-r--r-- | views/controls/menu/menu_item_view_win.cc | 4 | ||||
-rw-r--r-- | views/controls/menu/menu_model_adapter_unittest.cc | 1 |
6 files changed, 12 insertions, 17 deletions
diff --git a/views/controls/menu/menu_controller.cc b/views/controls/menu/menu_controller.cc index a36184a..c215b70 100644 --- a/views/controls/menu/menu_controller.cc +++ b/views/controls/menu/menu_controller.cc @@ -68,7 +68,7 @@ bool TitleMatchesMnemonic(MenuItemView* menu, char16 key) { if (menu->GetMnemonic()) return false; - string16 lower_title = base::i18n::ToLower(WideToUTF16(menu->GetTitle())); + string16 lower_title = base::i18n::ToLower(menu->title()); return !lower_title.empty() && lower_title[0] == key; } diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc index ee7b2c9..baa1ff1 100644 --- a/views/controls/menu/menu_item_view.cc +++ b/views/controls/menu/menu_item_view.cc @@ -348,13 +348,12 @@ char16 MenuItemView::GetMnemonic() { if (!GetRootMenuItem()->has_mnemonics_) return 0; - string16 title = WideToUTF16(GetTitle()); size_t index = 0; do { - index = title.find('&', index); + index = title_.find('&', index); if (index != string16::npos) { - if (index + 1 != title.size() && title[index + 1] != '&') { - char16 char_array[] = { title[index + 1], 0 }; + if (index + 1 != title_.size() && title_[index + 1] != '&') { + char16 char_array[] = { title_[index + 1], 0 }; // TODO(jshin): What about Turkish locale? See http://crbug.com/81719. // If the mnemonic is capital I and the UI language is Turkish, // lowercasing it results in 'small dotless i', which is different @@ -411,7 +410,7 @@ void MenuItemView::Layout() { if (!has_children()) return; - if (child_count() == 1 && GetTitle().size() == 0) { + if (child_count() == 1 && title_.empty()) { // We only have one child and no title so let the view take over all the // space. View* child = child_at(0); @@ -667,7 +666,7 @@ gfx::Size MenuItemView::GetChildPreferredSize() { if (!has_children()) return gfx::Size(); - if (GetTitle().size() == 0 && child_count() == 1) { + if (title_.empty() && child_count() == 1) { View* child = child_at(0); return child->GetPreferredSize(); } diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h index beb487b..bb8add9 100644 --- a/views/controls/menu/menu_item_view.h +++ b/views/controls/menu/menu_item_view.h @@ -14,8 +14,6 @@ #endif #include "base/logging.h" -// TODO(avi): remove when not needed -#include "base/utf_string_conversions.h" #include "third_party/skia/include/core/SkBitmap.h" #include "views/view.h" @@ -224,12 +222,9 @@ class VIEWS_EXPORT MenuItemView : public View { // Returns the parent menu item. MenuItemView* GetParentMenuItem() const { return parent_menu_item_; } - // Sets the title + // Sets/Gets the title. void SetTitle(const std::wstring& title); - - // Returns the title. - // TODO(avi): switch back to returning a const reference. - const std::wstring GetTitle() const { return UTF16ToWideHack(title_); } + const string16& title() const { return title_; } // Returns the type of this menu. const Type& GetType() { return type_; } diff --git a/views/controls/menu/menu_item_view_linux.cc b/views/controls/menu/menu_item_view_linux.cc index 2b04004..30fddec 100644 --- a/views/controls/menu/menu_item_view_linux.cc +++ b/views/controls/menu/menu_item_view_linux.cc @@ -107,7 +107,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { (available_height - font.GetHeight()) / 2, width, font.GetHeight()); text_bounds.set_x(GetMirroredXForRect(text_bounds)); - canvas->DrawStringInt(WideToUTF16Hack(GetTitle()), font, fg_color, + canvas->DrawStringInt(title(), font, fg_color, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), GetRootMenuItem()->GetDrawStringFlags()); diff --git a/views/controls/menu/menu_item_view_win.cc b/views/controls/menu/menu_item_view_win.cc index 9e04cdc..1755617 100644 --- a/views/controls/menu/menu_item_view_win.cc +++ b/views/controls/menu/menu_item_view_win.cc @@ -109,11 +109,11 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { // halo. Instead, just draw black on white, which will look good in most // cases. canvas->AsCanvasSkia()->DrawStringWithHalo( - GetTitle(), font, 0x00000000, 0xFFFFFFFF, text_bounds.x(), + title(), font, 0x00000000, 0xFFFFFFFF, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), GetRootMenuItem()->GetDrawStringFlags()); } else { - canvas->DrawStringInt(GetTitle(), font, fg_color, + canvas->DrawStringInt(title(), font, fg_color, text_bounds.x(), text_bounds.y(), text_bounds.width(), text_bounds.height(), GetRootMenuItem()->GetDrawStringFlags()); diff --git a/views/controls/menu/menu_model_adapter_unittest.cc b/views/controls/menu/menu_model_adapter_unittest.cc index 471b81a..af54852 100644 --- a/views/controls/menu/menu_model_adapter_unittest.cc +++ b/views/controls/menu/menu_model_adapter_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/menu_model.h" #include "ui/base/models/menu_model_delegate.h" |