RESOLVED FIXED 40084
Introduce FormSubmission, the structure representing a form submission.
https://bugs.webkit.org/show_bug.cgi?id=40084
Summary Introduce FormSubmission, the structure representing a form submission.
Dimitri Glazkov (Google)
Reported 2010-06-02 14:36:11 PDT
Introduce FormSubmission, the structure representing a form submission.
Attachments
Patch (22.96 KB, patch)
2010-06-02 14:42 PDT, Dimitri Glazkov (Google)
no flags
Patch (21.72 KB, patch)
2010-06-14 15:54 PDT, Dimitri Glazkov (Google)
no flags
Patch (23.28 KB, patch)
2010-06-14 15:57 PDT, Dimitri Glazkov (Google)
no flags
Patch (23.48 KB, patch)
2010-06-14 16:09 PDT, Dimitri Glazkov (Google)
no flags
Actually working patch (23.59 KB, patch)
2010-06-15 14:51 PDT, Dimitri Glazkov (Google)
darin: review+
Dimitri Glazkov (Google)
Comment 1 2010-06-02 14:42:41 PDT
Adam Barth
Comment 2 2010-06-03 00:25:15 PDT
Did you mean to mark this for review?
Dimitri Glazkov (Google)
Comment 3 2010-06-03 07:22:49 PDT
(In reply to comment #2) > Did you mean to mark this for review? Not yet, it depends on bug 39430 to land first.
Dimitri Glazkov (Google)
Comment 4 2010-06-14 15:54:45 PDT
Dimitri Glazkov (Google)
Comment 5 2010-06-14 15:56:03 PDT
Comment on attachment 57705 [details] Patch Whoops, webkit-patch upload for some reason didn't like the ChangeLog.
Dimitri Glazkov (Google)
Comment 6 2010-06-14 15:57:53 PDT
Early Warning System Bot
Comment 7 2010-06-14 16:02:50 PDT
Dimitri Glazkov (Google)
Comment 8 2010-06-14 16:06:08 PDT
Comment on attachment 58721 [details] Patch Argh. More merge untangling.
Dimitri Glazkov (Google)
Comment 9 2010-06-14 16:09:47 PDT
WebKit Review Bot
Comment 10 2010-06-14 17:59:07 PDT
Dimitri Glazkov (Google)
Comment 11 2010-06-14 19:03:02 PDT
Comment on attachment 58723 [details] Patch :( I'll figure out what's wrong.
Dimitri Glazkov (Google)
Comment 12 2010-06-15 14:51:50 PDT
Created attachment 58823 [details] Actually working patch
Dimitri Glazkov (Google)
Comment 13 2010-06-15 14:53:40 PDT
This now works and doesn't regress anything. Chromium fails are because the EWS doesn't seem to refresh the project after applying the patch. Please take a look.
Darin Adler
Comment 14 2010-06-15 15:31:35 PDT
Comment on attachment 58823 [details] Actually working patch > for (unsigned i = 0; i < m_associatedElements.size(); ++i) { > HTMLFormControlElement* control = m_associatedElements[i]; > if (!control->disabled()) > control->appendFormData(*domFormData, m_formDataBuilder.isMultiPartForm()); > + 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(); > + } > + } > } This redundancy between form data and form values is so bizarre. I can't believe we have it. And for the form data we have a nice abstraction and virtual functions, but for the form values, none at all! We need to fix that. And the call to addSearchResult here is so random too! Anyway, not your fault, but nutty. > + FormSubmission::Method method = m_formDataBuilder.isPostMethod() ? FormSubmission::PostMethod : FormSubmission::GetMethod; > + return FormSubmission::create(method, m_url, m_target, m_formDataBuilder.encodingType(), FormState::create(this, formValues, document()->frame(), trigger), formData.release(), boundary, lockHistory, event); Even I, famous for long lines, would be tempted to break this into multiple lines. Maybe put the FormState into a local variable. It occurs to me that FormSubmission, FormData, and FormState are all too similar. Too bad, but might be worth thinking about. Do we need all three? Are they all easy to explain? > +FormSubmission::FormSubmission(Method method, const String& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event) I suggest marking this inline since it's called only in one place. > +{ > +} > + > + > +PassRefPtr<FormSubmission> FormSubmission::create(Method method, const String& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event) Extra blank line here. > +class FormSubmission : public RefCounted<FormSubmission> { Do we really need a reference counted object for this, and a class? Why not just use a struct, and pass const FormSubmission& to the function that takes it? I'm not sure that a class adds enough value here. > + enum Method { > + GetMethod, > + PostMethod > + }; I’d put this on a single line instead of breaking it across multiple lines. > + String action() const { return m_action; } > + String target() const { return m_target; } > + String contentType() const { return m_contentType; } > + String boundary() const { return m_boundary; } More efficient to return const String& from functions like these, and very little downside to doing so. r=me
Dimitri Glazkov (Google)
Comment 15 2010-06-15 15:52:39 PDT
(In reply to comment #14) > (From update of attachment 58823 [details]) > > for (unsigned i = 0; i < m_associatedElements.size(); ++i) { > > HTMLFormControlElement* control = m_associatedElements[i]; > > if (!control->disabled()) > > control->appendFormData(*domFormData, m_formDataBuilder.isMultiPartForm()); > > + 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(); > > + } > > + } > > } > > This redundancy between form data and form values is so bizarre. I can't believe we have it. And for the form data we have a nice abstraction and virtual functions, but for the form values, none at all! We need to fix that. I agree. That's my goal. > And the call to addSearchResult here is so random too! Anyway, not your fault, but nutty. > > > + FormSubmission::Method method = m_formDataBuilder.isPostMethod() ? FormSubmission::PostMethod : FormSubmission::GetMethod; > > + return FormSubmission::create(method, m_url, m_target, m_formDataBuilder.encodingType(), FormState::create(this, formValues, document()->frame(), trigger), formData.release(), boundary, lockHistory, event); > > Even I, famous for long lines, would be tempted to break this into multiple lines. Maybe put the FormState into a local variable. Sounds good. > > It occurs to me that FormSubmission, FormData, and FormState are all too similar. Too bad, but might be worth thinking about. Do we need all three? Are they all easy to explain? Out of the three, I want FormState to go away. It already name-conflicts with a completely separate concept of restoring form state (see Document::formElementsWithState, et al.). > > > +FormSubmission::FormSubmission(Method method, const String& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event) > > I suggest marking this inline since it's called only in one place. ok. > > +{ > > +} > > + > > + > > +PassRefPtr<FormSubmission> FormSubmission::create(Method method, const String& action, const String& target, const String& contentType, PassRefPtr<FormState> state, PassRefPtr<FormData> data, const String& boundary, bool lockHistory, PassRefPtr<Event> event) > > Extra blank line here. > > > +class FormSubmission : public RefCounted<FormSubmission> { > > Do we really need a reference counted object for this, and a class? Why not just use a struct, and pass const FormSubmission& to the function that takes it? I'm not sure that a class adds enough value here. I've been back and forth on it. So far, I don't see the need for it to be ref-counted -- the ownership flows forward-only, so yes, simpler the better. > > + enum Method { > > + GetMethod, > > + PostMethod > > + }; > > I’d put this on a single line instead of breaking it across multiple lines. ok. > > > + String action() const { return m_action; } > > + String target() const { return m_target; } > > + String contentType() const { return m_contentType; } > > > + String boundary() const { return m_boundary; } > > More efficient to return const String& from functions like these, and very little downside to doing so. ok. > > r=me Would it be ok for me to land this as-is and address the issues in a separate patch? I have two patches sitting on top of this and my last round of merge resolution was a b*tch :)
Darin Adler
Comment 16 2010-06-16 10:12:54 PDT
(In reply to comment #15) > Would it be ok for me to land this as-is and address the issues in a separate patch? I have two patches sitting on top of this and my last round of merge resolution was a b*tch :) Yes, it’s OK with me. If it wasn’t OK I would have said review-.
Dimitri Glazkov (Google)
Comment 17 2010-06-20 14:00:49 PDT
Note You need to log in before you can comment on or make changes to this bug.