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

Unified 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: Address feedback 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 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 4787e4e4af6281a38cf26fa9327643a4eb52d391..b76c20c8ac8dbbb9c065bb7650f32953bb4b5488 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -89,7 +89,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) {
@@ -114,7 +115,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);
@@ -506,6 +508,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() {
@@ -547,6 +555,9 @@ const char* Textfield::GetClassName() const {
return kViewClassName;
}
+////////////////////////////////////////////////////////////////////////////////
+// Textfield, private:
+
gfx::Insets Textfield::GetTextInsets() const {
gfx::Insets insets = GetInsets();
if (draw_border_ && native_wrapper_)
@@ -554,6 +565,13 @@ gfx::Insets Textfield::GetTextInsets() const {
return insets;
}
+void Textfield::AccessibilitySetValue(const string16& new_value) {
+ if (!read_only()) {
+ SetText(new_value);
+ ClearSelection();
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeTextfieldWrapper, public:

Powered by Google App Engine
This is Rietveld 408576698