Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index 74395f29eea8f5acdb33f177af363fe990b83197..1f7919406e8f846436330971100ba4f41c8db2d3 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -73,10 +73,9 @@ Textfield::Textfield(StyleFlags style) |
| initialized_(false), |
| horizontal_margins_were_set_(false), |
| vertical_margins_were_set_(false), |
| - text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { |
| + text_input_type_(style & STYLE_PASSWORD ? |
|
bryeung
2011/12/02 16:22:28
I'd rather not duplicate the logic of IsPassword h
benrg
2011/12/02 18:21:41
I did it that way to avoid calling a method while
|
| + ui::TEXT_INPUT_TYPE_PASSWORD : ui::TEXT_INPUT_TYPE_TEXT) { |
| set_focusable(true); |
| - if (IsPassword()) |
| - SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| } |
| Textfield::~Textfield() { |
| @@ -103,19 +102,6 @@ bool Textfield::IsPassword() const { |
| return style_ & STYLE_PASSWORD; |
| } |
| -void Textfield::SetPassword(bool password) { |
| - if (password) { |
| - style_ = static_cast<StyleFlags>(style_ | STYLE_PASSWORD); |
| - SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| - } else { |
| - style_ = static_cast<StyleFlags>(style_ & ~STYLE_PASSWORD); |
| - SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); |
| - } |
| - if (native_wrapper_) |
| - native_wrapper_->UpdateIsPassword(); |
| -} |
| - |
| - |
| ui::TextInputType Textfield::GetTextInputType() const { |
| if (read_only() || !IsEnabled()) |
| return ui::TEXT_INPUT_TYPE_NONE; |
| @@ -123,10 +109,14 @@ ui::TextInputType Textfield::GetTextInputType() const { |
| } |
| void Textfield::SetTextInputType(ui::TextInputType type) { |
| + bool was_password = IsPassword(); |
| + bool will_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD; |
| text_input_type_ = type; |
| - bool should_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD; |
| - if (IsPassword() != should_be_password) |
| - SetPassword(should_be_password); |
| + if (was_password != will_be_password) { |
| + style_ = static_cast<StyleFlags>(style_ ^ STYLE_PASSWORD); |
| + if (native_wrapper_) |
| + native_wrapper_->UpdateIsPassword(); |
| + } |
| } |
| void Textfield::SetText(const string16& text) { |