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

Side by Side Diff: chrome/renderer/form_manager.cc

Issue 5137004: Autofill: Prefer maxLength to size attribute for form filling heuristics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Denitting Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/render_messages.cc ('k') | chrome/renderer/form_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/form_manager.h" 5 #include "chrome/renderer/form_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/scoped_vector.h" 8 #include "base/scoped_vector.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 if (extract_mask & EXTRACT_OPTIONS) { 304 if (extract_mask & EXTRACT_OPTIONS) {
305 // Set option strings on the field if available. 305 // Set option strings on the field if available.
306 std::vector<string16> option_strings; 306 std::vector<string16> option_strings;
307 GetOptionStringsFromElement(element, &option_strings); 307 GetOptionStringsFromElement(element, &option_strings);
308 field->set_option_strings(option_strings); 308 field->set_option_strings(option_strings);
309 } 309 }
310 310
311 if (element.formControlType() == WebString::fromUTF8("text")) { 311 if (element.formControlType() == WebString::fromUTF8("text")) {
312 const WebInputElement& input_element = element.toConst<WebInputElement>(); 312 const WebInputElement& input_element = element.toConst<WebInputElement>();
313 field->set_size(input_element.size()); 313 field->set_max_length(input_element.maxLength());
314 } 314 }
315 315
316 if (!(extract_mask & EXTRACT_VALUE)) 316 if (!(extract_mask & EXTRACT_VALUE))
317 return; 317 return;
318 318
319 // TODO(jhawkins): In WebKit, move value() and setValue() to 319 // TODO(jhawkins): In WebKit, move value() and setValue() to
320 // WebFormControlElement. 320 // WebFormControlElement.
321 string16 value; 321 string16 value;
322 if (element.formControlType() == WebString::fromUTF8("text") || 322 if (element.formControlType() == WebString::fromUTF8("text") ||
323 element.formControlType() == WebString::fromUTF8("hidden")) { 323 element.formControlType() == WebString::fromUTF8("hidden")) {
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 WebInputElement input_element = field->to<WebInputElement>(); 908 WebInputElement input_element = field->to<WebInputElement>();
909 909
910 // If the maxlength attribute contains a negative value, maxLength() 910 // If the maxlength attribute contains a negative value, maxLength()
911 // returns the default maxlength value. 911 // returns the default maxlength value.
912 input_element.setSuggestedValue( 912 input_element.setSuggestedValue(
913 data->value().substr(0, input_element.maxLength())); 913 data->value().substr(0, input_element.maxLength()));
914 input_element.setAutofilled(true); 914 input_element.setAutofilled(true);
915 if (is_initiating_node) 915 if (is_initiating_node)
916 input_element.setSelectionRange(0, input_element.suggestedValue().length()); 916 input_element.setSelectionRange(0, input_element.suggestedValue().length());
917 } 917 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages.cc ('k') | chrome/renderer/form_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698