| Index: ui/views/controls/textfield/textfield.cc
|
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
|
| index e358657cb135e902972eaf5d2f5b19cbef838c45..bf35aff80b323dc1e3803ef77126bdf81e6272d2 100644
|
| --- a/ui/views/controls/textfield/textfield.cc
|
| +++ b/ui/views/controls/textfield/textfield.cc
|
| @@ -85,7 +85,8 @@ Textfield::Textfield()
|
| vertical_margins_were_set_(false),
|
| vertical_alignment_(gfx::ALIGN_VCENTER),
|
| placeholder_text_color_(kDefaultPlaceholderTextColor),
|
| - text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
|
| + text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
|
| + weak_ptr_factory_(this) {
|
| set_focusable(true);
|
|
|
| if (ViewsDelegate::views_delegate) {
|
| @@ -110,7 +111,8 @@ Textfield::Textfield(StyleFlags style)
|
| vertical_margins_were_set_(false),
|
| vertical_alignment_(gfx::ALIGN_VCENTER),
|
| placeholder_text_color_(kDefaultPlaceholderTextColor),
|
| - text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
|
| + text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
|
| + weak_ptr_factory_(this) {
|
| set_focusable(true);
|
| if (IsObscured())
|
| SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
|
| @@ -502,6 +504,12 @@ void Textfield::GetAccessibleState(ui::AccessibleViewState* state) {
|
| const ui::Range range = native_wrapper_->GetSelectedRange();
|
| state->selection_start = range.start();
|
| state->selection_end = range.end();
|
| +
|
| + if (!read_only()) {
|
| + state->set_value_callback =
|
| + base::Bind(&Textfield::AccessibilitySetValue,
|
| + weak_ptr_factory_.GetWeakPtr());
|
| + }
|
| }
|
|
|
| ui::TextInputClient* Textfield::GetTextInputClient() {
|
| @@ -543,6 +551,9 @@ const char* Textfield::GetClassName() const {
|
| return kViewClassName;
|
| }
|
|
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// Textfield, private:
|
| +
|
| gfx::Insets Textfield::GetTextInsets() const {
|
| gfx::Insets insets = GetInsets();
|
| if (draw_border_ && native_wrapper_)
|
| @@ -550,6 +561,13 @@ gfx::Insets Textfield::GetTextInsets() const {
|
| return insets;
|
| }
|
|
|
| +void Textfield::AccessibilitySetValue(const string16& new_value) {
|
| + if (!read_only()) {
|
| + SetText(new_value);
|
| + ClearSelection();
|
| + }
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // NativeTextfieldWrapper, public:
|
|
|
|
|