Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index fdfe19b095fc0cdb63d857ba800f0d88b509abf0..3a23bc5b9017eba91b12b1086928aa32411f7833 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -455,7 +455,12 @@ bool Textfield::GetCursorEnabled() const { |
| } |
| void Textfield::SetCursorEnabled(bool enabled) { |
| + if (GetRenderText()->cursor_enabled() == enabled) { |
|
msw
2017/03/09 21:05:45
nit: curlies not needed
yiyix
2017/03/10 20:19:29
Done.
|
| + return; |
| + } |
| GetRenderText()->SetCursorEnabled(enabled); |
| + UpdateCursorView(); |
| + ShowCursor(); |
| } |
| const gfx::FontList& Textfield::GetFontList() const { |
| @@ -1911,11 +1916,7 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { |
| } |
| if (cursor_changed) { |
| UpdateCursorView(); |
| - cursor_view_.SetVisible(ShouldShowCursor()); |
| - if (ShouldBlinkCursor()) |
| - StartBlinkingCursor(); |
| - else |
| - StopBlinkingCursor(); |
| + ShowCursor(); |
| NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); |
| } |
| if (text_changed || cursor_changed) { |
| @@ -1924,6 +1925,14 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { |
| } |
| } |
| +void Textfield::ShowCursor() { |
|
msw
2017/03/09 21:05:45
Can we inline this into UpdateCursorView()? Otherw
yiyix
2017/03/10 20:19:29
I don't think inline this into UpdateCursorView is
msw
2017/03/10 21:04:29
Acknowledged.
|
| + cursor_view_.SetVisible(ShouldShowCursor()); |
| + if (ShouldBlinkCursor()) |
| + StartBlinkingCursor(); |
| + else |
| + StopBlinkingCursor(); |
| +} |
| + |
| void Textfield::UpdateCursorView() { |
| gfx::Rect location(GetRenderText()->GetUpdatedCursorBounds()); |
| location.set_x(GetMirroredXForRect(location)); |