Changeset 20333 in webkit


Ignore:
Timestamp:
Mar 19, 2007, 5:30:49 PM (18 years ago)
Author:
adele
Message:

LayoutTests:

Reviewed by Beth.

Test for http://bugs.webkit.org/show_bug.cgi?id=13087
<rdar://problem/5064316> REGRESSION: Allow setting the checked attribute in js and in markup for unnamed radio buttons (dominos.com)

  • fast/forms/radio_checked_name-expected.txt: Added.
  • fast/forms/radio_checked_name.html: Added.

WebCore:

Reviewed by Beth.

Fix for http://bugs.webkit.org/show_bug.cgi?id=13087
<rdar://problem/5064316> REGRESSION: Allow setting the checked attribute in js and in markup for unnamed radio buttons (dominos.com)

Test: fast/forms/radio_checked_name.html

We were matching a WinIE quirk that does not allow a user to check and uncheck an unnamed radio button. But they still
allow the checked attribute to be set in html, and changed in javascript. So this change matches that behavior.

  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::parseMappedAttribute): We no longer need a special call to setChecked when parsing the name attribute, since we setChecked will now work with unnamed radio buttons. (WebCore::HTMLInputElement::preDispatchEventHandler): Added comment. (WebCore::HTMLInputElement::setChecked): Don't check for the unnamed radio button case here. (WebCore::HTMLInputElement::postDispatchEventHandler): Don't call setChecked for unnamed radio buttons. (WebCore::HTMLInputElement::defaultEventHandler): ditto.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r20326 r20333  
     12007-03-19  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Beth.
     4
     5        Test for http://bugs.webkit.org/show_bug.cgi?id=13087
     6        <rdar://problem/5064316> REGRESSION: Allow setting the checked attribute in js and in markup for unnamed radio buttons (dominos.com)
     7
     8        * fast/forms/radio_checked_name-expected.txt: Added.
     9        * fast/forms/radio_checked_name.html: Added.
     10
    1112007-03-19  Justin Garcia  <justin.garcia@apple.com>
    212
  • trunk/WebCore/ChangeLog

    r20332 r20333  
     12007-03-19  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Beth.
     4
     5        Fix for http://bugs.webkit.org/show_bug.cgi?id=13087
     6        <rdar://problem/5064316> REGRESSION: Allow setting the checked attribute in js and in markup for unnamed radio buttons (dominos.com)
     7
     8        Test: fast/forms/radio_checked_name.html
     9
     10        We were matching a WinIE quirk that does not allow a user to check and uncheck an unnamed radio button.  But they still
     11        allow the checked attribute to be set in html, and changed in javascript.  So this change matches that behavior.
     12
     13        * html/HTMLInputElement.cpp:
     14        (WebCore::HTMLInputElement::parseMappedAttribute): We no longer need a special call to setChecked when parsing the name
     15         attribute, since we setChecked will now work with unnamed radio buttons.
     16        (WebCore::HTMLInputElement::preDispatchEventHandler): Added comment.
     17        (WebCore::HTMLInputElement::setChecked): Don't check for the unnamed radio button case here.
     18        (WebCore::HTMLInputElement::postDispatchEventHandler): Don't call setChecked for unnamed radio buttons.
     19        (WebCore::HTMLInputElement::defaultEventHandler): ditto.
     20
    1212007-03-19  Adam Roben  <aroben@apple.com>
    222
  • trunk/WebCore/html/HTMLInputElement.cpp

    r20214 r20333  
    585585       
    586586        if (inputType() == RADIO) {
    587             // In case we parsed the checked attribute first, call setChecked if the element is checked by default.
    588             if (m_useDefaultChecked)
    589                 setChecked(m_defaultChecked);
    590587            // Add the button to its new group.
    591588            if (checked())
     
    880877void HTMLInputElement::setChecked(bool nowChecked, bool sendChangeEvent)
    881878{
    882     // We mimic WinIE and don't allow unnamed radio buttons to be checked.
    883     if (checked() == nowChecked || (inputType() == RADIO && name().isEmpty()))
     879    if (checked() == nowChecked)
    884880        return;
    885881
     
    10601056            // For radio buttons, store the current selected radio object.
    10611057            if (name().isEmpty() || checked())
    1062                 return 0; // Unnamed radio buttons dont get checked. Checked buttons just stay checked.
     1058                return 0; // Match WinIE and don't allow unnamed radio buttons to be checked.
     1059                          // Checked buttons just stay checked.
    10631060                          // FIXME: Need to learn to work without a form.
    10641061
     
    10971094                // Make sure it is still a radio button and only do the restoration if it still
    10981095                // belongs to our group.
    1099                 if (input->form() == form() && input->inputType() == RADIO && input->name() == name()) {
     1096
     1097                // Match WinIE and don't allow unnamed radio buttons to be checked.
     1098                if (input->form() == form() && input->inputType() == RADIO && !name().isEmpty() && input->name() == name()) {
    11001099                    // Ok, the old radio button is still in our form and in our group and is still a
    11011100                    // radio button, so it's safe to restore selection to it.
     
    12531252                        break;
    12541253                    if (n->hasTagName(inputTag)) {
     1254                        // Match WinIE and don't allow unnamed radio buttons to be checked.
    12551255                        HTMLInputElement* inputElt = static_cast<HTMLInputElement*>(n);
    1256                         if (inputElt->inputType() == RADIO && inputElt->name() == name() &&
    1257                             inputElt->isFocusable()) {
     1256                        if (inputElt->inputType() == RADIO && !name().isEmpty() && inputElt->name() == name() && inputElt->isFocusable()) {
    12581257                            inputElt->setChecked(true);
    12591258                            document()->setFocusedNode(inputElt);
Note: See TracChangeset for help on using the changeset viewer.