Changeset 91048 in webkit


Ignore:
Timestamp:
Jul 14, 2011 9:36:29 PM (13 years ago)
Author:
bashi@chromium.org
Message:

<input form="x"> should not associate the input with any forms when there is no form with id="x"
https://bugs.webkit.org/show_bug.cgi?id=64509

Source/WebCore:

Don't set form owner when a form associated element has the form attribute but there is no such form element.

Patch by Kenichi Ishibashi <bashi@chromium.org> on 2011-07-14
Reviewed by Kent Tamura.

Test: fast/forms/form-attribute-nonexistence-form-id.html

  • dom/Document.cpp:

(WebCore::Document::resetFormElementsOwner): Removed the argument which is no longer needed.

  • dom/Document.h: Ditto.
  • html/FormAssociatedElement.cpp:

(WebCore::FormAssociatedElement::insertedIntoTree): Resets m_form whenever the element has the form attribute.
(WebCore::FormAssociatedElement::resetFormOwner): Don't set m_form when there is no form element which has the given id.
(WebCore::FormAssociatedElement::formAttributeChanged): Removed the argument of resetFormOwner().

  • html/FormAssociatedElement.h: Ditto.
  • html/HTMLFormElement.cpp: Ditto.

(WebCore::HTMLFormElement::insertedIntoDocument):
(WebCore::HTMLFormElement::removedFromDocument):

LayoutTests:

Adds a test for checking input elements don't associate any form elements when they have the form attribute which points nonexistence form.
Fixes existing tests that contain unintended form attributes.

