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

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: Fix rebase error 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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698