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

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: 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 | « no previous file | 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 // TODO(isherman): Add "524288" as a named constant to the WebKit API
dhollowa 2010/11/18 18:26:51 It looks to me like the use of |size| was misguide
Ilya Sherman 2010/11/19 02:33:44 Done.
314 if (input_element.hasAttribute(WebString::fromUTF8("maxLength")) &&
315 input_element.maxLength() != 524288)
316 field->set_size(input_element.maxLength());
317 else
318 field->set_size(input_element.size());
314 } 319 }
315 320
316 if (!(extract_mask & EXTRACT_VALUE)) 321 if (!(extract_mask & EXTRACT_VALUE))
317 return; 322 return;
318 323
319 // TODO(jhawkins): In WebKit, move value() and setValue() to 324 // TODO(jhawkins): In WebKit, move value() and setValue() to
320 // WebFormControlElement. 325 // WebFormControlElement.
321 string16 value; 326 string16 value;
322 if (element.formControlType() == WebString::fromUTF8("text") || 327 if (element.formControlType() == WebString::fromUTF8("text") ||
323 element.formControlType() == WebString::fromUTF8("hidden")) { 328 element.formControlType() == WebString::fromUTF8("hidden")) {
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 WebInputElement input_element = field->to<WebInputElement>(); 913 WebInputElement input_element = field->to<WebInputElement>();
909 914
910 // If the maxlength attribute contains a negative value, maxLength() 915 // If the maxlength attribute contains a negative value, maxLength()
911 // returns the default maxlength value. 916 // returns the default maxlength value.
912 input_element.setSuggestedValue( 917 input_element.setSuggestedValue(
913 data->value().substr(0, input_element.maxLength())); 918 data->value().substr(0, input_element.maxLength()));
914 input_element.setAutofilled(true); 919 input_element.setAutofilled(true);
915 if (is_initiating_node) 920 if (is_initiating_node)
916 input_element.setSelectionRange(0, input_element.suggestedValue().length()); 921 input_element.setSelectionRange(0, input_element.suggestedValue().length());
917 } 922 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/form_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698