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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2406363003: Update appearance of invalid textfields in Harmony. (Closed)
Patch Set: Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
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..1c6f1401d8026b6db5e8e14cdfae4c88835ba6cd 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,20 @@ void Textfield::ApplyStyle(gfx::TextStyle style,
SchedulePaint();
}
+void Textfield::SetInvalid(bool invalid) {
+ if (invalid == invalid_)
+ return;
+ invalid_ = invalid;
+ UpdateBorder();
+
+ if (HasFocus() && use_focus_ring_) {
+ base::Optional<ui::NativeTheme::ColorId> color_id;
+ if (invalid_)
+ color_id = ui::NativeTheme::kColorId_AlertSeverityHigh;
+ FocusRing::SetColorId(this, color_id);
+ }
+}
+
void Textfield::ClearEditHistory() {
model_->ClearEditHistory();
}
@@ -996,8 +1011,11 @@ void Textfield::OnFocus() {
OnCaretBoundsChanged();
if (ShouldBlinkCursor())
StartBlinkingCursor();
- if (use_focus_ring_)
+ if (use_focus_ring_) {
FocusRing::Install(this);
+ if (invalid_)
+ FocusRing::SetColorId(this, ui::NativeTheme::kColorId_AlertSeverityHigh);
+ }
SchedulePaint();
View::OnFocus();
}
@@ -1815,6 +1833,13 @@ void Textfield::UpdateBackgroundColor() {
SchedulePaint();
}
+void Textfield::UpdateBorder() {
+ std::unique_ptr<views::FocusableBorder> border(new views::FocusableBorder());
sky 2016/10/11 23:59:18 MakeUnique
Evan Stade 2016/10/12 00:36:39 Done.
+ 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_)

Powered by Google App Engine
This is Rietveld 408576698