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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 23441024: Implement put_accvalue for textfields and location bar. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Switch to WeakPtrFactory Created 7 years, 3 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 default_width_in_chars_(0), 82 default_width_in_chars_(0),
83 draw_border_(true), 83 draw_border_(true),
84 text_color_(SK_ColorBLACK), 84 text_color_(SK_ColorBLACK),
85 use_default_text_color_(true), 85 use_default_text_color_(true),
86 background_color_(SK_ColorWHITE), 86 background_color_(SK_ColorWHITE),
87 use_default_background_color_(true), 87 use_default_background_color_(true),
88 horizontal_margins_were_set_(false), 88 horizontal_margins_were_set_(false),
89 vertical_margins_were_set_(false), 89 vertical_margins_were_set_(false),
90 vertical_alignment_(gfx::ALIGN_VCENTER), 90 vertical_alignment_(gfx::ALIGN_VCENTER),
91 placeholder_text_color_(kDefaultPlaceholderTextColor), 91 placeholder_text_color_(kDefaultPlaceholderTextColor),
92 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 92 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
93 weak_ptr_factory_(this) {
93 set_focusable(true); 94 set_focusable(true);
94 95
95 if (ViewsDelegate::views_delegate) { 96 if (ViewsDelegate::views_delegate) {
96 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 97 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
97 GetDefaultTextfieldObscuredRevealDuration(); 98 GetDefaultTextfieldObscuredRevealDuration();
98 } 99 }
99 } 100 }
100 101
101 Textfield::Textfield(StyleFlags style) 102 Textfield::Textfield(StyleFlags style)
102 : native_wrapper_(NULL), 103 : native_wrapper_(NULL),
103 controller_(NULL), 104 controller_(NULL),
104 style_(style), 105 style_(style),
105 font_list_(GetDefaultFontList()), 106 font_list_(GetDefaultFontList()),
106 read_only_(false), 107 read_only_(false),
107 default_width_in_chars_(0), 108 default_width_in_chars_(0),
108 draw_border_(true), 109 draw_border_(true),
109 text_color_(SK_ColorBLACK), 110 text_color_(SK_ColorBLACK),
110 use_default_text_color_(true), 111 use_default_text_color_(true),
111 background_color_(SK_ColorWHITE), 112 background_color_(SK_ColorWHITE),
112 use_default_background_color_(true), 113 use_default_background_color_(true),
113 horizontal_margins_were_set_(false), 114 horizontal_margins_were_set_(false),
114 vertical_margins_were_set_(false), 115 vertical_margins_were_set_(false),
115 vertical_alignment_(gfx::ALIGN_VCENTER), 116 vertical_alignment_(gfx::ALIGN_VCENTER),
116 placeholder_text_color_(kDefaultPlaceholderTextColor), 117 placeholder_text_color_(kDefaultPlaceholderTextColor),
117 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { 118 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
119 weak_ptr_factory_(this) {
118 set_focusable(true); 120 set_focusable(true);
119 if (IsObscured()) 121 if (IsObscured())
120 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 122 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
121 123
122 if (ViewsDelegate::views_delegate) { 124 if (ViewsDelegate::views_delegate) {
123 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 125 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
124 GetDefaultTextfieldObscuredRevealDuration(); 126 GetDefaultTextfieldObscuredRevealDuration();
125 } 127 }
126 } 128 }
127 129
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 state->name = accessible_name_; 501 state->name = accessible_name_;
500 if (read_only()) 502 if (read_only())
501 state->state |= ui::AccessibilityTypes::STATE_READONLY; 503 state->state |= ui::AccessibilityTypes::STATE_READONLY;
502 if (IsObscured()) 504 if (IsObscured())
503 state->state |= ui::AccessibilityTypes::STATE_PROTECTED; 505 state->state |= ui::AccessibilityTypes::STATE_PROTECTED;
504 state->value = text_; 506 state->value = text_;
505 507
506 const ui::Range range = native_wrapper_->GetSelectedRange(); 508 const ui::Range range = native_wrapper_->GetSelectedRange();
507 state->selection_start = range.start(); 509 state->selection_start = range.start();
508 state->selection_end = range.end(); 510 state->selection_end = range.end();
511
512 state->set_value_callback =
513 base::Bind(&Textfield::AccessibilitySetValue,
514 weak_ptr_factory_.GetWeakPtr());
509 } 515 }
510 516
511 ui::TextInputClient* Textfield::GetTextInputClient() { 517 ui::TextInputClient* Textfield::GetTextInputClient() {
512 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL; 518 return native_wrapper_ ? native_wrapper_->GetTextInputClient() : NULL;
513 } 519 }
514 520
515 void Textfield::OnEnabledChanged() { 521 void Textfield::OnEnabledChanged() {
516 View::OnEnabledChanged(); 522 View::OnEnabledChanged();
517 if (native_wrapper_) 523 if (native_wrapper_)
518 native_wrapper_->UpdateEnabled(); 524 native_wrapper_->UpdateEnabled();
(...skipping 28 matching lines...) Expand all
547 return kViewClassName; 553 return kViewClassName;
548 } 554 }
549 555
550 gfx::Insets Textfield::GetTextInsets() const { 556 gfx::Insets Textfield::GetTextInsets() const {
551 gfx::Insets insets = GetInsets(); 557 gfx::Insets insets = GetInsets();
552 if (draw_border_ && native_wrapper_) 558 if (draw_border_ && native_wrapper_)
553 insets += native_wrapper_->CalculateInsets(); 559 insets += native_wrapper_->CalculateInsets();
554 return insets; 560 return insets;
555 } 561 }
556 562
563 void Textfield::AccessibilitySetValue(const string16& new_value) {
sky 2013/09/04 16:20:12 Make position match header.
dmazzoni 2013/09/04 17:16:18 I think it is in the right place - I added a secti
564 SetText(new_value);
sky 2013/09/04 16:20:12 Doesn't this need to check readonly?
dmazzoni 2013/09/04 17:16:18 Done. I also had it not set the callback, above.
565 ClearSelection();
566 }
567
557 //////////////////////////////////////////////////////////////////////////////// 568 ////////////////////////////////////////////////////////////////////////////////
558 // NativeTextfieldWrapper, public: 569 // NativeTextfieldWrapper, public:
559 570
560 // static 571 // static
561 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 572 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
562 Textfield* field) { 573 Textfield* field) {
563 #if defined(OS_WIN) && !defined(USE_AURA) 574 #if defined(OS_WIN) && !defined(USE_AURA)
564 if (!Textfield::IsViewsTextfieldEnabled()) 575 if (!Textfield::IsViewsTextfieldEnabled())
565 return new NativeTextfieldWin(field); 576 return new NativeTextfieldWin(field);
566 #endif 577 #endif
567 return new NativeTextfieldViews(field); 578 return new NativeTextfieldViews(field);
568 } 579 }
569 580
570 } // namespace views 581 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698