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

Unified Diff: ui/views/controls/focus_ring.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/focus_ring.cc
diff --git a/ui/views/controls/focus_ring.cc b/ui/views/controls/focus_ring.cc
index 8e1702b37884dbb2114351b7c52591ba9da9fde7..59e97f7838a31ae786f179693cd74af000afa1ac 100644
--- a/ui/views/controls/focus_ring.cc
+++ b/ui/views/controls/focus_ring.cc
@@ -21,6 +21,15 @@ constexpr float kFocusHaloThicknessDp = 2.f;
constexpr float kFocusHaloCornerRadiusDp =
FocusableBorder::kCornerRadiusDp + kFocusHaloThicknessDp / 2.f;
+FocusRing* GetFocusRing(views::View* parent) {
+ for (int i = 0; i < parent->child_count(); ++i) {
+ if (parent->child_at(i)->GetClassName() == FocusRing::kViewClassName)
+ return static_cast<FocusRing*>(parent->child_at(i));
+ }
+ NOTREACHED();
+ return nullptr;
+}
+
} // namespace
const char FocusRing::kViewClassName[] = "FocusRing";
@@ -35,13 +44,16 @@ void FocusRing::Install(views::View* parent) {
// static
void FocusRing::Uninstall(views::View* parent) {
- for (int i = 0; i < parent->child_count(); ++i) {
- if (parent->child_at(i)->GetClassName() == kViewClassName) {
- delete parent->child_at(i);
- return;
- }
- }
- NOTREACHED();
+ delete GetFocusRing(parent);
+}
+
+// static
+void FocusRing::SetColorId(
+ views::View* parent,
+ const base::Optional<ui::NativeTheme::ColorId>& override_color_id) {
+ FocusRing* ring = GetFocusRing(parent);
+ ring->override_color_id_ = override_color_id;
+ ring->SchedulePaint();
}
const char* FocusRing::GetClassName() const {
@@ -63,9 +75,11 @@ void FocusRing::Layout() {
void FocusRing::OnPaint(gfx::Canvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
- paint.setColor(SkColorSetA(GetNativeTheme()->GetSystemColor(
- ui::NativeTheme::kColorId_FocusedBorderColor),
- 0x66));
+ paint.setColor(SkColorSetA(
+ GetNativeTheme()->GetSystemColor(
+ override_color_id_ ? *override_color_id_
+ : ui::NativeTheme::kColorId_FocusedBorderColor),
+ 0x66));
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(kFocusHaloThicknessDp);
gfx::RectF rect(GetLocalBounds());

Powered by Google App Engine
This is Rietveld 408576698