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

Side by Side Diff: chrome/renderer/autofill/form_autofill_util.h

Issue 9225042: Fix Autofill hang when interacting with large forms (i.e. forms containing many fields). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test failure -- don't count hidden fields Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ 5 #ifndef CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_
6 #define CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ 6 #define CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 26 matching lines...) Expand all
37 EXTRACT_VALUE = 1 << 0, // Extract value from WebFormControlElement. 37 EXTRACT_VALUE = 1 << 0, // Extract value from WebFormControlElement.
38 EXTRACT_OPTION_TEXT = 1 << 1, // Extract option text from 38 EXTRACT_OPTION_TEXT = 1 << 1, // Extract option text from
39 // WebFormSelectElement. Only valid when 39 // WebFormSelectElement. Only valid when
40 // |EXTRACT_VALUE| is set. 40 // |EXTRACT_VALUE| is set.
41 // This is used for form submission where 41 // This is used for form submission where
42 // human readable value is captured. 42 // human readable value is captured.
43 EXTRACT_OPTIONS = 1 << 2, // Extract options from 43 EXTRACT_OPTIONS = 1 << 2, // Extract options from
44 // WebFormControlElement. 44 // WebFormControlElement.
45 }; 45 };
46 46
47 // The maximum number of form fields we are willing to parse, due to
48 // computational costs. Several examples of forms with lots of fields that are
49 // not relevant to Autofill: (1) the Netflix queue; (2) the Amazon wishlist;
50 // (3) router configuration pages; and (4) other configuration pages, e.g. for
51 // Google code project settings.
52 extern const size_t kMaxParseableFields;
53
47 // Returns true if |element| is a text input element. 54 // Returns true if |element| is a text input element.
48 bool IsTextInput(const WebKit::WebInputElement* element); 55 bool IsTextInput(const WebKit::WebInputElement* element);
49 56
50 // Returns true if |element| is a select element. 57 // Returns true if |element| is a select element.
51 bool IsSelectElement(const WebKit::WebFormControlElement& element); 58 bool IsSelectElement(const WebKit::WebFormControlElement& element);
52 59
53 // Returns the form's |name| attribute if non-empty; otherwise the form's |id| 60 // Returns the form's |name| attribute if non-empty; otherwise the form's |id|
54 // attribute. 61 // attribute.
55 const string16 GetFormIdentifier(const WebKit::WebFormElement& form); 62 const string16 GetFormIdentifier(const WebKit::WebFormElement& form);
56 63
57 // Fills |autofillable_elements| with all the auto-fillable form control 64 // Fills |autofillable_elements| with all the auto-fillable form control
58 // elements in |form_element|. 65 // elements in |form_element|.
59 void ExtractAutofillableElements( 66 void ExtractAutofillableElements(
60 const WebKit::WebFormElement& form_element, 67 const WebKit::WebFormElement& form_element,
61 RequirementsMask requirements, 68 RequirementsMask requirements,
62 std::vector<WebKit::WebFormControlElement>* autofillable_elements); 69 std::vector<WebKit::WebFormControlElement>* autofillable_elements);
63 70
64 // Fills out a FormField object from a given WebFormControlElement. 71 // Fills out a FormField object from a given WebFormControlElement.
65 // |extract_mask|: See the enum ExtractMask above for details. 72 // |extract_mask|: See the enum ExtractMask above for details.
66 void WebFormControlElementToFormField( 73 void WebFormControlElementToFormField(
67 const WebKit::WebFormControlElement& element, 74 const WebKit::WebFormControlElement& element,
68 ExtractMask extract_mask, 75 ExtractMask extract_mask,
69 webkit::forms::FormField* field); 76 webkit::forms::FormField* field);
70 77
71 // Fills |form| with the FormData object corresponding to the |form_element|. 78 // Fills |form| with the FormData object corresponding to the |form_element|.
72 // If |field| is non-NULL, also fills |field| with the FormField object 79 // If |field| is non-NULL, also fills |field| with the FormField object
73 // corresponding to the |form_control_element|. 80 // corresponding to the |form_control_element|.
74 // |extract_mask| controls what data is extracted. 81 // |extract_mask| controls what data is extracted.
75 // Returns true if |form| is filled out; it's possible that the |form_element| 82 // Returns true if |form| is filled out; it's possible that the |form_element|
76 // won't meet the |requirements|. Also returns false if there are no fields 83 // won't meet the |requirements|. Also returns false if there are no fields or
77 // in the |form|. 84 // too many fields in the |form|.
78 bool WebFormElementToFormData( 85 bool WebFormElementToFormData(
79 const WebKit::WebFormElement& form_element, 86 const WebKit::WebFormElement& form_element,
80 const WebKit::WebFormControlElement& form_control_element, 87 const WebKit::WebFormControlElement& form_control_element,
81 RequirementsMask requirements, 88 RequirementsMask requirements,
82 ExtractMask extract_mask, 89 ExtractMask extract_mask,
83 webkit::forms::FormData* form, 90 webkit::forms::FormData* form,
84 webkit::forms::FormField* field); 91 webkit::forms::FormField* field);
85 92
86 // Finds the form that contains |element| and returns it in |form|. Fills 93 // Finds the form that contains |element| and returns it in |form|. Fills
87 // |field| with the |FormField| representation for element. 94 // |field| with the |FormField| representation for element.
88 // Returns false if the form is not found. 95 // Returns false if the form is not found or cannot be serialized.
89 bool FindFormAndFieldForInputElement(const WebKit::WebInputElement& element, 96 bool FindFormAndFieldForInputElement(const WebKit::WebInputElement& element,
90 webkit::forms::FormData* form, 97 webkit::forms::FormData* form,
91 webkit::forms::FormField* field, 98 webkit::forms::FormField* field,
92 RequirementsMask requirements); 99 RequirementsMask requirements);
93 100
94 // Fills the form represented by |form|. |element| is the input element that 101 // Fills the form represented by |form|. |element| is the input element that
95 // initiated the auto-fill process. 102 // initiated the auto-fill process.
96 void FillForm(const webkit::forms::FormData& form, 103 void FillForm(const webkit::forms::FormData& form,
97 const WebKit::WebInputElement& element); 104 const WebKit::WebInputElement& element);
98 105
99 // Previews the form represented by |form|. |element| is the input element that 106 // Previews the form represented by |form|. |element| is the input element that
100 // initiated the preview process. 107 // initiated the preview process.
101 void PreviewForm(const webkit::forms::FormData& form, 108 void PreviewForm(const webkit::forms::FormData& form,
102 const WebKit::WebInputElement& element); 109 const WebKit::WebInputElement& element);
103 110
104 // Clears the placeholder values and the auto-filled background for any fields 111 // Clears the placeholder values and the auto-filled background for any fields
105 // in the form containing |node| that have been previewed. Resets the 112 // in the form containing |node| that have been previewed. Resets the
106 // autofilled state of |node| to |was_autofilled|. Returns false if the form is 113 // autofilled state of |node| to |was_autofilled|. Returns false if the form is
107 // not found. 114 // not found.
108 bool ClearPreviewedFormWithElement(const WebKit::WebInputElement& element, 115 bool ClearPreviewedFormWithElement(const WebKit::WebInputElement& element,
109 bool was_autofilled); 116 bool was_autofilled);
110 117
111 // Returns true if |form| has any auto-filled fields. 118 // Returns true if |form| has any auto-filled fields.
112 bool FormWithElementIsAutofilled(const WebKit::WebInputElement& element); 119 bool FormWithElementIsAutofilled(const WebKit::WebInputElement& element);
113 120
114 } // namespace autofill 121 } // namespace autofill
115 122
116 #endif // CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_ 123 #endif // CHROME_RENDERER_AUTOFILL_FORM_AUTOFILL_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/form_autofill_browsertest.cc ('k') | chrome/renderer/autofill/form_autofill_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698