| Index: ui/views/controls/textfield/textfield.cc
|
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
|
| index 107bea8e0249824f2ad2639d1bceadab55bd6502..4163c40a3742095f01fec3da7cf14d44db94aae4 100644
|
| --- a/ui/views/controls/textfield/textfield.cc
|
| +++ b/ui/views/controls/textfield/textfield.cc
|
| @@ -252,6 +252,7 @@ Textfield::Textfield()
|
| selection_text_color_(SK_ColorWHITE),
|
| selection_background_color_(SK_ColorBLUE),
|
| placeholder_text_color_(kDefaultPlaceholderTextColor),
|
| + invalid_(false),
|
| text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
|
| text_input_flags_(0),
|
| performing_user_action_(false),
|
| @@ -523,6 +524,19 @@ void Textfield::ApplyStyle(gfx::TextStyle style,
|
| SchedulePaint();
|
| }
|
|
|
| +void Textfield::SetInvalid(bool invalid) {
|
| + if (invalid == invalid_)
|
| + return;
|
| + invalid_ = invalid;
|
| + UpdateBorder();
|
| +
|
| + if (HasFocus() && use_focus_ring_) {
|
| + FocusRing::Install(this, invalid_
|
| + ? ui::NativeTheme::kColorId_AlertSeverityHigh
|
| + : ui::NativeTheme::kColorId_NumColors);
|
| + }
|
| +}
|
| +
|
| void Textfield::ClearEditHistory() {
|
| model_->ClearEditHistory();
|
| }
|
| @@ -996,8 +1010,11 @@ void Textfield::OnFocus() {
|
| OnCaretBoundsChanged();
|
| if (ShouldBlinkCursor())
|
| StartBlinkingCursor();
|
| - if (use_focus_ring_)
|
| - FocusRing::Install(this);
|
| + if (use_focus_ring_) {
|
| + FocusRing::Install(this, invalid_
|
| + ? ui::NativeTheme::kColorId_AlertSeverityHigh
|
| + : ui::NativeTheme::kColorId_NumColors);
|
| + }
|
| SchedulePaint();
|
| View::OnFocus();
|
| }
|
| @@ -1815,6 +1832,13 @@ void Textfield::UpdateBackgroundColor() {
|
| SchedulePaint();
|
| }
|
|
|
| +void Textfield::UpdateBorder() {
|
| + auto border = base::MakeUnique<views::FocusableBorder>();
|
| + if (invalid_)
|
| + border->SetColorId(ui::NativeTheme::kColorId_AlertSeverityHigh);
|
| + View::SetBorder(std::move(border));
|
| +}
|
| +
|
| void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
|
| if (text_changed) {
|
| if (controller_)
|
|
|