Changeset 35611 in webkit


Ignore:
Timestamp:
Aug 6, 2008 2:15:39 PM (16 years ago)
Author:
ddkilzer@apple.com
Message:

WebCore:

Bug 20038: REGRESSION (r35151): Can't post comments on flickr.com

<https://bugs.webkit.org/show_bug.cgi?id=20038>
<rdar://problem/6092270>

Reviewed by Eric Seidel.

Test: fast/forms/submit-to-url-fragment.html

The problem was that isFormSubmission was not being set to true in
FrameLoader::loadWithDocumentLoader() when we were actually
submitting a form, causing the page to scroll instead of the form to
be submitted.

The isFormSubmission variable wasn't set to true because a FormState
object was not being created in
FrameLoader::loadFrameRequestWithFormAndValues().

The FormState object was not being created because
HTMLFormElement::submit(Event*, bool activateSubmitButton) would
only set FrameLoader::m_formAboutToBeSubmitted to the current form
if there was a "text field" element in the form (type = text,
password, search or isindex).

Thus when FrameLoader::submitForm(const FrameLoadRequest&, Event*)
called FrameLoader::loadFrameRequestWithFormAndValues(), a null
HTMLFormElement pointer would be sent and cause the above failures.

  • html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::submit): Call new FrameLoader::setFormAboutToBeSubmitted() method outside the for loop so we always set FrameLoader::m_formAboutToBeSubmitted exactly once for any form submission. The FrameLoader::recordFormValue() method is only called with the name/value pair of each text field.
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::setFormAboutToBeSubmitted): Added method that only sets m_formAboutToBeSubmitted. (WebCore::FrameLoader::recordFormValue): Removed PassRefPtr<HTMLFormElement> argument since this method only sets name/value pairs on m_formValuesAboutToBeSubmitted now. (WebCore::FrameLoader::loadFrameRequestWithFormAndValues): Create a FormState object as long as submitForm is not null so that other FrameLoader methods know when a form is being submitted.
  • loader/FrameLoader.h:

LayoutTests:

Bug 20038: REGRESSION (r35151): Can't post comments on flickr.com

<https://bugs.webkit.org/show_bug.cgi?id=20038>
<rdar://problem/6092270>

