diff options
author | hayato@chromium.org <hayato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 09:34:50 +0000 |
---|---|---|
committer | hayato@chromium.org <hayato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-31 09:34:50 +0000 |
commit | e6efd025246dc04f22ee0f62a25e1259ab95512e (patch) | |
tree | a7bee5e86797af0826bf2cbda24070526ef33b60 /chrome/renderer/form_manager.cc | |
parent | 5c43b97cfe76c02c88900a4c68326adac842b7be (diff) | |
download | chromium_src-e6efd025246dc04f22ee0f62a25e1259ab95512e.zip chromium_src-e6efd025246dc04f22ee0f62a25e1259ab95512e.tar.gz chromium_src-e6efd025246dc04f22ee0f62a25e1259ab95512e.tar.bz2 |
Page Cycler Intl2 perf regression.
Revert 43181 - AutoFill: Send the forms cached in the FormManager to the AutoFillManager on
page load instead of duplicating this parsing in RenderView.
BUG=38325
TEST=none
Review URL: http://codereview.chromium.org/1530011
TBR=jhawkins@chromium.org
Review URL: http://codereview.chromium.org/1540008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/form_manager.cc')
-rw-r--r-- | chrome/renderer/form_manager.cc | 114 |
1 files changed, 22 insertions, 92 deletions
diff --git a/chrome/renderer/form_manager.cc b/chrome/renderer/form_manager.cc index 4377b1b..5413963 100644 --- a/chrome/renderer/form_manager.cc +++ b/chrome/renderer/form_manager.cc @@ -32,7 +32,6 @@ using WebKit::WebString; using WebKit::WebVector; using webkit_glue::FormData; using webkit_glue::FormField; -using webkit_glue::FormFieldValues; FormManager::FormManager() { } @@ -41,9 +40,7 @@ FormManager::~FormManager() { Reset(); } -void FormManager::ExtractForms(const WebFrame* frame) { - DCHECK(frame); - +void FormManager::ExtractForms(WebFrame* frame) { // Reset the vector of FormElements for this frame. ResetFrame(frame); @@ -71,12 +68,10 @@ void FormManager::ExtractForms(const WebFrame* frame) { void FormManager::GetForms(std::vector<FormData>* forms, RequirementsMask requirements) { - DCHECK(forms); - // Frame loop. for (WebFrameFormElementMap::iterator iter = form_elements_map_.begin(); iter != form_elements_map_.end(); ++iter) { - const WebFrame* frame = iter->first; + WebFrame* frame = iter->first; // Form loop. for (std::vector<FormElement*>::iterator form_iter = iter->second.begin(); @@ -94,40 +89,12 @@ void FormManager::GetForms(std::vector<FormData>* forms, } } -void FormManager::GetFormsInFrame(const WebFrame* frame, - RequirementsMask requirements, - std::vector<FormData>* forms) { - DCHECK(frame); - DCHECK(forms); - - WebFrameFormElementMap::iterator iter = form_elements_map_.find(frame); - if (iter == form_elements_map_.end()) - return; - - const std::vector<FormElement*>& form_elements = iter->second; - for (std::vector<FormElement*>::const_iterator form_iter = - form_elements.begin(); - form_iter != form_elements.end(); ++form_iter) { - FormElement* form_element = *form_iter; - - if (requirements & REQUIRE_AUTOCOMPLETE && - !form_element->form_element.autoComplete()) - continue; - - FormData form; - FormElementToFormData(frame, form_element, requirements, &form); - forms->push_back(form); - } -} - bool FormManager::FindForm(const WebFormControlElement& element, FormData* form) { - DCHECK(form); - // Frame loop. for (WebFrameFormElementMap::iterator iter = form_elements_map_.begin(); iter != form_elements_map_.end(); ++iter) { - const WebFrame* frame = iter->first; + WebFrame* frame = iter->first; // Form loop. for (std::vector<FormElement*>::iterator form_iter = iter->second.begin(); @@ -206,54 +173,7 @@ void FormManager::Reset() { form_elements_map_.clear(); } -// static -void FormManager::FormDataToFormFieldValues( - const std::vector<FormData>& forms, - std::vector<FormFieldValues>* form_field_values) { - DCHECK(form_field_values); - - for (std::vector<FormData>::const_iterator iter = forms.begin(); - iter != forms.end(); ++iter) { - FormFieldValues form; - form.form_name = iter->name; - // TODO(jhawkins): Store the method in FormData. - form.method = ASCIIToUTF16("post"); - form.source_url = iter->origin; - form.target_url = iter->action; - form.elements = iter->fields; - form_field_values->push_back(form); - } -} - -// static -void FormManager::WebFormControlElementToFormField( - const WebFormControlElement& element, - webkit_glue::FormField* field) { - DCHECK(field); - field->set_label(LabelForElement(element)); - field->set_name(element.nameForAutofill()); - field->set_form_control_type(element.formControlType()); - - // TODO(jhawkins): In WebKit, move value() and setValue() to - // WebFormControlElement. - string16 value; - if (element.formControlType() == ASCIIToUTF16("text")) { - const WebInputElement& input_element = - element.toConstElement<WebInputElement>(); - value = input_element.value(); - } else if (element.formControlType() == ASCIIToUTF16("select-one")) { - // TODO(jhawkins): This is ugly. WebSelectElement::value() is a non-const - // method. Look into fixing this on the WebKit side. - WebFormControlElement& e = const_cast<WebFormControlElement&>(element); - WebSelectElement select_element = e.toElement<WebSelectElement>(); - value = select_element.value(); - } - field->set_value(value); -} - -void FormManager::ResetFrame(const WebFrame* frame) { - DCHECK(frame); - +void FormManager::ResetFrame(WebFrame* frame) { WebFrameFormElementMap::iterator iter = form_elements_map_.find(frame); if (iter != form_elements_map_.end()) { STLDeleteElements(&iter->second); @@ -261,14 +181,10 @@ void FormManager::ResetFrame(const WebFrame* frame) { } } -void FormManager::FormElementToFormData(const WebFrame* frame, +void FormManager::FormElementToFormData(WebFrame* frame, const FormElement* form_element, RequirementsMask requirements, FormData* form) { - DCHECK(frame); - DCHECK(form_element); - DCHECK(form); - form->name = form_element->form_element.name(); form->origin = frame->url(); form->action = frame->completeURL(form_element->form_element.action()); @@ -295,9 +211,23 @@ void FormManager::FormElementToFormData(const WebFrame* frame, if (requirements & REQUIRE_ELEMENTS_ENABLED && !control_element.isEnabled()) continue; - FormField field; - WebFormControlElementToFormField(control_element, &field); - form->fields.push_back(field); + string16 label = LabelForElement(control_element); + string16 name = control_element.nameForAutofill(); + + string16 value; + if (control_element.formControlType() == ASCIIToUTF16("text")) { + const WebInputElement& input_element = + control_element.toConstElement<WebInputElement>(); + value = input_element.value(); + } else if (control_element.formControlType() == + ASCIIToUTF16("select-one")) { + WebSelectElement select_element = + control_element.toElement<WebSelectElement>(); + value = select_element.value(); + } + + string16 form_control_type = control_element.formControlType(); + form->fields.push_back(FormField(label, name, value, form_control_type)); } } |