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

Unified Diff: components/autofill/core/browser/form_structure.cc

Issue 932023003: Autofill: Do not split sections on fields used for presentation roles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « chrome/test/data/autofill/heuristics/output/bug_459132.out ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/form_structure.cc
diff --git a/components/autofill/core/browser/form_structure.cc b/components/autofill/core/browser/form_structure.cc
index c546a113f773d27526d2b39b799f41197ab6a5cc..002fc6277fe77bbc69f5d1e3693ca39dab405fc0 100644
--- a/components/autofill/core/browser/form_structure.cc
+++ b/components/autofill/core/browser/form_structure.cc
@@ -1208,8 +1208,11 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) {
if (AutofillType(current_type).group() == PHONE_HOME)
already_saw_current_type = false;
- // Ignore non-focusable field while inferring boundaries between sections.
- if (!field->is_focusable)
+ // Ignore non-focusable field and presentation role fields while inferring
+ // boundaries between sections.
+ bool ignored_field = !field->is_focusable ||
+ field->role == FormFieldData::ROLE_ATTRIBUTE_PRESENTATION;
+ if (ignored_field)
already_saw_current_type = false;
// Some forms have adjacent fields of the same type. Two common examples:
@@ -1224,20 +1227,23 @@ void FormStructure::IdentifySections(bool has_author_specified_sections) {
if (current_type == previous_type)
already_saw_current_type = false;
- previous_type = current_type;
-
if (current_type != UNKNOWN_TYPE && already_saw_current_type) {
// We reached the end of a section, so start a new section.
seen_types.clear();
current_section = field->unique_name();
}
- // Only consider a type "seen" if it was focusable. Some forms have
+ // Only consider a type "seen" if it was not ignored. Some forms have
// sections for different locales, only one of which is enabled at a
// time. Each section may duplicate some information (e.g. postal code)
// and we don't want that to cause section splits.
- if (field->is_focusable)
+ // Also only set |previous_type| when the field was not ignored. This
+ // prevents ignored fields from breaking up fields that are otherwise
+ // adjacent.
+ if (!ignored_field) {
seen_types.insert(current_type);
+ previous_type = current_type;
+ }
field->set_section(base::UTF16ToUTF8(current_section));
}
« no previous file with comments | « chrome/test/data/autofill/heuristics/output/bug_459132.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698