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

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: rebase 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
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..7daddf30b27660a87ee92e02aa703a504c7566b2 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 ?
+ ui::TEXT_INPUT_TYPE_PASSWORD : ui::TEXT_INPUT_TYPE_TEXT) {
set_focusable(true);
- if (IsPassword())
- SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
}
Textfield::~Textfield() {
@@ -99,23 +98,6 @@ void Textfield::SetReadOnly(bool read_only) {
}
}
-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 +105,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) {
« ui/views/controls/textfield/textfield.h ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698