diff options
Diffstat (limited to 'views/controls')
-rw-r--r-- | views/controls/combobox/native_combobox_views.cc | 3 | ||||
-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 |
7 files changed, 14 insertions, 18 deletions
diff --git a/views/controls/combobox/native_combobox_views.cc b/views/controls/combobox/native_combobox_views.cc index ab676d1..e1f436d 100644 --- a/views/controls/combobox/native_combobox_views.cc +++ b/views/controls/combobox/native_combobox_views.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "base/command_line.h" +#include "base/utf_string_conversions.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/models/combobox_model.h" #include "ui/base/resource/resource_bundle.h" @@ -176,7 +177,7 @@ void NativeComboboxViews::UpdateFromModel() { // text is displayed correctly in right-to-left UIs. base::i18n::AdjustStringForLocaleDirection(&text); - menu->AppendMenuItem(i + kFirstMenuItemId, UTF16ToWide(text), + menu->AppendMenuItem(i + kFirstMenuItemId, UTF16ToWideHack(text), MenuItemView::NORMAL); max_width = std::max(max_width, font.GetStringWidth(text)); } 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" |