Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/autofill/decorated_textfield.h" | 5 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 7 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 8 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" | 8 #include "chrome/browser/ui/views/autofill/tooltip_icon.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 set_background( | 137 set_background( |
| 138 views::Background::CreateSolidBackground(GetBackgroundColor())); | 138 views::Background::CreateSolidBackground(GetBackgroundColor())); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void DecoratedTextfield::UpdateBorder() { | 141 void DecoratedTextfield::UpdateBorder() { |
| 142 views::FocusableBorder* border = new views::FocusableBorder(); | 142 views::FocusableBorder* border = new views::FocusableBorder(); |
| 143 if (invalid_) | 143 if (invalid_) |
| 144 border->SetColor(kWarningColor); | 144 border->SetColor(kWarningColor); |
| 145 else if (!editable_) | 145 else if (!editable_) |
| 146 border->SetColor(SK_ColorTRANSPARENT); | 146 border->SetColor(SK_ColorTRANSPARENT); |
| 147 | |
| 148 const gfx::Insets insets = GetInsets(); | |
| 149 int left = icon_view_ ? | |
| 150 icon_view_->GetPreferredSize().width() + 2 * kTextfieldIconPadding : 0; | |
| 151 int right = 0; | |
| 152 if (base::i18n::IsRTL()) | |
| 153 std::swap(left, right); | |
| 154 border->SetInsets(insets.top(), insets.left() + left, insets.bottom(), | |
| 155 insets.right() + right); | |
| 156 set_border(border); | 147 set_border(border); |
| 157 } | 148 } |
| 158 | 149 |
| 159 void DecoratedTextfield::IconChanged() { | 150 void DecoratedTextfield::IconChanged() { |
| 160 // Don't show the icon if nothing else is showing. | 151 // Don't show the icon if nothing else is showing. |
| 161 const bool visible = editable_ || !text().empty(); | 152 icon_view_->SetVisible(editable_ || !text().empty()); |
| 162 if (icon_view_->visible() == visible) | 153 Layout(); |
|
Evan Stade
2014/01/16 20:40:43
why remove this?
msw
2014/01/16 21:10:33
It seems to be necessary. I tried to dig in and un
| |
| 163 return; | |
| 164 | |
| 165 icon_view_->SetVisible(visible); | |
| 166 UpdateBorder(); | |
| 167 SchedulePaint(); | |
| 168 } | 154 } |
| 169 | 155 |
| 170 } // namespace autofill | 156 } // namespace autofill |
| OLD | NEW |