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

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

Issue 2373403002: views: update textfield cursor state after programmatic text changes (Closed)
Patch Set: Created 4 years, 2 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/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 SchedulePaint(); 300 SchedulePaint();
301 } 301 }
302 302
303 void Textfield::SetTextInputFlags(int flags) { 303 void Textfield::SetTextInputFlags(int flags) {
304 text_input_flags_ = flags; 304 text_input_flags_ = flags;
305 } 305 }
306 306
307 void Textfield::SetText(const base::string16& new_text) { 307 void Textfield::SetText(const base::string16& new_text) {
308 model_->SetText(new_text); 308 model_->SetText(new_text);
309 OnCaretBoundsChanged(); 309 OnCaretBoundsChanged();
310 UpdateAfterChange(true, true);
Peter Kasting 2016/09/28 18:56:47 UpdateAfterChange() calls OnCaretBoundsChanged(),
Elly Fong-Jones 2016/10/03 17:37:30 Done.
310 SchedulePaint(); 311 SchedulePaint();
311 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); 312 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
312 } 313 }
313 314
314 void Textfield::AppendText(const base::string16& new_text) { 315 void Textfield::AppendText(const base::string16& new_text) {
315 if (new_text.empty()) 316 if (new_text.empty())
316 return; 317 return;
317 model_->Append(new_text); 318 model_->Append(new_text);
318 OnCaretBoundsChanged(); 319 OnCaretBoundsChanged();
320 UpdateAfterChange(true, true);
Peter Kasting 2016/09/28 18:56:47 The next two functions now trigger accessibility n
Elly Fong-Jones 2016/10/03 17:37:30 I don't know. There are several screenreaders, all
319 SchedulePaint(); 321 SchedulePaint();
320 } 322 }
321 323
322 void Textfield::InsertOrReplaceText(const base::string16& new_text) { 324 void Textfield::InsertOrReplaceText(const base::string16& new_text) {
323 if (new_text.empty()) 325 if (new_text.empty())
324 return; 326 return;
325 model_->InsertText(new_text); 327 model_->InsertText(new_text);
326 OnCaretBoundsChanged(); 328 OnCaretBoundsChanged();
329 UpdateAfterChange(true, true);
327 SchedulePaint(); 330 SchedulePaint();
328 } 331 }
329 332
330 base::string16 Textfield::GetSelectedText() const { 333 base::string16 Textfield::GetSelectedText() const {
331 return model_->GetSelectedText(); 334 return model_->GetSelectedText();
332 } 335 }
333 336
334 void Textfield::SelectAll(bool reversed) { 337 void Textfield::SelectAll(bool reversed) {
335 model_->SelectAll(reversed); 338 model_->SelectAll(reversed);
336 UpdateSelectionClipboard(); 339 UpdateSelectionClipboard();
(...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 } 2062 }
2060 2063
2061 void Textfield::OnCursorBlinkTimerFired() { 2064 void Textfield::OnCursorBlinkTimerFired() {
2062 DCHECK(ShouldBlinkCursor()); 2065 DCHECK(ShouldBlinkCursor());
2063 gfx::RenderText* render_text = GetRenderText(); 2066 gfx::RenderText* render_text = GetRenderText();
2064 render_text->set_cursor_visible(!render_text->cursor_visible()); 2067 render_text->set_cursor_visible(!render_text->cursor_visible());
2065 RepaintCursor(); 2068 RepaintCursor();
2066 } 2069 }
2067 2070
2068 } // namespace views 2071 } // 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