Changeset 50132 in webkit


Ignore:
Timestamp:
Oct 27, 2009 12:12:10 AM (15 years ago)
Author:
dbates@webkit.org
Message:

2009-10-26 Daniel Bates <dbates@webkit.org>

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=30491

Fixes an issue where pressing return/enter on the keyboard
in <isindex> does not submit it if is not within a <form>.

According to the HTML 2.0 thru HTML 4.01 spec
(http://www.w3.org/MarkUp/html-spec/html-spec_7.html#SEC7.5), the
<isindex> element does not need to be within a <form> element in
order to submit it. It can submitted on its own. Also, if present,
the href property of the <base> element will dictate where to submit
the value of the <isindex> element (this is analogous to the action
property of the <form> element).

Tests: http/tests/misc/isindex-with-no-form-base-href.html

http/tests/misc/isindex-with-no-form.html

  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler): Calls createTemporaryFormForIsIndex() to create a <form> if none is present and we are an <isindex> element. (WebCore::HTMLInputElement::createTemporaryFormForIsIndex): Added.
  • html/HTMLInputElement.h:

2009-10-26 Daniel Bates <dbates@webkit.org>

Reviewed by Darin Adler.

https://bugs.webkit.org/show_bug.cgi?id=30491

Test that the <isindex> element can be submitted without being enclosed
within a <form> element. Also tests that the href property of the <base>
element can be used to direct where the submission is sent.

  • http/tests/misc/isindex-with-no-form-base-href-expected.txt: Added.
  • http/tests/misc/isindex-with-no-form-base-href.html: Added.
  • http/tests/misc/isindex-with-no-form-expected.txt: Added.
  • http/tests/misc/isindex-with-no-form.html: Added.
  • http/tests/misc/resources/isindex-with-no-form-base-href-submit.html: Added.
  • http/tests/misc/resources/isindex-with-no-form-base-href.html: Added.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50119 r50132  
     12009-10-26  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=30491
     6
     7        Test that the <isindex> element can be submitted without being enclosed
     8        within a <form> element. Also tests that the href property of the <base>
     9        element can be used to direct where the submission is sent.
     10
     11        * http/tests/misc/isindex-with-no-form-base-href-expected.txt: Added.
     12        * http/tests/misc/isindex-with-no-form-base-href.html: Added.
     13        * http/tests/misc/isindex-with-no-form-expected.txt: Added.
     14        * http/tests/misc/isindex-with-no-form.html: Added.
     15        * http/tests/misc/resources/isindex-with-no-form-base-href-submit.html: Added.
     16        * http/tests/misc/resources/isindex-with-no-form-base-href.html: Added.
     17
    1182009-10-26  Brian Weinstein  <bweinstein@apple.com>
    219
  • trunk/WebCore/ChangeLog

    r50131 r50132  
     12009-10-26  Daniel Bates  <dbates@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=30491
     6
     7        Fixes an issue where pressing return/enter on the keyboard
     8        in <isindex> does not submit it if is not within a <form>.
     9
     10        According to the HTML 2.0 thru HTML 4.01 spec
     11        (http://www.w3.org/MarkUp/html-spec/html-spec_7.html#SEC7.5), the
     12        <isindex> element does not need to be within a <form> element in
     13        order to submit it. It can submitted on its own. Also, if present,
     14        the href property of the <base> element will dictate where to submit
     15        the value of the <isindex> element (this is analogous to the action
     16        property of the <form> element).
     17
     18        Tests: http/tests/misc/isindex-with-no-form-base-href.html
     19               http/tests/misc/isindex-with-no-form.html
     20
     21        * html/HTMLInputElement.cpp:
     22        (WebCore::HTMLInputElement::defaultEventHandler): Calls createTemporaryFormForIsIndex()
     23        to create a <form> if none is present and we are an <isindex> element.
     24        (WebCore::HTMLInputElement::createTemporaryFormForIsIndex): Added.
     25        * html/HTMLInputElement.h:
     26
    1272009-10-26  Oliver Hunt  <oliver@apple.com>
    228
  • trunk/WebCore/html/HTMLInputElement.cpp

    r49394 r50132  
    15501550                toRenderTextControl(r)->setEdited(false);
    15511551        }
    1552         // Form may never have been present, or may have been destroyed by the change event.
    1553         if (form())
    1554             form()->submitClick(evt);
     1552
     1553        RefPtr<HTMLFormElement> formForSubmission = form();
     1554        // If there is no form and the element is an <isindex>, then create a temporary form just to be used for submission.
     1555        if (!formForSubmission && inputType() == ISINDEX)
     1556            formForSubmission = createTemporaryFormForIsIndex();
     1557
     1558        // Form may never have been present, or may have been destroyed by code responding to the change event.
     1559        if (formForSubmission)
     1560            formForSubmission->submitClick(evt);
     1561
    15551562        evt->setDefaultHandled();
    15561563        return;
     
    15681575    if (!callBaseClassEarly && !evt->defaultHandled())
    15691576        HTMLFormControlElementWithState::defaultEventHandler(evt);
     1577}
     1578
     1579PassRefPtr<HTMLFormElement> HTMLInputElement::createTemporaryFormForIsIndex()
     1580{
     1581    RefPtr<HTMLFormElement> form = new HTMLFormElement(formTag, document());
     1582    form->registerFormElement(this);
     1583    form->setMethod("GET");
     1584    if (!document()->baseURL().isEmpty()) {
     1585        // We treat the href property of the <base> element as the form action, as per section 7.5
     1586        // "Queries and Indexes" of the HTML 2.0 spec. <http://www.w3.org/MarkUp/html-spec/html-spec_7.html#SEC7.5>.
     1587        form->setAction(document()->baseURL().string());
     1588    }
     1589    return form.release();
    15701590}
    15711591
  • trunk/WebCore/html/HTMLInputElement.h

    r49199 r50132  
    257257    virtual bool isRequiredFormControl() const;
    258258
     259    PassRefPtr<HTMLFormElement> createTemporaryFormForIsIndex();
     260
    259261#if ENABLE(DATALIST)
    260262    HTMLDataListElement* dataList() const;
Note: See TracChangeset for help on using the changeset viewer.