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

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: fix spelling 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 fdfe19b095fc0cdb63d857ba800f0d88b509abf0..8414521dd258ccc1ec46ef855a242c5fc03b3fa8 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 {
@@ -982,7 +987,7 @@ void Textfield::OnPaint(gfx::Canvas* canvas) {
void Textfield::OnFocus() {
GetRenderText()->set_focused(true);
if (ShouldShowCursor()) {
- UpdateCursorView();
+ UpdateCursorViewPosition();
cursor_view_.SetVisible(true);
}
if (GetInputMethod())
@@ -1910,12 +1915,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) {
@@ -1924,7 +1925,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);
@@ -2089,7 +2098,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