Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: views/controls/button/native_button.cc

Issue 5154009: Cleanup AdjustStringForLocaleDirection() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: further fixes Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/button/native_button.h" 5 #include "views/controls/button/native_button.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "views/controls/native/native_view_host.h" 9 #include "views/controls/native/native_view_host.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Even though we create a flipped HWND for a native button when the locale 67 // Even though we create a flipped HWND for a native button when the locale
68 // is right-to-left, Windows does not render text for the button using a 68 // is right-to-left, Windows does not render text for the button using a
69 // right-to-left context (perhaps because the parent HWND is not flipped). 69 // right-to-left context (perhaps because the parent HWND is not flipped).
70 // The result is that RTL strings containing punctuation marks are not 70 // The result is that RTL strings containing punctuation marks are not
71 // displayed properly. For example, the string "...ABC" (where A, B and C are 71 // displayed properly. For example, the string "...ABC" (where A, B and C are
72 // Hebrew characters) is displayed as "ABC..." which is incorrect. 72 // Hebrew characters) is displayed as "ABC..." which is incorrect.
73 // 73 //
74 // In order to overcome this problem, we mark the localized Hebrew strings as 74 // In order to overcome this problem, we mark the localized Hebrew strings as
75 // RTL strings explicitly (using the appropriate Unicode formatting) so that 75 // RTL strings explicitly (using the appropriate Unicode formatting) so that
76 // Windows displays the text correctly regardless of the HWND hierarchy. 76 // Windows displays the text correctly regardless of the HWND hierarchy.
77 std::wstring localized_label; 77 base::i18n::AdjustStringForLocaleDirection(&label_);
78 if (base::i18n::AdjustStringForLocaleDirection(label_, &localized_label))
79 label_ = localized_label;
80 78
81 if (native_wrapper_) 79 if (native_wrapper_)
82 native_wrapper_->UpdateLabel(); 80 native_wrapper_->UpdateLabel();
83 81
84 // Update the accessible name whenever the label changes. 82 // Update the accessible name whenever the label changes.
85 SetAccessibleName(label); 83 SetAccessibleName(label);
86 PreferredSizeChanged(); 84 PreferredSizeChanged();
87 } 85 }
88 86
89 void NativeButton::SetIsDefault(bool is_default) { 87 void NativeButton::SetIsDefault(bool is_default) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 native_wrapper->UpdateEnabled(); 229 native_wrapper->UpdateEnabled();
232 return native_wrapper; 230 return native_wrapper;
233 } 231 }
234 232
235 void NativeButton::InitBorder() { 233 void NativeButton::InitBorder() {
236 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0, 234 set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0,
237 kButtonBorderHWidth)); 235 kButtonBorderHWidth));
238 } 236 }
239 237
240 } // namespace views 238 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698