| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 if (form.document().loader()) | 65 if (form.document().loader()) |
| 66 *encoding = WTF::TextEncoding(form.document().encoding()); | 66 *encoding = WTF::TextEncoding(form.document().encoding()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // If the form does not have an activated submit button, the first submit | 69 // If the form does not have an activated submit button, the first submit |
| 70 // button is returned. | 70 // button is returned. |
| 71 HTMLFormControlElement* buttonToActivate(const HTMLFormElement& form) { | 71 HTMLFormControlElement* buttonToActivate(const HTMLFormElement& form) { |
| 72 HTMLFormControlElement* firstSubmitButton = nullptr; | 72 HTMLFormControlElement* firstSubmitButton = nullptr; |
| 73 for (auto& element : form.associatedElements()) { | 73 for (auto& element : form.listedElements()) { |
| 74 if (!element->isFormControlElement()) | 74 if (!element->isFormControlElement()) |
| 75 continue; | 75 continue; |
| 76 HTMLFormControlElement* control = toHTMLFormControlElement(element); | 76 HTMLFormControlElement* control = toHTMLFormControlElement(element); |
| 77 if (control->isActivatedSubmit()) { | 77 if (control->isActivatedSubmit()) { |
| 78 // There's a button that is already activated for submit, return | 78 // There's a button that is already activated for submit, return |
| 79 // nullptr. | 79 // nullptr. |
| 80 return nullptr; | 80 return nullptr; |
| 81 } | 81 } |
| 82 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) | 82 if (!firstSubmitButton && control->isSuccessfulSubmitButton()) |
| 83 firstSubmitButton = control; | 83 firstSubmitButton = control; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 } | 131 } |
| 132 | 132 |
| 133 // Look for a suitable search text field in a given HTMLFormElement | 133 // Look for a suitable search text field in a given HTMLFormElement |
| 134 // Return nothing if one of those items are found: | 134 // Return nothing if one of those items are found: |
| 135 // - A text area field | 135 // - A text area field |
| 136 // - A file upload field | 136 // - A file upload field |
| 137 // - A Password field | 137 // - A Password field |
| 138 // - More than one text field | 138 // - More than one text field |
| 139 HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement& form) { | 139 HTMLInputElement* findSuitableSearchInputElement(const HTMLFormElement& form) { |
| 140 HTMLInputElement* textElement = nullptr; | 140 HTMLInputElement* textElement = nullptr; |
| 141 for (const auto& item : form.associatedElements()) { | 141 for (const auto& item : form.listedElements()) { |
| 142 if (!item->isFormControlElement()) | 142 if (!item->isFormControlElement()) |
| 143 continue; | 143 continue; |
| 144 | 144 |
| 145 HTMLFormControlElement& control = toHTMLFormControlElement(*item); | 145 HTMLFormControlElement& control = toHTMLFormControlElement(*item); |
| 146 | 146 |
| 147 if (control.isDisabledFormControl() || control.name().isNull()) | 147 if (control.isDisabledFormControl() || control.name().isNull()) |
| 148 continue; | 148 continue; |
| 149 | 149 |
| 150 if (!isInDefaultState(control) || isHTMLTextAreaElement(control)) | 150 if (!isInDefaultState(control) || isHTMLTextAreaElement(control)) |
| 151 return nullptr; | 151 return nullptr; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 177 // | 177 // |
| 178 // Search string output example from www.google.com: | 178 // Search string output example from www.google.com: |
| 179 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi
=&aql=&oq=" | 179 // "hl=en&source=hp&biw=1085&bih=854&q={searchTerms}&btnG=Google+Search&aq=f&aqi
=&aql=&oq=" |
| 180 // | 180 // |
| 181 // Return false if the provided HTMLInputElement is not found in the form | 181 // Return false if the provided HTMLInputElement is not found in the form |
| 182 bool buildSearchString(const HTMLFormElement& form, | 182 bool buildSearchString(const HTMLFormElement& form, |
| 183 Vector<char>* encodedString, | 183 Vector<char>* encodedString, |
| 184 const WTF::TextEncoding& encoding, | 184 const WTF::TextEncoding& encoding, |
| 185 const HTMLInputElement* textElement) { | 185 const HTMLInputElement* textElement) { |
| 186 bool isElementFound = false; | 186 bool isElementFound = false; |
| 187 for (const auto& item : form.associatedElements()) { | 187 for (const auto& item : form.listedElements()) { |
| 188 if (!item->isFormControlElement()) | 188 if (!item->isFormControlElement()) |
| 189 continue; | 189 continue; |
| 190 | 190 |
| 191 HTMLFormControlElement& control = toHTMLFormControlElement(*item); | 191 HTMLFormControlElement& control = toHTMLFormControlElement(*item); |
| 192 if (control.isDisabledFormControl() || control.name().isNull()) | 192 if (control.isDisabledFormControl() || control.name().isNull()) |
| 193 continue; | 193 continue; |
| 194 | 194 |
| 195 FormData* formData = FormData::create(encoding); | 195 FormData* formData = FormData::create(encoding); |
| 196 control.appendToFormData(*formData); | 196 control.appendToFormData(*formData); |
| 197 | 197 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 String action(formElement->action()); | 267 String action(formElement->action()); |
| 268 KURL url(formElement->document().completeURL(action.isNull() ? "" : action)); | 268 KURL url(formElement->document().completeURL(action.isNull() ? "" : action)); |
| 269 RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString); | 269 RefPtr<EncodedFormData> formData = EncodedFormData::create(encodedString); |
| 270 url.setQuery(formData->flattenToString()); | 270 url.setQuery(formData->flattenToString()); |
| 271 m_url = url; | 271 m_url = url; |
| 272 m_encoding = String(encoding.name()); | 272 m_encoding = String(encoding.name()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |