| OLD | NEW |
| 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/textfield/native_textfield_win.h" | 5 #include "views/controls/textfield/native_textfield_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
| 10 #include "app/clipboard/scoped_clipboard_writer.h" | 10 #include "app/clipboard/scoped_clipboard_writer.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // not be displayed correctly in a textfield. For example, "Yahoo!" will be | 148 // not be displayed correctly in a textfield. For example, "Yahoo!" will be |
| 149 // displayed as "!Yahoo", and "Google (by default)" will be displayed as | 149 // displayed as "!Yahoo", and "Google (by default)" will be displayed as |
| 150 // "(Google (by default". | 150 // "(Google (by default". |
| 151 return base::i18n::StripWrappingBidiControlCharacters(WideToUTF16(str)); | 151 return base::i18n::StripWrappingBidiControlCharacters(WideToUTF16(str)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void NativeTextfieldWin::UpdateText() { | 154 void NativeTextfieldWin::UpdateText() { |
| 155 std::wstring text = textfield_->text(); | 155 std::wstring text = textfield_->text(); |
| 156 // Adjusting the string direction before setting the text in order to make | 156 // Adjusting the string direction before setting the text in order to make |
| 157 // sure both RTL and LTR strings are displayed properly. | 157 // sure both RTL and LTR strings are displayed properly. |
| 158 std::wstring text_to_set; | 158 base::i18n::AdjustStringForLocaleDirection(&text); |
| 159 if (!base::i18n::AdjustStringForLocaleDirection(text, &text_to_set)) | |
| 160 text_to_set = text; | |
| 161 if (textfield_->style() & Textfield::STYLE_LOWERCASE) | 159 if (textfield_->style() & Textfield::STYLE_LOWERCASE) |
| 162 text_to_set = l10n_util::ToLower(text_to_set); | 160 text = l10n_util::ToLower(text); |
| 163 SetWindowText(text_to_set.c_str()); | 161 SetWindowText(text.c_str()); |
| 164 UpdateAccessibleValue(text_to_set); | 162 UpdateAccessibleValue(text); |
| 165 } | 163 } |
| 166 | 164 |
| 167 void NativeTextfieldWin::AppendText(const string16& text) { | 165 void NativeTextfieldWin::AppendText(const string16& text) { |
| 168 int text_length = GetWindowTextLength(); | 166 int text_length = GetWindowTextLength(); |
| 169 ::SendMessage(m_hWnd, TBM_SETSEL, true, MAKELPARAM(text_length, text_length)); | 167 ::SendMessage(m_hWnd, TBM_SETSEL, true, MAKELPARAM(text_length, text_length)); |
| 170 ::SendMessage(m_hWnd, EM_REPLACESEL, false, | 168 ::SendMessage(m_hWnd, EM_REPLACESEL, false, |
| 171 reinterpret_cast<LPARAM>(text.c_str())); | 169 reinterpret_cast<LPARAM>(text.c_str())); |
| 172 } | 170 } |
| 173 | 171 |
| 174 string16 NativeTextfieldWin::GetSelectedText() const { | 172 string16 NativeTextfieldWin::GetSelectedText() const { |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 //////////////////////////////////////////////////////////////////////////////// | 1072 //////////////////////////////////////////////////////////////////////////////// |
| 1075 // NativeTextfieldWrapper, public: | 1073 // NativeTextfieldWrapper, public: |
| 1076 | 1074 |
| 1077 // static | 1075 // static |
| 1078 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1076 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| 1079 Textfield* field) { | 1077 Textfield* field) { |
| 1080 return new NativeTextfieldWin(field); | 1078 return new NativeTextfieldWin(field); |
| 1081 } | 1079 } |
| 1082 | 1080 |
| 1083 } // namespace views | 1081 } // namespace views |
| OLD | NEW |