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

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

Issue 2754633002: Fix: Cursor missing in omnibox after entering a alphabet in NTP 'Search box' (Closed)
Patch Set: 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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 342e5137acd96751d31e38a57289bd3b1e7aefce..19bc1c8f72032c31f36dcd81717ebe1b27a0f990 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)
+ return;
+
GetRenderText()->SetCursorEnabled(enabled);
+ UpdateCursorViewPosition();
+ UpdateCursorVisibility();
}
const gfx::FontList& Textfield::GetFontList() const {
@@ -981,7 +986,7 @@ void Textfield::OnPaint(gfx::Canvas* canvas) {
void Textfield::OnFocus() {
GetRenderText()->set_focused(true);
if (ShouldShowCursor()) {
- UpdateCursorView();
+ UpdateCursorViewPosition();
cursor_view_.SetVisible(true);
}
if (GetInputMethod())
@@ -1909,12 +1914,8 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
}
if (cursor_changed) {
- UpdateCursorView();
- cursor_view_.SetVisible(ShouldShowCursor());
- if (ShouldBlinkCursor())
- StartBlinkingCursor();
- else
- StopBlinkingCursor();
+ UpdateCursorViewPosition();
+ UpdateCursorVisibility();
NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true);
}
if (text_changed || cursor_changed) {
@@ -1923,7 +1924,15 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
}
}
-void Textfield::UpdateCursorView() {
+void Textfield::UpdateCursorVisibility() {
+ cursor_view_.SetVisible(ShouldShowCursor());
+ if (ShouldBlinkCursor())
+ StartBlinkingCursor();
+ else
+ StopBlinkingCursor();
+}
+
+void Textfield::UpdateCursorViewPosition() {
gfx::Rect location(GetRenderText()->GetUpdatedCursorBounds());
location.set_x(GetMirroredXForRect(location));
cursor_view_.SetBoundsRect(location);
@@ -2088,7 +2097,7 @@ void Textfield::StopBlinkingCursor() {
void Textfield::OnCursorBlinkTimerFired() {
DCHECK(ShouldBlinkCursor());
cursor_view_.SetVisible(!cursor_view_.visible());
- UpdateCursorView();
+ UpdateCursorViewPosition();
}
} // namespace views
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/controls/textfield/textfield_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698