Reviewed by Mitz.
- fix http://bugs.webkit.org/show_bug.cgi?id=15806
<rdar://problem/
5561626> ASSERT(element->isRadioButton()) fires destroying form elements
Test: fast/forms/remove-radio-button-assert.html
* html/HTMLGenericFormElement.cpp: (WebCore::HTMLGenericFormElement::removeFromForm):
Added protected function to be used by derived classes that need to do the same sort
of removal from form that's automatically done by the base class in certain circumstances.
* html/HTMLGenericFormElement.h: Added removeFromForm.
* html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::~HTMLInputElement):
Call removeFromForm here so the element is removed before we destroy the HTMLInputElement
part of this object. By the time we get to the base class's destructor it's too late.
The problem is specific to radio buttons so we don't have to worry about other classes
derived from HTMLGenericFormElement.
LayoutTests:
Reviewed by Mitz.
- test for http://bugs.webkit.org/show_bug.cgi?id=15806
<rdar://problem/
5561626> ASSERT(element->isRadioButton()) fires destroying form elements
* fast/forms/remove-radio-button-assert-expected.txt: Added.
* fast/forms/remove-radio-button-assert.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@27380
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-11-02 Darin Adler <darin@apple.com>
+
+ Reviewed by Mitz.
+
+ - test for http://bugs.webkit.org/show_bug.cgi?id=15806
+ <rdar://problem/5561626> ASSERT(element->isRadioButton()) fires destroying form elements
+
+ * fast/forms/remove-radio-button-assert-expected.txt: Added.
+ * fast/forms/remove-radio-button-assert.html: Added.
+
2007-11-02 Darin Adler <darin@apple.com>
Reviewed by Mitz.
--- /dev/null
+This tests the code path for destruction of a radio button when it's checked, when the form outlives the radio button, but where the radio button is never explicitly removed from the form.
+
+If you can see this text, the test has run.
--- /dev/null
+<p>This tests the code path for destruction of a radio button when it's checked, when the form outlives the radio button, but where the radio button is never explicitly removed from the form.</p>
+<div id="container"><form id="form"><input type="radio" name="button" checked></form></div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+var form = document.getElementById("form");
+document.getElementById("container").removeChild(form);
+form.innerHTML="";
+document.getElementById("container").innerHTML="If you can see this text, the test has run.";
+</script>
+2007-11-02 Darin Adler <darin@apple.com>
+
+ Reviewed by Mitz.
+
+ - fix http://bugs.webkit.org/show_bug.cgi?id=15806
+ <rdar://problem/5561626> ASSERT(element->isRadioButton()) fires destroying form elements
+
+ Test: fast/forms/remove-radio-button-assert.html
+
+ * html/HTMLGenericFormElement.cpp: (WebCore::HTMLGenericFormElement::removeFromForm):
+ Added protected function to be used by derived classes that need to do the same sort
+ of removal from form that's automatically done by the base class in certain circumstances.
+ * html/HTMLGenericFormElement.h: Added removeFromForm.
+
+ * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::~HTMLInputElement):
+ Call removeFromForm here so the element is removed before we destroy the HTMLInputElement
+ part of this object. By the time we get to the base class's destructor it's too late.
+ The problem is specific to radio buttons so we don't have to worry about other classes
+ derived from HTMLGenericFormElement.
+
2007-11-02 Darin Adler <darin@apple.com>
Reviewed by Mitz.
return m_form;
}
+void HTMLGenericFormElement::removeFromForm()
+{
+ if (!m_form)
+ return;
+ m_form->removeFormElement(this);
+ m_form = 0;
+}
+
HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
: HTMLGenericFormElement(tagName, doc, f)
{
void formDestroyed() { m_form = 0; }
+protected:
+ void removeFromForm();
+
private:
virtual HTMLFormElement* virtualForm() const;
document()->unregisterForCacheCallbacks(this);
document()->checkedRadioButtons().removeButton(this);
-
+
delete m_imageLoader;
+
+ // Need to remove this from the form while it is still an HTMLInputElement,
+ // so can't wait for the base class's destructor to do it.
+ removeFromForm();
}
const AtomicString& HTMLInputElement::name() const