[webkit-help] Question about how HTMLFormElement builds query string

Peter Fletcher peter.fletcher62 at gmail.com
Tue Feb 2 20:36:51 PST 2010


HI,

I have looked at the code of how HTMLFormElement builds query string when it
is submitted.
For each form control element it needs to build a query string of a key and
value pair.

I think the code which does it is (which i confirmed by stepped thru the
debugger):

My question is in the for loop before, why it only cares about Input Form
Element when building the form data? What happens to Select form element's
value?

void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool
lockHistory, FormSubmissionTrigger formSubmissionTrigger)
{
 //... omit
 Vector<pair<String, String> > formValues;

    for (unsigned i = 0; i < formElements.size(); ++i) {
        HTMLFormControlElement* control = formElements[i];

        // Question: Why it only checks for input form element???
        if (control->hasLocalName(inputTag)) {
            HTMLInputElement* input =
static_cast<HTMLInputElement*>(control);
            if (input->isTextField()) {
                formValues.append(pair<String, String>(input->name(),
input->value()));
                if (input->isSearchField())
                    input->addSearchResult();
            }
        }
        if (needButtonActivation) {
            if (control->isActivatedSubmit())
                needButtonActivation = false;
            else if (firstSuccessfulSubmitButton == 0 &&
control->isSuccessfulSubmitButton())
                firstSuccessfulSubmitButton = control;
        }
    }
 //... omit
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20100202/e93edf55/attachment.html>


More information about the webkit-help mailing list