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

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

Issue 8748001: Make text input type and password visibility bit independent in Textfield (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move IsPassword() back to .cc Created 9 years, 1 month 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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698