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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2729133005: Fix: Cursor missing in omnibox after entering a alphabet in NTP 'Search box' (Closed)
Patch Set: new approach Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698