| Index: ui/views/controls/textfield/native_textfield_views.cc
|
| diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
|
| index f82fba1484ee8bc87e9a9e1d7e258402fb8bbaf3..d804397a74a3046ff20933d32a90d91fa73ecfe7 100644
|
| --- a/ui/views/controls/textfield/native_textfield_views.cc
|
| +++ b/ui/views/controls/textfield/native_textfield_views.cc
|
| @@ -9,6 +9,7 @@
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| #include "base/debug/trace_event.h"
|
| +#include "base/i18n/case_conversion.h"
|
| #include "base/logging.h"
|
| #include "base/message_loop.h"
|
| #include "base/utf_string_conversions.h"
|
| @@ -36,6 +37,7 @@
|
| #include "ui/views/metrics.h"
|
| #include "ui/views/views_delegate.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "unicode/uchar.h"
|
|
|
| #if defined(OS_LINUX)
|
| #include "ui/gfx/gtk_util.h"
|
| @@ -80,9 +82,6 @@ NativeTextfieldViews::NativeTextfieldViews(Textfield* parent)
|
| TouchSelectionController::create(this))) {
|
| set_border(text_border_);
|
|
|
| - // Lowercase is not supported.
|
| - DCHECK_NE(parent->style(), Textfield::STYLE_LOWERCASE);
|
| -
|
| #if defined(OS_CHROMEOS)
|
| GetRenderText()->SetFontList(gfx::FontList(l10n_util::GetStringUTF8(
|
| IDS_UI_FONT_FAMILY_CROS)));
|
| @@ -201,6 +200,8 @@ int NativeTextfieldViews::OnPerformDrop(const DropTargetEvent& event) {
|
| GetRenderText()->FindCursorPosition(event.location());
|
| string16 text;
|
| event.data().GetString(&text);
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE)
|
| + text = base::i18n::ToLower(text);
|
|
|
| // We'll delete the current selection for a drag and drop within this view.
|
| bool move = initiating_drag_ && !event.IsControlDown() &&
|
| @@ -326,7 +327,10 @@ string16 NativeTextfieldViews::GetText() const {
|
| }
|
|
|
| void NativeTextfieldViews::UpdateText() {
|
| - model_->SetText(textfield_->text());
|
| + string16 text = textfield_->text();
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE)
|
| + text = base::i18n::ToLower(text);
|
| + model_->SetText(text);
|
| OnCaretBoundsChanged();
|
| SchedulePaint();
|
| textfield_->GetWidget()->NotifyAccessibilityEvent(
|
| @@ -336,7 +340,10 @@ void NativeTextfieldViews::UpdateText() {
|
| void NativeTextfieldViews::AppendText(const string16& text) {
|
| if (text.empty())
|
| return;
|
| - model_->Append(text);
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE)
|
| + model_->Append(base::i18n::ToLower(text));
|
| + else
|
| + model_->Append(text);
|
| OnCaretBoundsChanged();
|
| SchedulePaint();
|
| }
|
| @@ -673,10 +680,15 @@ void NativeTextfieldViews::InsertText(const string16& text) {
|
|
|
| OnBeforeUserAction();
|
| skip_input_method_cancel_composition_ = true;
|
| +
|
| + string16 new_text = text;
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE)
|
| + new_text = base::i18n::ToLower(new_text);
|
| +
|
| if (GetRenderText()->insert_mode())
|
| - model_->InsertText(text);
|
| + model_->InsertText(new_text);
|
| else
|
| - model_->ReplaceText(text);
|
| + model_->ReplaceText(new_text);
|
| skip_input_method_cancel_composition_ = false;
|
| UpdateAfterChange(true, true);
|
| OnAfterUserAction();
|
| @@ -688,6 +700,9 @@ void NativeTextfieldViews::InsertChar(char16 ch, int flags) {
|
| return;
|
| }
|
|
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE)
|
| + ch = u_tolower(ch);
|
| +
|
| OnBeforeUserAction();
|
| skip_input_method_cancel_composition_ = true;
|
| if (GetRenderText()->insert_mode())
|
| @@ -1046,6 +1061,12 @@ bool NativeTextfieldViews::Copy() {
|
| bool NativeTextfieldViews::Paste() {
|
| const bool success = model_->Paste();
|
|
|
| + if (textfield_->style() & Textfield::STYLE_LOWERCASE) {
|
| + string16 text = model_->GetText();
|
| + text = base::i18n::ToLower(text);
|
| + model_->SetText(text);
|
| + }
|
| +
|
| // Calls TextfieldController::ContentsChanged() explicitly if the paste action
|
| // did not change the content at all. See http://crbug.com/79002
|
| if (success && GetText() == textfield_->text()) {
|
|
|