Patch by Kenichi Ishibashi <bashi@chromium.org> on 2011-07-14
Reviewed by Kent Tamura.

  • fast/forms/form-attribute-nonexistence-form-id-expected.txt: Added.
  • fast/forms/form-attribute-nonexistence-form-id.html: Added.
  • fast/forms/script-tests/form-attribute.js: Fixed unintended form attributes.
  • fast/forms/script-tests/form-collection-elements-order.js: Ditto.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r91047 r91048  
     12011-07-14  Kenichi Ishibashi  <bashi@chromium.org>
     2
     3        <input form="x"> should not associate the input with any forms when there is no  form with id="x"
     4        https://bugs.webkit.org/show_bug.cgi?id=64509
     5
     6        Adds a test for checking input elements don't associate any form elements when they have the form attribute which points nonexistence form.
     7        Fixes existing tests that contain unintended form attributes.
     8
     9        Reviewed by Kent Tamura.
     10
     11        * fast/forms/form-attribute-nonexistence-form-id-expected.txt: Added.
     12        * fast/forms/form-attribute-nonexistence-form-id.html: Added.
     13        * fast/forms/script-tests/form-attribute.js: Fixed unintended form attributes.
     14        * fast/forms/script-tests/form-collection-elements-order.js: Ditto.
     15
    1162011-07-14  Kent Tamura  <tkent@chromium.org>
    217
  • trunk/LayoutTests/fast/forms/script-tests/form-attribute.js

    r73430 r91048  
    6262container.innerHTML = '<form id=owner>' +
    6363    '    <form>' +
    64     '        <input id=inputElement1 name=victim form=owner/>' +
     64    '        <input id=inputElement1 name=victim form=owner />' +
    6565    '        <input id=inputElement2 name=victim />' +
    66     '        <input id=inputElement3 name=victim form=owner/>' +
     66    '        <input id=inputElement3 name=victim form=owner />' +
    6767    '    </form>' +
    6868    '</form>';
  • trunk/LayoutTests/fast/forms/script-tests/form-collection-elements-order.js

    r73430 r91048  
    5858container.innerHTML = '<button name=victim form=owner></button>' +
    5959    '<fieldset name=victim form=owner>Test</fieldset>' +
    60     '<input name=victim form=owner/>' +
     60    '<input name=victim form=owner />' +
    6161    '<keygen name=victim form=owner></keygen>' +
    6262    '<form id=owner>' +
  • trunk/Source/WebCore/ChangeLog

    r91047 r91048  
     12011-07-14  Kenichi Ishibashi  <bashi@chromium.org>
     2
     3        <input form="x"> should not associate the input with any forms when there is no  form with id="x"
     4        https://bugs.webkit.org/show_bug.cgi?id=64509
     5
     6        Don't set form owner when a form associated element has the form attribute but there is no such form element.
     7
     8        Reviewed by Kent Tamura.
     9
     10        Test: fast/forms/form-attribute-nonexistence-form-id.html
     11
     12        * dom/Document.cpp:
     13        (WebCore::Document::resetFormElementsOwner): Removed the argument which is no longer needed.
     14        * dom/Document.h: Ditto.
     15        * html/FormAssociatedElement.cpp:
     16        (WebCore::FormAssociatedElement::insertedIntoTree): Resets m_form whenever the element has the form attribute.
     17        (WebCore::FormAssociatedElement::resetFormOwner): Don't set m_form when there is no form element which has the given id.
     18        (WebCore::FormAssociatedElement::formAttributeChanged): Removed the argument of resetFormOwner().
     19        * html/FormAssociatedElement.h: Ditto.
     20        * html/HTMLFormElement.cpp: Ditto.
     21        (WebCore::HTMLFormElement::insertedIntoDocument):
     22        (WebCore::HTMLFormElement::removedFromDocument):
     23
    1242011-07-14  Kent Tamura  <tkent@chromium.org>
    225
  • trunk/Source/WebCore/dom/Document.cpp

    r90654 r91048  
    43744374}
    43754375
    4376 void Document::resetFormElementsOwner(HTMLFormElement* form)
     4376void Document::resetFormElementsOwner()
    43774377{
    43784378    typedef FormAssociatedElementListHashSet::iterator Iterator;
    43794379    Iterator end = m_formElementsWithFormAttribute.end();
    43804380    for (Iterator it = m_formElementsWithFormAttribute.begin(); it != end; ++it)
    4381         (*it)->resetFormOwner(form);
     4381        (*it)->resetFormOwner();
    43824382}
    43834383
  • trunk/Source/WebCore/dom/Document.h

    r90809 r91048  
    521521    void registerFormElementWithFormAttribute(FormAssociatedElement*);
    522522    void unregisterFormElementWithFormAttribute(FormAssociatedElement*);
    523     void resetFormElementsOwner(HTMLFormElement*);
     523    void resetFormElementsOwner();
    524524
    525525    FrameView* view() const; // can be NULL
  • trunk/Source/WebCore/html/FormAssociatedElement.cpp

    r85617 r91048  
    7878    HTMLElement* element = toHTMLElement(this);
    7979    if (element->fastHasAttribute(formAttr)) {
     80        // Resets the form owner at first to make sure the element don't
     81        // associate any form elements when there is no element which has
     82        // the given ID.
     83        if (m_form) {
     84            m_form->removeFormElement(this);
     85            m_form = 0;
     86        }
    8087        Element* formElement = element->treeScope()->getElementById(element->fastGetAttribute(formAttr));
    8188        if (formElement && formElement->hasTagName(formTag)) {
    82             if (m_form)
    83                 m_form->removeFormElement(this);
    8489            m_form = static_cast<HTMLFormElement*>(formElement);
    8590            m_form->registerFormElement(this);
    8691        }
     92        return;
    8793    }
    8894    if (!m_form) {
     
    123129}
    124130
    125 void FormAssociatedElement::resetFormOwner(HTMLFormElement* form)
     131void FormAssociatedElement::resetFormOwner()
    126132{
    127133    HTMLElement* element = toHTMLElement(this);
     
    141147        if (firstElement && firstElement->hasTagName(formTag))
    142148            m_form = static_cast<HTMLFormElement*>(firstElement);
    143         else
    144             m_form = form;
    145149    } else
    146150        m_form = element->findFormAncestor();
     
    161165        element->document()->unregisterFormElementWithFormAttribute(this);
    162166    } else
    163         resetFormOwner(0);
     167        resetFormOwner();
    164168}
    165169
  • trunk/Source/WebCore/html/FormAssociatedElement.h

    r82925 r91048  
    5656    virtual void formDestroyed() { m_form = 0; }
    5757
    58     void resetFormOwner(HTMLFormElement*);
     58    void resetFormOwner();
    5959
    6060protected:
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r89991 r91048  
    139139
    140140    if (hasID())
    141         document()->resetFormElementsOwner(this);
     141        document()->resetFormElementsOwner();
    142142}
    143143
     
    150150
    151151    if (hasID())
    152         document()->resetFormElementsOwner(0);
     152        document()->resetFormElementsOwner();
    153153}
    154154
Note: See TracChangeset for help on using the changeset viewer.