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

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: Textfield(STYLE_OBSCURED) sets TEXT_INPUT_TYPE_PASSWORD Created 9 years 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..56a50045edb9c6907cc28b75e8b3f2a9b82831b4 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -75,7 +75,7 @@ Textfield::Textfield(StyleFlags style)
vertical_margins_were_set_(false),
text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
set_focusable(true);
- if (IsPassword())
+ if (IsObscured())
SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
}
@@ -99,23 +99,18 @@ void Textfield::SetReadOnly(bool read_only) {
}
}
-bool Textfield::IsPassword() const {
- return style_ & STYLE_PASSWORD;
+bool Textfield::IsObscured() const {
+ return style_ & STYLE_OBSCURED;
}
-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);
+void Textfield::SetObscured(bool obscure) {
+ if (obscure != IsObscured()) {
+ style_ = static_cast<StyleFlags>(style_ ^ STYLE_OBSCURED);
+ if (native_wrapper_)
+ native_wrapper_->UpdateIsObscured();
}
- if (native_wrapper_)
- native_wrapper_->UpdateIsPassword();
}
-
ui::TextInputType Textfield::GetTextInputType() const {
if (read_only() || !IsEnabled())
return ui::TEXT_INPUT_TYPE_NONE;
@@ -124,9 +119,6 @@ ui::TextInputType Textfield::GetTextInputType() const {
void Textfield::SetTextInputType(ui::TextInputType type) {
text_input_type_ = type;
- bool should_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD;
- if (IsPassword() != should_be_password)
- SetPassword(should_be_password);
}
void Textfield::SetText(const string16& text) {
@@ -247,7 +239,7 @@ void Textfield::UpdateAllProperties() {
native_wrapper_->UpdateFont();
native_wrapper_->UpdateEnabled();
native_wrapper_->UpdateBorder();
- native_wrapper_->UpdateIsPassword();
+ native_wrapper_->UpdateIsObscured();
native_wrapper_->UpdateHorizontalMargins();
native_wrapper_->UpdateVerticalMargins();
}
@@ -399,7 +391,7 @@ void Textfield::GetAccessibleState(ui::AccessibleViewState* state) {
state->name = accessible_name_;
if (read_only())
state->state |= ui::AccessibilityTypes::STATE_READONLY;
- if (IsPassword())
+ if (IsObscured())
state->state |= ui::AccessibilityTypes::STATE_PROTECTED;
state->value = text_;

Powered by Google App Engine
This is Rietveld 408576698