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

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 734983006: Autofill - Fix Harry and David checkout: ignore role="presentation" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/form_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 949
950 return ExtractAutofillableElementsFromSet(control_elements, requirements); 950 return ExtractAutofillableElementsFromSet(control_elements, requirements);
951 } 951 }
952 952
953 void WebFormControlElementToFormField(const WebFormControlElement& element, 953 void WebFormControlElementToFormField(const WebFormControlElement& element,
954 ExtractMask extract_mask, 954 ExtractMask extract_mask,
955 FormFieldData* field) { 955 FormFieldData* field) {
956 DCHECK(field); 956 DCHECK(field);
957 DCHECK(!element.isNull()); 957 DCHECK(!element.isNull());
958 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete")); 958 CR_DEFINE_STATIC_LOCAL(WebString, kAutocomplete, ("autocomplete"));
959 CR_DEFINE_STATIC_LOCAL(WebString, kRole, ("role"));
959 960
960 // The label is not officially part of a WebFormControlElement; however, the 961 // The label is not officially part of a WebFormControlElement; however, the
961 // labels for all form control elements are scraped from the DOM and set in 962 // labels for all form control elements are scraped from the DOM and set in
962 // WebFormElementToFormData. 963 // WebFormElementToFormData.
963 field->name = element.nameForAutofill(); 964 field->name = element.nameForAutofill();
964 field->form_control_type = base::UTF16ToUTF8(element.formControlType()); 965 field->form_control_type = base::UTF16ToUTF8(element.formControlType());
965 field->autocomplete_attribute = 966 field->autocomplete_attribute =
966 base::UTF16ToUTF8(element.getAttribute(kAutocomplete)); 967 base::UTF16ToUTF8(element.getAttribute(kAutocomplete));
967 if (field->autocomplete_attribute.size() > kMaxDataLength) { 968 if (field->autocomplete_attribute.size() > kMaxDataLength) {
968 // Discard overly long attribute values to avoid DOS-ing the browser 969 // Discard overly long attribute values to avoid DOS-ing the browser
969 // process. However, send over a default string to indicate that the 970 // process. However, send over a default string to indicate that the
970 // attribute was present. 971 // attribute was present.
971 field->autocomplete_attribute = "x-max-data-length-exceeded"; 972 field->autocomplete_attribute = "x-max-data-length-exceeded";
972 } 973 }
974 if (LowerCaseEqualsASCII(element.getAttribute(kRole), "presentation"))
975 field->role = FormFieldData::ROLE_ATTRIBUTE_PRESENTATION;
973 976
974 if (!IsAutofillableElement(element)) 977 if (!IsAutofillableElement(element))
975 return; 978 return;
976 979
977 const WebInputElement* input_element = toWebInputElement(&element); 980 const WebInputElement* input_element = toWebInputElement(&element);
978 if (IsAutofillableInputElement(input_element) || 981 if (IsAutofillableInputElement(input_element) ||
979 IsTextAreaElement(element)) { 982 IsTextAreaElement(element)) {
980 field->is_autofilled = element.isAutofilled(); 983 field->is_autofilled = element.isAutofilled();
981 field->is_focusable = element.isFocusable(); 984 field->is_focusable = element.isFocusable();
982 field->should_autocomplete = element.autoComplete(); 985 field->should_autocomplete = element.autoComplete();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 1268
1266 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { 1269 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) {
1267 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1270 gfx::Rect bounding_box(element->boundsInViewportSpace());
1268 return gfx::RectF(bounding_box.x() * scale, 1271 return gfx::RectF(bounding_box.x() * scale,
1269 bounding_box.y() * scale, 1272 bounding_box.y() * scale,
1270 bounding_box.width() * scale, 1273 bounding_box.width() * scale,
1271 bounding_box.height() * scale); 1274 bounding_box.height() * scale);
1272 } 1275 }
1273 1276
1274 } // namespace autofill 1277 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/content/common/autofill_messages.h ('k') | components/autofill/core/browser/form_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698