summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 07:27:42 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 07:27:42 +0000
commitc32d31eab915dcff1f128bf744ced2ad8fa221ef (patch)
tree69a8fbf3b9360c6401bb4658893cafc4b2f209ed /views
parent6ee50a8d443f48e70921a8eed76f26a6e9844228 (diff)
downloadchromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.zip
chromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.tar.gz
chromium_src-c32d31eab915dcff1f128bf744ced2ad8fa221ef.tar.bz2
Cleanup AdjustStringForLocaleDirection() to modify input parameter in place.
As described in the bug, the current behavior is confusing and bug-prone. BUG=47194 TEST=Check that there are no visible regressions in RTL and LTR language UIs on Linux & Windows. Review URL: http://codereview.chromium.org/5154009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67237 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/native_button.cc4
-rw-r--r--views/controls/combobox/native_combobox_win.cc6
-rw-r--r--views/controls/textfield/native_textfield_win.cc10
-rw-r--r--views/controls/tree/tree_view.cc4
-rw-r--r--views/widget/tooltip_manager_win.cc3
-rw-r--r--views/window/window_gtk.cc4
-rw-r--r--views/window/window_win.cc4
7 files changed, 11 insertions, 24 deletions
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index 89dae9c..e1693d3 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -74,9 +74,7 @@ void NativeButton::SetLabel(const std::wstring& label) {
// In order to overcome this problem, we mark the localized Hebrew strings as
// RTL strings explicitly (using the appropriate Unicode formatting) so that
// Windows displays the text correctly regardless of the HWND hierarchy.
- std::wstring localized_label;
- if (base::i18n::AdjustStringForLocaleDirection(label_, &localized_label))
- label_ = localized_label;
+ base::i18n::AdjustStringForLocaleDirection(&label_);
if (native_wrapper_)
native_wrapper_->UpdateLabel();
diff --git a/views/controls/combobox/native_combobox_win.cc b/views/controls/combobox/native_combobox_win.cc
index 720e51f..2134a75e 100644
--- a/views/controls/combobox/native_combobox_win.cc
+++ b/views/controls/combobox/native_combobox_win.cc
@@ -47,14 +47,12 @@ void NativeComboboxWin::UpdateFromModel() {
int max_width = 0;
int num_items = combobox_->model()->GetItemCount();
for (int i = 0; i < num_items; ++i) {
- const std::wstring& text = UTF16ToWide(combobox_->model()->GetItemAt(i));
+ std::wstring text = UTF16ToWide(combobox_->model()->GetItemAt(i));
// Inserting the Unicode formatting characters if necessary so that the
// text is displayed correctly in right-to-left UIs.
- std::wstring localized_text;
+ base::i18n::AdjustStringForLocaleDirection(&text);
const wchar_t* text_ptr = text.c_str();
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
- text_ptr = localized_text.c_str();
SendMessage(native_view(), CB_ADDSTRING, 0,
reinterpret_cast<LPARAM>(text_ptr));
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 2109cb9..3f4b0eb 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -155,13 +155,11 @@ void NativeTextfieldWin::UpdateText() {
std::wstring text = textfield_->text();
// Adjusting the string direction before setting the text in order to make
// sure both RTL and LTR strings are displayed properly.
- std::wstring text_to_set;
- if (!base::i18n::AdjustStringForLocaleDirection(text, &text_to_set))
- text_to_set = text;
+ base::i18n::AdjustStringForLocaleDirection(&text);
if (textfield_->style() & Textfield::STYLE_LOWERCASE)
- text_to_set = l10n_util::ToLower(text_to_set);
- SetWindowText(text_to_set.c_str());
- UpdateAccessibleValue(text_to_set);
+ text = l10n_util::ToLower(text);
+ SetWindowText(text.c_str());
+ UpdateAccessibleValue(text);
}
void NativeTextfieldWin::AppendText(const string16& text) {
diff --git a/views/controls/tree/tree_view.cc b/views/controls/tree/tree_view.cc
index 6b02a62..bfdd454 100644
--- a/views/controls/tree/tree_view.cc
+++ b/views/controls/tree/tree_view.cc
@@ -370,9 +370,7 @@ LRESULT TreeView::OnNotify(int w_param, LPNMHDR l_param) {
DCHECK(info->item.cchTextMax);
// Adjust the string direction if such adjustment is required.
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text))
- text.swap(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&text);
wcsncpy_s(info->item.pszText, info->item.cchTextMax, text.c_str(),
_TRUNCATE);
diff --git a/views/widget/tooltip_manager_win.cc b/views/widget/tooltip_manager_win.cc
index c7ad4ff..8e51e64 100644
--- a/views/widget/tooltip_manager_win.cc
+++ b/views/widget/tooltip_manager_win.cc
@@ -173,8 +173,7 @@ LRESULT TooltipManagerWin::OnNotify(int w_param,
TrimTooltipToFit(&clipped_text_, &tooltip_width_, &line_count_,
screen_loc.x(), screen_loc.y());
// Adjust the clipped tooltip text for locale direction.
- base::i18n::AdjustStringForLocaleDirection(clipped_text_,
- &clipped_text_);
+ base::i18n::AdjustStringForLocaleDirection(&clipped_text_);
tooltip_info->lpszText = const_cast<WCHAR*>(clipped_text_.c_str());
} else {
tooltip_text_.clear();
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index d59d7a5..4f8a251 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -207,9 +207,7 @@ void WindowGtk::UpdateWindowTitle() {
// Update the native frame's text. We do this regardless of whether or not
// the native frame is being used, since this also updates the taskbar, etc.
std::wstring window_title = window_delegate_->GetWindowTitle();
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(window_title, &localized_text))
- window_title.assign(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&window_title);
gtk_window_set_title(GetNativeWindow(), WideToUTF8(window_title).c_str());
}
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 03bf75f..e940fdd 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -417,9 +417,7 @@ void WindowWin::UpdateWindowTitle() {
window_title = window_delegate_->GetAccessibleWindowTitle();
else
window_title = window_delegate_->GetWindowTitle();
- std::wstring localized_text;
- if (base::i18n::AdjustStringForLocaleDirection(window_title, &localized_text))
- window_title.assign(localized_text);
+ base::i18n::AdjustStringForLocaleDirection(&window_title);
SetWindowText(GetNativeView(), window_title.c_str());
// Also update the accessibility name.