Commit d9b040ba authored by ziran.sun's avatar ziran.sun Committed by Commit bot

[Autofill Clean up] Revert changes introduced by Autocheckout to autofill

disabled and readonly fields. Autocheckout is deprecated.

R=isherman@chromium.org
BUG=231160

Review URL: https://codereview.chromium.org/609733003

Cr-Commit-Position: refs/heads/master@{#297015}
parent 63800d59
...@@ -258,11 +258,6 @@ class FormAutofillTest : public ChromeRenderViewTest { ...@@ -258,11 +258,6 @@ class FormAutofillTest : public ChromeRenderViewTest {
EXPECT_EQ(field_case.should_be_autofilled, element.isAutofilled()); EXPECT_EQ(field_case.should_be_autofilled, element.isAutofilled());
} }
static void FillFormForAllFieldsWrapper(const FormData& form,
const WebInputElement& element) {
FillFormForAllElements(form, element.form());
}
static void FillFormIncludingNonFocusableElementsWrapper( static void FillFormIncludingNonFocusableElementsWrapper(
const FormData& form, const FormData& form,
const WebFormControlElement& element) { const WebFormControlElement& element) {
......
...@@ -54,17 +54,6 @@ using blink::WebVector; ...@@ -54,17 +54,6 @@ using blink::WebVector;
namespace autofill { namespace autofill {
namespace { namespace {
// A bit field mask for FillForm functions to not fill some fields.
enum FieldFilterMask {
FILTER_NONE = 0,
FILTER_DISABLED_ELEMENTS = 1 << 0,
FILTER_READONLY_ELEMENTS = 1 << 1,
FILTER_NON_FOCUSABLE_ELEMENTS = 1 << 2,
FILTER_ALL_NON_EDITIABLE_ELEMENTS = FILTER_DISABLED_ELEMENTS |
FILTER_READONLY_ELEMENTS |
FILTER_NON_FOCUSABLE_ELEMENTS,
};
bool IsOptionElement(const WebElement& element) { bool IsOptionElement(const WebElement& element) {
CR_DEFINE_STATIC_LOCAL(WebString, kOption, ("option")); CR_DEFINE_STATIC_LOCAL(WebString, kOption, ("option"));
return element.hasHTMLTagName(kOption); return element.hasHTMLTagName(kOption);
...@@ -476,7 +465,7 @@ typedef void (*Callback)(const FormFieldData&, ...@@ -476,7 +465,7 @@ typedef void (*Callback)(const FormFieldData&,
void ForEachMatchingFormField(const WebFormElement& form_element, void ForEachMatchingFormField(const WebFormElement& form_element,
const WebElement& initiating_element, const WebElement& initiating_element,
const FormData& data, const FormData& data,
FieldFilterMask filters, bool only_focusable_elements,
bool force_override, bool force_override,
Callback callback) { Callback callback) {
std::vector<WebFormControlElement> control_elements; std::vector<WebFormControlElement> control_elements;
...@@ -519,9 +508,8 @@ void ForEachMatchingFormField(const WebFormElement& form_element, ...@@ -519,9 +508,8 @@ void ForEachMatchingFormField(const WebFormElement& form_element,
!element->value().isEmpty())) !element->value().isEmpty()))
continue; continue;
if (((filters & FILTER_DISABLED_ELEMENTS) && !element->isEnabled()) || if (!element->isEnabled() || element->isReadOnly() ||
((filters & FILTER_READONLY_ELEMENTS) && element->isReadOnly()) || (only_focusable_elements && !element->isFocusable()))
((filters & FILTER_NON_FOCUSABLE_ELEMENTS) && !element->isFocusable()))
continue; continue;
callback(data.fields[i], is_initiating_element, element); callback(data.fields[i], is_initiating_element, element);
...@@ -1001,8 +989,8 @@ void FillForm(const FormData& form, const WebFormControlElement& element) { ...@@ -1001,8 +989,8 @@ void FillForm(const FormData& form, const WebFormControlElement& element) {
ForEachMatchingFormField(form_element, ForEachMatchingFormField(form_element,
element, element,
form, form,
FILTER_ALL_NON_EDITIABLE_ELEMENTS, true, /* only_focusable_elements */
false, /* dont force override */ false, /* don't force override */
&FillFormField); &FillFormField);
} }
...@@ -1011,25 +999,10 @@ void FillFormIncludingNonFocusableElements(const FormData& form_data, ...@@ -1011,25 +999,10 @@ void FillFormIncludingNonFocusableElements(const FormData& form_data,
if (form_element.isNull()) if (form_element.isNull())
return; return;
FieldFilterMask filter_mask = static_cast<FieldFilterMask>(
FILTER_DISABLED_ELEMENTS | FILTER_READONLY_ELEMENTS);
ForEachMatchingFormField(form_element,
WebInputElement(),
form_data,
filter_mask,
true, /* force override */
&FillFormField);
}
void FillFormForAllElements(const FormData& form_data,
const WebFormElement& form_element) {
if (form_element.isNull())
return;
ForEachMatchingFormField(form_element, ForEachMatchingFormField(form_element,
WebInputElement(), WebInputElement(),
form_data, form_data,
FILTER_NONE, false, /* only_focusable_elements */
true, /* force override */ true, /* force override */
&FillFormField); &FillFormField);
} }
...@@ -1042,7 +1015,7 @@ void PreviewForm(const FormData& form, const WebFormControlElement& element) { ...@@ -1042,7 +1015,7 @@ void PreviewForm(const FormData& form, const WebFormControlElement& element) {
ForEachMatchingFormField(form_element, ForEachMatchingFormField(form_element,
element, element,
form, form,
FILTER_ALL_NON_EDITIABLE_ELEMENTS, true, /* only_focusable_elements */
false, /* dont force override */ false, /* dont force override */
&PreviewFormField); &PreviewFormField);
} }
......
...@@ -133,12 +133,6 @@ void FillFormIncludingNonFocusableElements( ...@@ -133,12 +133,6 @@ void FillFormIncludingNonFocusableElements(
const FormData& form_data, const FormData& form_data,
const blink::WebFormElement& form_element); const blink::WebFormElement& form_element);
// Fills all (including disabled, read-only and non-focusable) form control
// elements within |form_element| with field data from |form_data|.
void FillFormForAllElements(
const FormData& form_data,
const blink::WebFormElement& form_element);
// Previews the form represented by |form|. |element| is the input element that // Previews the form represented by |form|. |element| is the input element that
// initiated the preview process. // initiated the preview process.
void PreviewForm(const FormData& form, void PreviewForm(const FormData& form,
......
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