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

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

Issue 2373403002: views: update textfield cursor state after programmatic text changes (Closed)
Patch Set: remove spurious update calls 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 GetInputMethod()->OnTextInputTypeChanged(this); 299 GetInputMethod()->OnTextInputTypeChanged(this);
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 UpdateAfterChange(true, true);
310 SchedulePaint();
311 NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
312 } 310 }
313 311
314 void Textfield::AppendText(const base::string16& new_text) { 312 void Textfield::AppendText(const base::string16& new_text) {
315 if (new_text.empty()) 313 if (new_text.empty())
316 return; 314 return;
317 model_->Append(new_text); 315 model_->Append(new_text);
318 OnCaretBoundsChanged(); 316 UpdateAfterChange(true, true);
319 SchedulePaint();
320 } 317 }
321 318
322 void Textfield::InsertOrReplaceText(const base::string16& new_text) { 319 void Textfield::InsertOrReplaceText(const base::string16& new_text) {
323 if (new_text.empty()) 320 if (new_text.empty())
324 return; 321 return;
325 model_->InsertText(new_text); 322 model_->InsertText(new_text);
326 OnCaretBoundsChanged(); 323 UpdateAfterChange(true, true);
327 SchedulePaint();
328 } 324 }
329 325
330 base::string16 Textfield::GetSelectedText() const { 326 base::string16 Textfield::GetSelectedText() const {
331 return model_->GetSelectedText(); 327 return model_->GetSelectedText();
332 } 328 }
333 329
334 void Textfield::SelectAll(bool reversed) { 330 void Textfield::SelectAll(bool reversed) {
335 model_->SelectAll(reversed); 331 model_->SelectAll(reversed);
336 UpdateSelectionClipboard(); 332 UpdateSelectionClipboard();
337 UpdateAfterChange(false, true); 333 UpdateAfterChange(false, true);
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
2059 } 2055 }
2060 2056
2061 void Textfield::OnCursorBlinkTimerFired() { 2057 void Textfield::OnCursorBlinkTimerFired() {
2062 DCHECK(ShouldBlinkCursor()); 2058 DCHECK(ShouldBlinkCursor());
2063 gfx::RenderText* render_text = GetRenderText(); 2059 gfx::RenderText* render_text = GetRenderText();
2064 render_text->set_cursor_visible(!render_text->cursor_visible()); 2060 render_text->set_cursor_visible(!render_text->cursor_visible());
2065 RepaintCursor(); 2061 RepaintCursor();
2066 } 2062 }
2067 2063
2068 } // namespace views 2064 } // 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