Commit 9ccbec24 authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

Update cursor position when textfield text changes.

Bug: 789190
Change-Id: I1f1b2546d126ad35e27bd977e17b295477e10938
Reviewed-on: https://chromium-review.googlesource.com/795011
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521474}
parent 62fe5b7c
...@@ -115,7 +115,7 @@ LoginAuthUserView::LoginAuthUserView( ...@@ -115,7 +115,7 @@ LoginAuthUserView::LoginAuthUserView(
password_view_->UpdateForUser(user); password_view_->UpdateForUser(user);
pin_view_ = pin_view_ =
new LoginPinView(base::BindRepeating(&LoginPasswordView::AppendNumber, new LoginPinView(base::BindRepeating(&LoginPasswordView::InsertNumber,
base::Unretained(password_view_)), base::Unretained(password_view_)),
base::BindRepeating(&LoginPasswordView::Backspace, base::BindRepeating(&LoginPasswordView::Backspace,
base::Unretained(password_view_))); base::Unretained(password_view_)));
......
...@@ -482,11 +482,8 @@ void LoginPasswordView::Clear() { ...@@ -482,11 +482,8 @@ void LoginPasswordView::Clear() {
ContentsChanged(textfield_, textfield_->text()); ContentsChanged(textfield_, textfield_->text());
} }
void LoginPasswordView::AppendNumber(int value) { void LoginPasswordView::InsertNumber(int value) {
textfield_->SetText(textfield_->text() + base::IntToString16(value)); textfield_->InsertOrReplaceText(base::IntToString16(value));
// |ContentsChanged| won't be called by |Textfield| if the text is changed
// by |Textfield::AppendText()|.
ContentsChanged(textfield_, textfield_->text());
} }
void LoginPasswordView::Backspace() { void LoginPasswordView::Backspace() {
......
...@@ -89,8 +89,9 @@ class ASH_EXPORT LoginPasswordView ...@@ -89,8 +89,9 @@ class ASH_EXPORT LoginPasswordView
// Clear all currently entered text. // Clear all currently entered text.
void Clear(); void Clear();
// Add the given numeric value to the textfield. // Inserts the given numeric value to the textfield at the current cursor
void AppendNumber(int value); // position (most likely the end).
void InsertNumber(int value);
// Erase the last entered value. // Erase the last entered value.
void Backspace(); void Backspace();
......
...@@ -78,6 +78,9 @@ class AXTreeSourceAuraTest : public ash::AshTestBase { ...@@ -78,6 +78,9 @@ class AXTreeSourceAuraTest : public ash::AshTestBase {
}; };
TEST_F(AXTreeSourceAuraTest, Accessors) { TEST_F(AXTreeSourceAuraTest, Accessors) {
// Focus the textfield so the cursor does not disappear.
textfield_->RequestFocus();
AXTreeSourceAura ax_tree; AXTreeSourceAura ax_tree;
ASSERT_TRUE(ax_tree.GetRoot()); ASSERT_TRUE(ax_tree.GetRoot());
......
...@@ -342,6 +342,8 @@ void Textfield::SetTextInputFlags(int flags) { ...@@ -342,6 +342,8 @@ void Textfield::SetTextInputFlags(int flags) {
void Textfield::SetText(const base::string16& new_text) { void Textfield::SetText(const base::string16& new_text) {
model_->SetText(new_text); model_->SetText(new_text);
OnCaretBoundsChanged(); OnCaretBoundsChanged();
UpdateCursorViewPosition();
UpdateCursorVisibility();
SchedulePaint(); SchedulePaint();
NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment