Commit 125aefdd authored by Michael Bai's avatar Michael Bai Committed by Commit Bot

WV Autofill: Use latest datalist suggestion

Previously, the internal class which extends AutofillPopup uses a copy
of suggestions when it is created, the copy one won't be changed
when suggestions changed.

This patch adds the suggestion array as data member, so the internal
class will always refer the latest suggestions.

Bug: 949555, 1136585
Test: verified manually
Change-Id: I4f300be648af4038c7b26f115161d8e56b9575b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462336Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Michael Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815716}
parent 77b47e47
......@@ -262,6 +262,7 @@ public class AutofillProvider {
private long mAutofillTriggeredTimeMillis;
private Context mContext;
private AutofillPopup mDatalistPopup;
private AutofillSuggestion[] mDatalistSuggestions;
private WebContentsAccessibility mWebContentsAccessibility;
private View mAnchorView;
......@@ -533,6 +534,7 @@ public class AutofillProvider {
if (mDatalistPopup != null) {
mDatalistPopup.dismiss();
mDatalistPopup = null;
mDatalistSuggestions = null;
}
if (mWebContentsAccessibility != null) {
mWebContentsAccessibility.onAutofillPopupDismissed();
......@@ -600,9 +602,9 @@ public class AutofillProvider {
*/
private void showDatalistPopup(
String[] datalistValues, String[] datalistLabels, RectF bounds, boolean isRtl) {
final AutofillSuggestion[] suggestions = new AutofillSuggestion[datalistValues.length];
for (int i = 0; i < suggestions.length; i++) {
suggestions[i] = new AutofillSuggestion(datalistValues[i], datalistLabels[i],
mDatalistSuggestions = new AutofillSuggestion[datalistValues.length];
for (int i = 0; i < mDatalistSuggestions.length; i++) {
mDatalistSuggestions[i] = new AutofillSuggestion(datalistValues[i], datalistLabels[i],
/* itemTag= */ "", DropdownItem.NO_ICON, false /* isIconAtLeft */, i,
false /* isDeletable */, false /* isMultilineLabel */, false /* isBoldLabel */);
}
......@@ -623,7 +625,7 @@ public class AutofillProvider {
@Override
public void suggestionSelected(int listIndex) {
onSuggestionSelected(suggestions[listIndex].getLabel());
onSuggestionSelected(mDatalistSuggestions[listIndex].getLabel());
}
@Override
......@@ -641,7 +643,7 @@ public class AutofillProvider {
return;
}
}
mDatalistPopup.filterAndShow(suggestions, isRtl, false);
mDatalistPopup.filterAndShow(mDatalistSuggestions, isRtl, false);
if (mWebContentsAccessibility != null) {
mWebContentsAccessibility.onAutofillPopupDisplayed(mDatalistPopup.getListView());
}
......
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