Commit d8dfe2fa authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Android: fix position of datalist popup after form moves

Bug: 1142600
Change-Id: Iebabca71d53c9cdc08cd0bfa50927b4bd4513d6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500547Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821267}
parent 30287be5
...@@ -86,8 +86,7 @@ void AutofillProviderAndroid::OnQueryFormFieldAutofill( ...@@ -86,8 +86,7 @@ void AutofillProviderAndroid::OnQueryFormFieldAutofill(
// Focus or field value change will also trigger the query, so it should be // Focus or field value change will also trigger the query, so it should be
// ignored if the form is same. // ignored if the form is same.
if (ShouldStartNewSession(handler, form)) MaybeStartNewSession(handler, form, field, bounding_box);
StartNewSession(handler, form, field, bounding_box);
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
...@@ -105,18 +104,24 @@ void AutofillProviderAndroid::OnQueryFormFieldAutofill( ...@@ -105,18 +104,24 @@ void AutofillProviderAndroid::OnQueryFormFieldAutofill(
} }
} }
bool AutofillProviderAndroid::ShouldStartNewSession( void AutofillProviderAndroid::MaybeStartNewSession(
AutofillHandlerProxy* handler, AutofillHandlerProxy* handler,
const FormData& form) { const FormData& form,
// Only start a new session when form or handler is changed, the change of const FormFieldData& field,
// handler indicates query from other frame and a new session is needed. const gfx::RectF& bounding_box) {
return !IsCurrentlyLinkedForm(form) || !IsCurrentlyLinkedHandler(handler); // Don't start a new session when the new form is similar to the old form, the
} // new handler is the same as the current handler, and the coordinates of the
// relevant form field haven't changed.
if (form_ && form_->SimilarFormAs(form) &&
IsCurrentlyLinkedHandler(handler)) {
size_t index;
if (form_->GetFieldIndex(field, &index) &&
handler->driver()->TransformBoundingBoxToViewportCoordinates(
form.fields[index].bounds) == form_->form().fields[index].bounds) {
return;
}
}
void AutofillProviderAndroid::StartNewSession(AutofillHandlerProxy* handler,
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box) {
JNIEnv* env = AttachCurrentThread(); JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null()) if (obj.is_null())
...@@ -221,8 +226,7 @@ void AutofillProviderAndroid::OnSelectControlDidChange( ...@@ -221,8 +226,7 @@ void AutofillProviderAndroid::OnSelectControlDidChange(
const FormData& form, const FormData& form,
const FormFieldData& field, const FormFieldData& field,
const gfx::RectF& bounding_box) { const gfx::RectF& bounding_box) {
if (ShouldStartNewSession(handler, form)) MaybeStartNewSession(handler, form, field, bounding_box);
StartNewSession(handler, form, field, bounding_box);
FireFormFieldDidChanged(handler, form, field, bounding_box); FireFormFieldDidChanged(handler, form, field, bounding_box);
} }
......
...@@ -100,13 +100,12 @@ class AutofillProviderAndroid : public AutofillProvider { ...@@ -100,13 +100,12 @@ class AutofillProviderAndroid : public AutofillProvider {
gfx::RectF ToClientAreaBound(const gfx::RectF& bounding_box); gfx::RectF ToClientAreaBound(const gfx::RectF& bounding_box);
bool ShouldStartNewSession(AutofillHandlerProxy* handler, // Starts a new session, but only if |form| or |handler| doesn't match the
const FormData& form); // current session.
void MaybeStartNewSession(AutofillHandlerProxy* handler,
void StartNewSession(AutofillHandlerProxy* handler, const FormData& form,
const FormData& form, const FormFieldData& field,
const FormFieldData& field, const gfx::RectF& bounding_box);
const gfx::RectF& bounding_box);
void Reset(); void Reset();
......
...@@ -54,7 +54,7 @@ class FormDataAndroid { ...@@ -54,7 +54,7 @@ class FormDataAndroid {
void ApplyHeuristicFieldType(const FormStructure& form); void ApplyHeuristicFieldType(const FormStructure& form);
const FormData& form_for_testing() { return form_; } const FormData& form() { return form_; }
private: private:
// Same as the form passed in from constructor, but FormFieldData's bounds is // Same as the form passed in from constructor, but FormFieldData's bounds is
......
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