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

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

Issue 8850001: Send a11y events from NativeTextfieldViews when the state changes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/native_textfield_views.h" 5 #include "ui/views/controls/textfield/native_textfield_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // NativeTextfieldViews, NativeTextifieldWrapper overrides: 316 // NativeTextfieldViews, NativeTextifieldWrapper overrides:
317 317
318 string16 NativeTextfieldViews::GetText() const { 318 string16 NativeTextfieldViews::GetText() const {
319 return model_->GetText(); 319 return model_->GetText();
320 } 320 }
321 321
322 void NativeTextfieldViews::UpdateText() { 322 void NativeTextfieldViews::UpdateText() {
323 model_->SetText(textfield_->text()); 323 model_->SetText(textfield_->text());
324 OnCaretBoundsChanged(); 324 OnCaretBoundsChanged();
325 SchedulePaint(); 325 SchedulePaint();
326 textfield_->GetWidget()->NotifyAccessibilityEvent(
327 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true);
326 } 328 }
327 329
328 void NativeTextfieldViews::AppendText(const string16& text) { 330 void NativeTextfieldViews::AppendText(const string16& text) {
329 if (text.empty()) 331 if (text.empty())
330 return; 332 return;
331 model_->Append(text); 333 model_->Append(text);
332 OnCaretBoundsChanged(); 334 OnCaretBoundsChanged();
333 SchedulePaint(); 335 SchedulePaint();
334 } 336 }
335 337
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 453 }
452 454
453 void NativeTextfieldViews::GetSelectedRange(ui::Range* range) const { 455 void NativeTextfieldViews::GetSelectedRange(ui::Range* range) const {
454 model_->GetSelectedRange(range); 456 model_->GetSelectedRange(range);
455 } 457 }
456 458
457 void NativeTextfieldViews::SelectRange(const ui::Range& range) { 459 void NativeTextfieldViews::SelectRange(const ui::Range& range) {
458 model_->SelectRange(range); 460 model_->SelectRange(range);
459 OnCaretBoundsChanged(); 461 OnCaretBoundsChanged();
460 SchedulePaint(); 462 SchedulePaint();
463 textfield_->GetWidget()->NotifyAccessibilityEvent(
464 textfield_, ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true);
461 } 465 }
462 466
463 void NativeTextfieldViews::GetSelectionModel(gfx::SelectionModel* sel) const { 467 void NativeTextfieldViews::GetSelectionModel(gfx::SelectionModel* sel) const {
464 model_->GetSelectionModel(sel); 468 model_->GetSelectionModel(sel);
465 } 469 }
466 470
467 void NativeTextfieldViews::SelectSelectionModel( 471 void NativeTextfieldViews::SelectSelectionModel(
468 const gfx::SelectionModel& sel) { 472 const gfx::SelectionModel& sel) {
469 model_->SelectSelectionModel(sel); 473 model_->SelectSelectionModel(sel);
470 OnCaretBoundsChanged(); 474 OnCaretBoundsChanged();
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 OnCaretBoundsChanged(); 934 OnCaretBoundsChanged();
931 return true; 935 return true;
932 } 936 }
933 937
934 void NativeTextfieldViews::PropagateTextChange() { 938 void NativeTextfieldViews::PropagateTextChange() {
935 textfield_->SyncText(); 939 textfield_->SyncText();
936 } 940 }
937 941
938 void NativeTextfieldViews::UpdateAfterChange(bool text_changed, 942 void NativeTextfieldViews::UpdateAfterChange(bool text_changed,
939 bool cursor_changed) { 943 bool cursor_changed) {
940 if (text_changed) 944 if (text_changed) {
941 PropagateTextChange(); 945 PropagateTextChange();
946 textfield_->GetWidget()->NotifyAccessibilityEvent(
947 textfield_, ui::AccessibilityTypes::EVENT_TEXT_CHANGED, true);
948 }
942 if (cursor_changed) { 949 if (cursor_changed) {
943 is_cursor_visible_ = true; 950 is_cursor_visible_ = true;
944 RepaintCursor(); 951 RepaintCursor();
952 if (!text_changed) {
953 // TEXT_CHANGED implies SELECTION_CHANGED, so we only need to fire
954 // this if only the selection changed.
955 textfield_->GetWidget()->NotifyAccessibilityEvent(
956 textfield_, ui::AccessibilityTypes::EVENT_SELECTION_CHANGED, true);
957 }
945 } 958 }
946 if (text_changed || cursor_changed) { 959 if (text_changed || cursor_changed) {
947 OnCaretBoundsChanged(); 960 OnCaretBoundsChanged();
948 SchedulePaint(); 961 SchedulePaint();
949 } 962 }
950 } 963 }
951 964
952 void NativeTextfieldViews::UpdateContextMenu() { 965 void NativeTextfieldViews::UpdateContextMenu() {
953 if (!context_menu_contents_.get()) { 966 if (!context_menu_contents_.get()) {
954 context_menu_contents_.reset(new ui::SimpleMenuModel(this)); 967 context_menu_contents_.reset(new ui::SimpleMenuModel(this));
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1089
1077 #if defined(USE_AURA) 1090 #if defined(USE_AURA)
1078 // static 1091 // static
1079 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1092 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1080 Textfield* field) { 1093 Textfield* field) {
1081 return new NativeTextfieldViews(field); 1094 return new NativeTextfieldViews(field);
1082 } 1095 }
1083 #endif 1096 #endif
1084 1097
1085 } // namespace views 1098 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698