Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Autofill: Port r307337 to iOS.
Browse files Browse the repository at this point in the history
https://crrev.com/307337: ignore role="presentation"

BUG=427614

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

Cr-Commit-Position: refs/heads/master@{#347274}
  • Loading branch information
leizleiz authored and Commit bot committed Sep 3, 2015
1 parent 2ea8c27 commit 4155f5f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions components/autofill/core/common/form_field_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace autofill {

// Stores information about a field in a form.
struct FormFieldData {
// Copied to components/autofill/ios/browser/resources/autofill_controller.js.
enum RoleAttribute {
// "presentation"
ROLE_ATTRIBUTE_PRESENTATION,
Expand Down
31 changes: 25 additions & 6 deletions components/autofill/ios/browser/resources/autofill_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ var FormControlElement;
/**
* @typedef {{
* name: string,
* value: string,
* form_control_type: string,
* autocomplete_attributes: string,
* is_autofilled: boolean,
* should_autocomplete: boolean,
* max_length: number,
* is_autofilled: boolean,
* is_checkable: boolean,
* value: string
* is_focusable: boolean,
* should_autocomplete: boolean,
* role: number,
* option_contents: Array<string>,
* option_values: Array<string>
* }}
*/
var AutofillFormFieldData;
Expand Down Expand Up @@ -115,6 +119,16 @@ __gCrWeb.autofill.EXTRACT_MASK_OPTION_TEXT = 1 << 1;
*/
__gCrWeb.autofill.EXTRACT_MASK_OPTIONS = 1 << 2;

/**
* A value for the "presentation" role.
*
* This variable is from enum RoleAttribute in
* chromium/src/components/autofill/core/common/form_field_data.h
*
* @const {number}
*/
__gCrWeb.autofill.ROLE_ATTRIBUTE_PRESENTATION = 0;

/**
* The last element that was autofilled.
*
Expand Down Expand Up @@ -1736,9 +1750,9 @@ __gCrWeb.autofill.webFormControlElementToFormField = function(
// form data.
field['name'] = __gCrWeb['common'].nameForAutofill(element);
field['form_control_type'] = element.type;
var attribute = element.getAttribute('autocomplete');
if (attribute) {
field['autocomplete_attribute'] = attribute;
var autocomplete_attribute = element.getAttribute('autocomplete');
if (autocomplete_attribute) {
field['autocomplete_attribute'] = autocomplete_attribute;
}
if (field['autocomplete_attribute'] != null &&
field['autocomplete_attribute'].length >
Expand All @@ -1749,6 +1763,11 @@ __gCrWeb.autofill.webFormControlElementToFormField = function(
field['autocomplete_attribute'] = 'x-max-data-length-exceeded';
}

var role_attribute = element.getAttribute('role');
if (role_attribute && role_attribute.toLowerCase() == 'presentation') {
field['role'] = __gCrWeb.autofill.ROLE_ATTRIBUTE_PRESENTATION;
}

if (!__gCrWeb.autofill.isAutofillableElement(element)) {
return;
}
Expand Down

0 comments on commit 4155f5f

Please sign in to comment.