OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 String action(form->action()); | 73 String action(form->action()); |
74 // The isNull() check is trying to avoid completeURL returning KURL() when p
assed a null string. | 74 // The isNull() check is trying to avoid completeURL returning KURL() when p
assed a null string. |
75 return form->document().completeURL(action.isNull() ? "" : action).protocolI
s("http"); | 75 return form->document().completeURL(action.isNull() ? "" : action).protocolI
s("http"); |
76 } | 76 } |
77 | 77 |
78 // If the form does not have an activated submit button, the first submit | 78 // If the form does not have an activated submit button, the first submit |
79 // button is returned. | 79 // button is returned. |
80 HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form) | 80 HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form) |
81 { | 81 { |
82 HTMLFormControlElement* firstSubmitButton = 0; | 82 HTMLFormControlElement* firstSubmitButton = 0; |
83 const Vector<FormAssociatedElement*>& element = form->associatedElements(); | 83 const FormAssociatedElement::List& element = form->associatedElements(); |
84 for (Vector<FormAssociatedElement*>::const_iterator i(element.begin()); i !=
element.end(); ++i) { | 84 for (FormAssociatedElement::List::const_iterator i(element.begin()); i != el
ement.end(); ++i) { |
85 if (!(*i)->isFormControlElement()) | 85 if (!(*i)->isFormControlElement()) |
86 continue; | 86 continue; |
87 HTMLFormControlElement* control = toHTMLFormControlElement(*i); | 87 HTMLFormControlElement* control = toHTMLFormControlElement(*i); |
88 if (control->isActivatedSubmit()) { | 88 if (control->isActivatedSubmit()) { |
89 // There's a button that is already activated for submit, return 0. | 89 // There's a button that is already activated for submit, return 0. |
90 return 0; | 90 return 0; |
91 } | 91 } |
92 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) | 92 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) |
93 firstSubmitButton = control; | 93 firstSubmitButton = control; |
94 } | 94 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 // Look for a suitable search text field in a given HTMLFormElement | 149 // Look for a suitable search text field in a given HTMLFormElement |
150 // Return nothing if one of those items are found: | 150 // Return nothing if one of those items are found: |
151 // - A text area field | 151 // - A text area field |
152 // - A file upload field | 152 // - A file upload field |
153 // - A Password field | 153 // - A Password field |
154 // - More than one text field | 154 // - More than one text field |
155 HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement* form) | 155 HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement* form) |
156 { | 156 { |
157 HTMLInputElement* textElement = 0; | 157 HTMLInputElement* textElement = 0; |
158 const Vector<FormAssociatedElement*>& element = form->associatedElements(); | 158 const FormAssociatedElement::List& element = form->associatedElements(); |
159 for (Vector<FormAssociatedElement*>::const_iterator i(element.begin()); i !=
element.end(); ++i) { | 159 for (FormAssociatedElement::List::const_iterator i(element.begin()); i != el
ement.end(); ++i) { |
160 if (!(*i)->isFormControlElement()) | 160 if (!(*i)->isFormControlElement()) |
161 continue; | 161 continue; |
162 | 162 |
163 HTMLFormControlElement* control = toHTMLFormControlElement(*i); | 163 HTMLFormControlElement* control = toHTMLFormControlElement(*i); |
164 | 164 |
165 if (control->isDisabledFormControl() || control->name().isNull()) | 165 if (control->isDisabledFormControl() || control->name().isNull()) |
166 continue; | 166 continue; |
167 | 167 |
168 if (!IsInDefaultState(control) || isHTMLTextAreaElement(*control)) | 168 if (!IsInDefaultState(control) || isHTMLTextAreaElement(*control)) |
169 return 0; | 169 return 0; |
(...skipping 21 matching lines...) Expand all Loading... |
191 // Build a search string based on a given HTMLFormElement and HTMLInputElement | 191 // Build a search string based on a given HTMLFormElement and HTMLInputElement |
192 // | 192 // |
193 // Search string output example from www.google.com: | 193 // Search string output example from www.google.com: |
194 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi
=&aql=&oq=" | 194 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi
=&aql=&oq=" |
195 // | 195 // |
196 // Return false if the provided HTMLInputElement is not found in the form | 196 // Return false if the provided HTMLInputElement is not found in the form |
197 bool buildSearchString(const HTMLFormElement* form, Vector<char>* encodedString,
WTF::TextEncoding* encoding, const HTMLInputElement* textElement) | 197 bool buildSearchString(const HTMLFormElement* form, Vector<char>* encodedString,
WTF::TextEncoding* encoding, const HTMLInputElement* textElement) |
198 { | 198 { |
199 bool isElementFound = false; | 199 bool isElementFound = false; |
200 | 200 |
201 Vector<FormAssociatedElement*> elements = form->associatedElements(); | 201 const FormAssociatedElement::List& elements = form->associatedElements(); |
202 for (Vector<FormAssociatedElement*>::const_iterator i(elements.begin()); i !
= elements.end(); ++i) { | 202 for (FormAssociatedElement::List::const_iterator i(elements.begin()); i != e
lements.end(); ++i) { |
203 if (!(*i)->isFormControlElement()) | 203 if (!(*i)->isFormControlElement()) |
204 continue; | 204 continue; |
205 | 205 |
206 HTMLFormControlElement* control = toHTMLFormControlElement(*i); | 206 HTMLFormControlElement* control = toHTMLFormControlElement(*i); |
207 | 207 |
208 if (control->isDisabledFormControl() || control->name().isNull()) | 208 if (control->isDisabledFormControl() || control->name().isNull()) |
209 continue; | 209 continue; |
210 | 210 |
211 FormDataList dataList(*encoding); | 211 FormDataList dataList(*encoding); |
212 if (!control->appendFormData(dataList, false)) | 212 if (!control->appendFormData(dataList, false)) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 String action(formElement->action()); | 285 String action(formElement->action()); |
286 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; | 286 KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
; |
287 RefPtr<FormData> formData = FormData::create(encodedString); | 287 RefPtr<FormData> formData = FormData::create(encodedString); |
288 url.setQuery(formData->flattenToString()); | 288 url.setQuery(formData->flattenToString()); |
289 m_url = url; | 289 m_url = url; |
290 m_encoding = String(encoding.name()); | 290 m_encoding = String(encoding.name()); |
291 } | 291 } |
292 | 292 |
293 } // namespace blink | 293 } // namespace blink |
OLD | NEW |