| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 58 { | 58 { | 
| 59     String str(form->getAttribute(HTMLNames::accept_charsetAttr)); | 59     String str(form->getAttribute(HTMLNames::accept_charsetAttr)); | 
| 60     str.replace(',', ' '); | 60     str.replace(',', ' '); | 
| 61     Vector<String> charsets; | 61     Vector<String> charsets; | 
| 62     str.split(' ', charsets); | 62     str.split(' ', charsets); | 
| 63     for (Vector<String>::const_iterator i(charsets.begin()); i != charsets.end()
     ; ++i) { | 63     for (Vector<String>::const_iterator i(charsets.begin()); i != charsets.end()
     ; ++i) { | 
| 64         *encoding = WTF::TextEncoding(*i); | 64         *encoding = WTF::TextEncoding(*i); | 
| 65         if (encoding->isValid()) | 65         if (encoding->isValid()) | 
| 66             return; | 66             return; | 
| 67     } | 67     } | 
| 68     if (!form->document()->loader()) | 68     if (!form->document().loader()) | 
| 69          return; | 69          return; | 
| 70     *encoding = WTF::TextEncoding(form->document()->encoding()); | 70     *encoding = WTF::TextEncoding(form->document().encoding()); | 
| 71 } | 71 } | 
| 72 | 72 | 
| 73 // Returns true if the submit request results in an HTTP URL. | 73 // Returns true if the submit request results in an HTTP URL. | 
| 74 bool IsHTTPFormSubmit(const HTMLFormElement* form) | 74 bool IsHTTPFormSubmit(const HTMLFormElement* form) | 
| 75 { | 75 { | 
| 76     // FIXME: This function is insane. This is an overly complicated way to get 
     this information. | 76     // FIXME: This function is insane. This is an overly complicated way to get 
     this information. | 
| 77     String action(form->action()); | 77     String action(form->action()); | 
| 78     // The isNull() check is trying to avoid completeURL returning KURL() when p
     assed a null string. | 78     // The isNull() check is trying to avoid completeURL returning KURL() when p
     assed a null string. | 
| 79     return form->document()->completeURL(action.isNull() ? "" : action).protocol
     Is("http"); | 79     return form->document().completeURL(action.isNull() ? "" : action).protocolI
     s("http"); | 
| 80 } | 80 } | 
| 81 | 81 | 
| 82 // If the form does not have an activated submit button, the first submit | 82 // If the form does not have an activated submit button, the first submit | 
| 83 // button is returned. | 83 // button is returned. | 
| 84 HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form) | 84 HTMLFormControlElement* GetButtonToActivate(HTMLFormElement* form) | 
| 85 { | 85 { | 
| 86     HTMLFormControlElement* firstSubmitButton = 0; | 86     HTMLFormControlElement* firstSubmitButton = 0; | 
| 87     // FIXME: Consider refactoring this code so that we don't call form->associa
     tedElements() twice. | 87     // FIXME: Consider refactoring this code so that we don't call form->associa
     tedElements() twice. | 
| 88     for (Vector<FormAssociatedElement*>::const_iterator i(form->associatedElemen
     ts().begin()); i != form->associatedElements().end(); ++i) { | 88     for (Vector<FormAssociatedElement*>::const_iterator i(form->associatedElemen
     ts().begin()); i != form->associatedElements().end(); ++i) { | 
| 89         if (!(*i)->isFormControlElement()) | 89         if (!(*i)->isFormControlElement()) | 
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283     bool isValidSearchString = buildSearchString(formElement.get(), &encodedStri
     ng, &encoding, inputElement); | 283     bool isValidSearchString = buildSearchString(formElement.get(), &encodedStri
     ng, &encoding, inputElement); | 
| 284 | 284 | 
| 285     if (firstSubmitButton) | 285     if (firstSubmitButton) | 
| 286         firstSubmitButton->setActivatedSubmit(false); | 286         firstSubmitButton->setActivatedSubmit(false); | 
| 287 | 287 | 
| 288     // Return if the search string is not valid. | 288     // Return if the search string is not valid. | 
| 289     if (!isValidSearchString) | 289     if (!isValidSearchString) | 
| 290         return; | 290         return; | 
| 291 | 291 | 
| 292     String action(formElement->action()); | 292     String action(formElement->action()); | 
| 293     KURL url(formElement->document()->completeURL(action.isNull() ? "" : action)
     ); | 293     KURL url(formElement->document().completeURL(action.isNull() ? "" : action))
     ; | 
| 294     RefPtr<FormData> formData = FormData::create(encodedString); | 294     RefPtr<FormData> formData = FormData::create(encodedString); | 
| 295     url.setQuery(formData->flattenToString()); | 295     url.setQuery(formData->flattenToString()); | 
| 296     m_url = url; | 296     m_url = url; | 
| 297     m_encoding = String(encoding.name()); | 297     m_encoding = String(encoding.name()); | 
| 298 } | 298 } | 
| 299 | 299 | 
| 300 } // namespace WebKit | 300 } // namespace WebKit | 
| OLD | NEW | 
|---|