- Test for <rdar://problem/
4469419>
REGRESSION: RadioButtons are not checked in Safari when name attribute comes after checked attribute
* fast/forms/radio-attr-order-expected.checksum: Added.
* fast/forms/radio-attr-order-expected.png: Added.
* fast/forms/radio-attr-order-expected.txt: Added.
* fast/forms/radio-attr-order.html: Added.
WebCore:
Reviewed by Tim Hatcher.
- fix for <rdar://problem/
4469419>
REGRESSION: RadioButtons are not checked in Safari when name attribute comes after checked attribute
Test: fast/forms/radio-attr-order.html
* khtml/html/HTMLInputElementImpl.cpp: (WebCore::HTMLInputElementImpl::parseMappedAttribute):
When the name attribute gets parsed for radio buttons, if its supposed to be checked by default, call setChecked.
Also, when the name changes on a checked button, we don't need to check that
there's a form before removing it as the checked button for that group.
That was an old check from when we required a form to keep track of checked buttons.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13250
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-03-10 Adele Peterson <adele@apple.com>
+
+ - Test for <rdar://problem/4469419>
+ REGRESSION: RadioButtons are not checked in Safari when name attribute comes after checked attribute
+
+ * fast/forms/radio-attr-order-expected.checksum: Added.
+ * fast/forms/radio-attr-order-expected.png: Added.
+ * fast/forms/radio-attr-order-expected.txt: Added.
+ * fast/forms/radio-attr-order.html: Added.
+
2006-03-09 Adele Peterson <adele@apple.com>
- Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7675
--- /dev/null
+71625a7fff7b02cd27bf1a356be520b8
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock (anonymous) at (0,0) size 784x73
+ RenderText {TEXT} at (0,0) size 744x18
+ text run at (0,0) width 744: "This tests that radio buttons are checked by default, even when the name attribute is parsed after the checked attribute. "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderBR {BR} at (0,18) size 0x18
+ RenderBlock {INPUT} at (3,39) size 12x13
+ RenderText {TEXT} at (18,36) size 300x18
+ text run at (18,36) width 300: "This radio button should be checked by default "
+ RenderBR {BR} at (0,0) size 0x0
+ RenderBR {BR} at (0,55) size 0x18
+ RenderBlock {DIV} at (0,73) size 784x18
+ RenderText {TEXT} at (0,0) size 301x18
+ text run at (0,0) width 82: "Test Passed. "
+ text run at (82,0) width 219: "Radio button is checked by default"
--- /dev/null
+<html>
+ <head>
+ <script>
+ function test() {
+ if (document.getElementById("rb").checked)
+ document.getElementById("result").innerHTML = "Test Passed. Radio button is checked by default";
+ }
+ </script>
+ </head>
+<body onload="test()">
+This tests that radio buttons are checked by default, even when the name attribute is parsed after the checked attribute.
+<br><br>
+<input type="radio" checked name="test_group" id="rb">This radio button should be checked by default
+<br><br>
+<div id="result">Test Failed. Radio button is not checked by default.</div>
+</body>
+</html>
+2006-03-10 Adele Peterson <adele@apple.com>
+
+ Reviewed by Tim Hatcher.
+
+ - fix for <rdar://problem/4469419>
+ REGRESSION: RadioButtons are not checked in Safari when name attribute comes after checked attribute
+
+ Test: fast/forms/radio-attr-order.html
+
+ * khtml/html/HTMLInputElementImpl.cpp: (WebCore::HTMLInputElementImpl::parseMappedAttribute):
+ When the name attribute gets parsed for radio buttons, if its supposed to be checked by default, call setChecked.
+ Also, when the name changes on a checked button, we don't need to check that
+ there's a form before removing it as the checked button for that group.
+ That was an old check from when we required a form to keep track of checked buttons.
+
2006-03-10 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
void HTMLInputElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
{
if (attr->name() == nameAttr) {
- if (m_type == RADIO && checked() && m_form) {
+ if (m_type == RADIO && checked()) {
// Remove the radio from its old group.
if (m_type == RADIO && !m_name.isEmpty())
getDocument()->removeRadioButtonGroup(m_name.impl(), m_form);
// Update our cached reference to the name.
m_name = attr->value();
- // Add it to its new group.
- if (m_type == RADIO && checked())
- getDocument()->radioButtonChecked(this, m_form);
+ if (m_type == RADIO) {
+ // In case we parsed the checked attribute first, call setChecked if the element is checked by default.
+ if (m_useDefaultChecked)
+ setChecked(m_defaultChecked);
+ // Add the button to its new group.
+ if (checked())
+ getDocument()->radioButtonChecked(this, m_form);
+ }
+
+
} else if (attr->name() == autocompleteAttr) {
m_autocomplete = !equalIgnoringCase(attr->value(), "off");
} else if (attr->name() == typeAttr) {