Reviewed by Eric Seidel.

  • fast/forms/submit-to-url-fragment-expected.txt: Added.
  • fast/forms/submit-to-url-fragment.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r35606 r35611  
     12008-08-05  David D. Kilzer  <ddkilzer@apple.com>
     2
     3        Bug 20038: REGRESSION (r35151): Can't post comments on flickr.com
     4
     5        <https://bugs.webkit.org/show_bug.cgi?id=20038>
     6        <rdar://problem/6092270>
     7
     8        Reviewed by Eric Seidel.
     9
     10        * fast/forms/submit-to-url-fragment-expected.txt: Added.
     11        * fast/forms/submit-to-url-fragment.html: Added.
     12
    1132008-07-02  David Kilzer  <ddkilzer@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r35610 r35611  
     12008-08-05  David D. Kilzer  <ddkilzer@apple.com>
     2
     3        Bug 20038: REGRESSION (r35151): Can't post comments on flickr.com
     4
     5        <https://bugs.webkit.org/show_bug.cgi?id=20038>
     6        <rdar://problem/6092270>
     7
     8        Reviewed by Eric Seidel.
     9
     10        Test: fast/forms/submit-to-url-fragment.html
     11
     12        The problem was that isFormSubmission was not being set to true in
     13        FrameLoader::loadWithDocumentLoader() when we were actually
     14        submitting a form, causing the page to scroll instead of the form to
     15        be submitted.
     16
     17        The isFormSubmission variable wasn't set to true because a FormState
     18        object was not being created in
     19        FrameLoader::loadFrameRequestWithFormAndValues().
     20
     21        The FormState object was not being created because
     22        HTMLFormElement::submit(Event*, bool activateSubmitButton) would
     23        only set FrameLoader::m_formAboutToBeSubmitted to the current form
     24        if there was a "text field" element in the form (type = text,
     25        password, search or isindex).
     26
     27        Thus when FrameLoader::submitForm(const FrameLoadRequest&, Event*)
     28        called FrameLoader::loadFrameRequestWithFormAndValues(), a null
     29        HTMLFormElement pointer would be sent and cause the above failures.
     30
     31        * html/HTMLFormElement.cpp:
     32        (WebCore::HTMLFormElement::submit): Call new
     33        FrameLoader::setFormAboutToBeSubmitted() method outside the for
     34        loop so we always set FrameLoader::m_formAboutToBeSubmitted exactly
     35        once for any form submission.  The FrameLoader::recordFormValue()
     36        method is only called with the name/value pair of each text field.
     37
     38        * loader/FrameLoader.cpp:
     39        (WebCore::FrameLoader::setFormAboutToBeSubmitted): Added method that
     40        only sets m_formAboutToBeSubmitted.
     41        (WebCore::FrameLoader::recordFormValue): Removed
     42        PassRefPtr<HTMLFormElement> argument since this method only sets
     43        name/value pairs on m_formValuesAboutToBeSubmitted now.
     44        (WebCore::FrameLoader::loadFrameRequestWithFormAndValues): Create a
     45        FormState object as long as submitForm is not null so that other
     46        FrameLoader methods know when a form is being submitted.
     47        * loader/FrameLoader.h:
     48
    1492008-08-06  David D. Kilzer  <ddkilzer@apple.com>
    250
  • trunk/WebCore/html/HTMLFormElement.cpp

    r35415 r35611  
    444444   
    445445    frame->loader()->clearRecordedFormValues();
     446    frame->loader()->setFormAboutToBeSubmitted(this);
    446447    for (unsigned i = 0; i < formElements.size(); ++i) {
    447448        HTMLFormControlElement* control = formElements[i];
     
    449450            HTMLInputElement* input = static_cast<HTMLInputElement*>(control);
    450451            if (input->isTextField()) {
    451                 frame->loader()->recordFormValue(input->name(), input->value(), this);
     452                frame->loader()->recordFormValue(input->name(), input->value());
    452453                if (input->isSearchField())
    453454                    input->addSearchResult();
  • trunk/WebCore/loader/FrameLoader.cpp

    r35590 r35611  
    17501750}
    17511751
    1752 void FrameLoader::recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement> element)
     1752void FrameLoader::setFormAboutToBeSubmitted(PassRefPtr<HTMLFormElement> element)
    17531753{
    17541754    m_formAboutToBeSubmitted = element;
     1755}
     1756
     1757void FrameLoader::recordFormValue(const String& name, const String& value)
     1758{
    17551759    m_formValuesAboutToBeSubmitted.set(name, value);
    17561760}
     
    20892093            page->chrome()->focus();
    20902094}
    2091        
     2095
    20922096void FrameLoader::loadFrameRequestWithFormAndValues(const FrameLoadRequest& request, bool lockHistory, Event* event,
    20932097    HTMLFormElement* submitForm, const HashMap<String, String>& formValues)
    20942098{
    20952099    RefPtr<FormState> formState;
    2096     if (submitForm && !formValues.isEmpty())
     2100    if (submitForm)
    20972101        formState = FormState::create(submitForm, formValues, m_frame);
    2098    
     2102
    20992103    loadFrameRequestWithFormState(request, lockHistory, event, formState.release());       
    21002104}
  • trunk/WebCore/loader/FrameLoader.h

    r35378 r35611  
    387387
    388388        void clearRecordedFormValues();
    389         void recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement>);
     389        void setFormAboutToBeSubmitted(PassRefPtr<HTMLFormElement> element);
     390        void recordFormValue(const String& name, const String& value);
    390391
    391392        bool isComplete() const;
Note: See TracChangeset for help on using the changeset viewer.