- Revision
- 119891
- Author
- [email protected]
- Date
- 2012-06-08 20:50:03 -0700 (Fri, 08 Jun 2012)
Log Message
REGRESSION(r116487?): HTMLFormElement::elements['name'] is empty if the form is detached from the document tree
https://bugs.webkit.org/show_bug.cgi?id=88632
Patch by Rakesh KN <[email protected]> on 2012-06-08
Reviewed by Ryosuke Niwa.
Source/WebCore:
Update root node of RadioNodeList when the form element is detached from dom tree.
Test: fast/forms/radionodelist-whose-form-element-detached-from-domtree.html
* dom/Node.cpp:
(WebCore::Node::resetCachedRadioNodeListRootNode):
New function to update the root node of RadioNodeLists to form element from document.
* dom/Node.h: Ditto.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::removedFrom):
On detach, we update the root node of all RadioNodeLists of this form element.
* html/RadioNodeList.cpp:
(WebCore::RadioNodeList::setRootElement):
Setter for updating root node.
* html/RadioNodeList.h:
(RadioNodeList): Ditto.
LayoutTests:
* fast/forms/radionodelist-whose-form-element-detached-from-domtree-expected.txt: Added.
* fast/forms/radionodelist-whose-form-element-detached-from-domtree.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (119890 => 119891)
--- trunk/LayoutTests/ChangeLog 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/LayoutTests/ChangeLog 2012-06-09 03:50:03 UTC (rev 119891)
@@ -1,3 +1,13 @@
+2012-06-08 Rakesh KN <[email protected]>
+
+ REGRESSION(r116487?): HTMLFormElement::elements['name'] is empty if the form is detached from the document tree
+ https://bugs.webkit.org/show_bug.cgi?id=88632
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/forms/radionodelist-whose-form-element-detached-from-domtree-expected.txt: Added.
+ * fast/forms/radionodelist-whose-form-element-detached-from-domtree.html: Added.
+
2012-06-08 Ryosuke Niwa <[email protected]>
Remove all uses of FAIL test expectation from Chromium test expectations.
Added: trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree-expected.txt (0 => 119891)
--- trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree-expected.txt 2012-06-09 03:50:03 UTC (rev 119891)
@@ -0,0 +1,45 @@
+RadioNodeList should be rooted at form itself if detached from dom tree
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+form in dom tree
+PASS radioNodeList1.length is 3
+PASS radioNodeList2.length is 3
+PASS radioNodeList1[0].value is 'value1'
+PASS radioNodeList1[1].value is 'value2'
+PASS radioNodeList1[2].value is 'value3'
+PASS radioNodeList2[0].value is 'value4'
+PASS radioNodeList2[1].value is 'value5'
+PASS radioNodeList2[2].value is 'value6'
+Check RadioNodeList.value
+PASS radioNodeList1.value is ""
+PASS radioNodeList2.value is ""
+PASS radioNodeList1[2].checked = true; radioNodeList1.value is 'value3'
+
+form detached from dom tree
+PASS radioNodeList1.length is 3
+PASS radioNodeList2.length is 3
+PASS radioNodeList1[0].value is 'value1'
+PASS radioNodeList1[1].value is 'value2'
+PASS radioNodeList1[2].value is 'value3'
+PASS radioNodeList2[0].value is 'value4'
+PASS radioNodeList2[1].value is 'value5'
+PASS radioNodeList2[2].value is 'value6'
+Check RadioNodeList.value
+PASS radioNodeList1[2].checked = true; radioNodeList1.value is 'value3'
+
+form again added to dom tree
+PASS radioNodeList1.length is 3
+PASS radioNodeList2.length is 3
+PASS radioNodeList1[0].value is 'value1'
+PASS radioNodeList1[1].value is 'value2'
+PASS radioNodeList1[2].value is 'value3'
+PASS radioNodeList2[0].value is 'value4'
+PASS radioNodeList2[1].value is 'value5'
+PASS radioNodeList2[2].value is 'value6'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree.html (0 => 119891)
--- trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree.html (rev 0)
+++ trunk/LayoutTests/fast/forms/radionodelist-whose-form-element-detached-from-domtree.html 2012-06-09 03:50:03 UTC (rev 119891)
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<form id="testform">
+ Radio button array:
+ <input type="radio" name="type1" value="value1">
+ <input type="radio" name="type1" value="value2">
+ <input type="radio" name="type1" value="value3">
+ <input type="radio" name="type2" value="value4">
+ <input type="radio" name="type2" value="value5">
+ <input type="radio" name="type2" value="value6">
+ <br>
+ Single checkbox:
+ <input type="checkbox" name="chkbox" value="chkboxvalue">
+ <br>
+</form>
+<div id="console"></div>
+<script>
+
+description("RadioNodeList should be rooted at form itself if detached from dom tree");
+debug("");
+var owner = document.getElementById('testform');
+var radioNodeList1 = owner.elements['type1'];
+var radioNodeList2 = owner.elements['type2'];
+
+function testRadioNodeList() {
+ shouldBe('radioNodeList1.length', '3');
+ shouldBe('radioNodeList2.length', '3');
+
+ shouldBe('radioNodeList1[0].value', "'value1'");
+ shouldBe('radioNodeList1[1].value', "'value2'");
+ shouldBe('radioNodeList1[2].value', "'value3'");
+ shouldBe('radioNodeList2[0].value', "'value4'");
+ shouldBe('radioNodeList2[1].value', "'value5'");
+ shouldBe('radioNodeList2[2].value', "'value6'");
+}
+debug("form in dom tree");
+testRadioNodeList();
+
+debug("Check RadioNodeList.value");
+shouldBe('radioNodeList1.value', '""');
+shouldBe('radioNodeList2.value', '""');
+shouldBe('radioNodeList1[2].checked = true; radioNodeList1.value', "'value3'");
+
+owner.parentNode.removeChild(owner);
+
+debug("");
+debug("form detached from dom tree");
+testRadioNodeList();
+
+debug("Check RadioNodeList.value");
+shouldBe('radioNodeList1[2].checked = true; radioNodeList1.value', "'value3'");
+
+document.body.appendChild(owner);
+debug("");
+debug("form again added to dom tree");
+testRadioNodeList();
+
+owner.parentNode.removeChild(owner);
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (119890 => 119891)
--- trunk/Source/WebCore/ChangeLog 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/ChangeLog 2012-06-09 03:50:03 UTC (rev 119891)
@@ -1,3 +1,27 @@
+2012-06-08 Rakesh KN <[email protected]>
+
+ REGRESSION(r116487?): HTMLFormElement::elements['name'] is empty if the form is detached from the document tree
+ https://bugs.webkit.org/show_bug.cgi?id=88632
+
+ Reviewed by Ryosuke Niwa.
+
+ Update root node of RadioNodeList when the form element is detached from dom tree.
+
+ Test: fast/forms/radionodelist-whose-form-element-detached-from-domtree.html
+
+ * dom/Node.cpp:
+ (WebCore::Node::resetCachedRadioNodeListRootNode):
+ New function to update the root node of RadioNodeLists to form element from document.
+ * dom/Node.h: Ditto.
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::removedFrom):
+ On detach, we update the root node of all RadioNodeLists of this form element.
+ * html/RadioNodeList.cpp:
+ (WebCore::RadioNodeList::setRootElement):
+ Setter for updating root node.
+ * html/RadioNodeList.h:
+ (RadioNodeList): Ditto.
+
2012-06-08 David Reveman <[email protected]>
[Chromium] Compositor doesn't support translucent root layers.
Modified: trunk/Source/WebCore/dom/Node.cpp (119890 => 119891)
--- trunk/Source/WebCore/dom/Node.cpp 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/dom/Node.cpp 2012-06-09 03:50:03 UTC (rev 119891)
@@ -2930,6 +2930,17 @@
data->m_radioNodeListCache.remove(name);
}
+void Node::resetCachedRadioNodeListRootNode()
+{
+ ASSERT(hasTagName(formTag));
+ if (!hasRareData() || !rareData()->nodeLists())
+ return;
+
+ NodeListsNodeData::RadioNodeListCache cache = rareData()->nodeLists()->m_radioNodeListCache;
+ for (NodeListsNodeData::RadioNodeListCache::iterator it = cache.begin(); it != cache.end(); ++it)
+ it->second->setRootElement(toElement(this));
+}
+
} // namespace WebCore
#ifndef NDEBUG
Modified: trunk/Source/WebCore/dom/Node.h (119890 => 119891)
--- trunk/Source/WebCore/dom/Node.h 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/dom/Node.h 2012-06-09 03:50:03 UTC (rev 119891)
@@ -578,6 +578,7 @@
PassRefPtr<RadioNodeList> radioNodeList(const AtomicString&);
void removeCachedRadioNodeList(RadioNodeList*, const AtomicString&);
+ void resetCachedRadioNodeListRootNode();
PassRefPtr<NodeList> getElementsByTagName(const AtomicString&);
PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (119890 => 119891)
--- trunk/Source/WebCore/html/HTMLFormElement.cpp 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp 2012-06-09 03:50:03 UTC (rev 119891)
@@ -165,6 +165,8 @@
HTMLElement::removedFrom(insertionPoint);
if (insertionPoint->inDocument() && hasID())
document()->formController()->resetFormElementsOwner();
+ if (!inDocument())
+ resetCachedRadioNodeListRootNode();
}
void HTMLFormElement::handleLocalEvents(Event* event)
Modified: trunk/Source/WebCore/html/RadioNodeList.cpp (119890 => 119891)
--- trunk/Source/WebCore/html/RadioNodeList.cpp 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/html/RadioNodeList.cpp 2012-06-09 03:50:03 UTC (rev 119891)
@@ -112,5 +112,9 @@
return checkElementMatchesRadioNodeListFilter(testElement);
}
+void RadioNodeList::setRootElement(Element* baseElement)
+{
+ m_node = baseElement->toNode();
+}
} // namspace
Modified: trunk/Source/WebCore/html/RadioNodeList.h (119890 => 119891)
--- trunk/Source/WebCore/html/RadioNodeList.h 2012-06-09 03:04:53 UTC (rev 119890)
+++ trunk/Source/WebCore/html/RadioNodeList.h 2012-06-09 03:50:03 UTC (rev 119891)
@@ -45,6 +45,7 @@
String value() const;
void setValue(const String&);
+ void setRootElement(Element* baseElement);
protected:
virtual bool nodeMatches(Element*) const;