diff options
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.cc | 1 | ||||
-rw-r--r-- | views/controls/textfield/textfield.cc | 35 | ||||
-rw-r--r-- | views/controls/textfield/textfield.h | 8 |
3 files changed, 18 insertions, 26 deletions
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc index 0dac9a4..4aef06f 100644 --- a/views/controls/textfield/native_textfield_gtk.cc +++ b/views/controls/textfield/native_textfield_gtk.cc @@ -243,6 +243,7 @@ void NativeTextfieldGtk::CreateNativeControl() { NativeControlCreated(gtk_entry_new()); gtk_entry_set_invisible_char(GTK_ENTRY(native_view()), static_cast<gunichar>(kPasswordChar)); + textfield_->UpdateAllProperties(); } void NativeTextfieldGtk::NativeControlCreated(GtkWidget* widget) { diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc index 8f6486f..d2e2fae 100644 --- a/views/controls/textfield/textfield.cc +++ b/views/controls/textfield/textfield.cc @@ -183,6 +183,18 @@ void Textfield::RemoveBorder() { native_wrapper_->UpdateBorder(); } +void Textfield::UpdateAllProperties() { + if (native_wrapper_) { + native_wrapper_->UpdateText(); + native_wrapper_->UpdateTextColor(); + native_wrapper_->UpdateBackgroundColor(); + native_wrapper_->UpdateReadOnly(); + native_wrapper_->UpdateFont(); + native_wrapper_->UpdateEnabled(); + native_wrapper_->UpdateBorder(); + native_wrapper_->UpdateIsPassword(); + } +} void Textfield::SyncText() { if (native_wrapper_) @@ -299,14 +311,7 @@ void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) { AddChildView(native_wrapper_->GetView()); // TODO(beng): Move this initialization to NativeTextfieldWin once it // subclasses NativeControlWin. - native_wrapper_->UpdateText(); - native_wrapper_->UpdateTextColor(); - native_wrapper_->UpdateBackgroundColor(); - native_wrapper_->UpdateReadOnly(); - native_wrapper_->UpdateFont(); - native_wrapper_->UpdateEnabled(); - native_wrapper_->UpdateBorder(); - native_wrapper_->UpdateIsPassword(); + UpdateAllProperties(); #if defined(OS_WIN) // TODO(beng): remove this once NativeTextfieldWin subclasses @@ -324,20 +329,6 @@ std::string Textfield::GetClassName() const { return kViewClassName; } -NativeTextfieldWrapper* Textfield::CreateWrapper() { - NativeTextfieldWrapper* native_wrapper = - NativeTextfieldWrapper::CreateWrapper(this); - - native_wrapper->UpdateText(); - native_wrapper->UpdateBackgroundColor(); - native_wrapper->UpdateReadOnly(); - native_wrapper->UpdateFont(); - native_wrapper->UpdateEnabled(); - native_wrapper->UpdateBorder(); - - return native_wrapper; -} - base::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const { #if defined(OS_WIN) return static_cast<base::KeyboardCode>(key_); diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h index 7b9c393..71bdf49 100644 --- a/views/controls/textfield/textfield.h +++ b/views/controls/textfield/textfield.h @@ -184,6 +184,10 @@ class Textfield : public View { bool draw_border() const { return draw_border_; } void RemoveBorder(); + // Updates all properties on the textfield. This is invoked internally. + // Users of Textfield never need to invoke this directly. + void UpdateAllProperties(); + // Invoked by the edit control when the value changes. This method set // the text_ member variable to the value contained in edit control. // This is important because the edit control can be replaced if it has @@ -216,10 +220,6 @@ class Textfield : public View { virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); virtual std::string GetClassName() const; - // Creates a new native wrapper properly initialized and returns it. Ownership - // is passed to the caller. - NativeTextfieldWrapper* CreateWrapper(); - // The object that actually implements the native text field. NativeTextfieldWrapper* native_wrapper_; |