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

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

Issue 2939553002: Views; Fire a value changed event when the contents of a text field changes. (Closed)
Patch Set: Created 3 years, 6 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
« 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) 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 330
331 void Textfield::SetTextInputFlags(int flags) { 331 void Textfield::SetTextInputFlags(int flags) {
332 text_input_flags_ = flags; 332 text_input_flags_ = flags;
333 } 333 }
334 334
335 void Textfield::SetText(const base::string16& new_text) { 335 void Textfield::SetText(const base::string16& new_text) {
336 model_->SetText(new_text); 336 model_->SetText(new_text);
337 OnCaretBoundsChanged(); 337 OnCaretBoundsChanged();
338 SchedulePaint(); 338 SchedulePaint();
339 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); 339 NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true);
340 } 340 }
341 341
342 void Textfield::AppendText(const base::string16& new_text) { 342 void Textfield::AppendText(const base::string16& new_text) {
343 if (new_text.empty()) 343 if (new_text.empty())
344 return; 344 return;
345 model_->Append(new_text); 345 model_->Append(new_text);
346 OnCaretBoundsChanged(); 346 OnCaretBoundsChanged();
347 SchedulePaint(); 347 SchedulePaint();
348 } 348 }
349 349
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 auto border = base::MakeUnique<views::FocusableBorder>(); 1928 auto border = base::MakeUnique<views::FocusableBorder>();
1929 if (invalid_) 1929 if (invalid_)
1930 border->SetColorId(ui::NativeTheme::kColorId_AlertSeverityHigh); 1930 border->SetColorId(ui::NativeTheme::kColorId_AlertSeverityHigh);
1931 View::SetBorder(std::move(border)); 1931 View::SetBorder(std::move(border));
1932 } 1932 }
1933 1933
1934 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { 1934 void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
1935 if (text_changed) { 1935 if (text_changed) {
1936 if (controller_) 1936 if (controller_)
1937 controller_->ContentsChanged(this, text()); 1937 controller_->ContentsChanged(this, text());
1938 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); 1938 NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true);
1939 } 1939 }
1940 if (cursor_changed) { 1940 if (cursor_changed) {
1941 UpdateCursorViewPosition(); 1941 UpdateCursorViewPosition();
1942 UpdateCursorVisibility(); 1942 UpdateCursorVisibility();
1943 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); 1943 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true);
1944 } 1944 }
1945 if (text_changed || cursor_changed) { 1945 if (text_changed || cursor_changed) {
1946 OnCaretBoundsChanged(); 1946 OnCaretBoundsChanged();
1947 SchedulePaint(); 1947 SchedulePaint();
1948 } 1948 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 cursor_blink_timer_.Stop(); 2117 cursor_blink_timer_.Stop();
2118 } 2118 }
2119 2119
2120 void Textfield::OnCursorBlinkTimerFired() { 2120 void Textfield::OnCursorBlinkTimerFired() {
2121 DCHECK(ShouldBlinkCursor()); 2121 DCHECK(ShouldBlinkCursor());
2122 cursor_view_.SetVisible(!cursor_view_.visible()); 2122 cursor_view_.SetVisible(!cursor_view_.visible());
2123 UpdateCursorViewPosition(); 2123 UpdateCursorViewPosition();
2124 } 2124 }
2125 2125
2126 } // namespace views 2126 } // 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