Commit 1aa6c4d3 authored by mitz@apple.com's avatar mitz@apple.com
Browse files

<rdar://problem/7682756> Assertion failure when replacing the contents of a <select>

Reviewed by Sam Weinig.

WebCore: 

Test: fast/dom/remove-children-notification-order.html

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChildren): Changed to call childrenChanged()
before calling removedFromDocument() on each removed child, which matches
the order removeChild() does things, and avoids the assertion. This required
temporarily storing the removed children in a vector.
Also added comments about other discrepancies between this function and
removeChild().

LayoutTests: 

* fast/dom/remove-children-notification-order-expected.txt: Added.
* fast/dom/remove-children-notification-order.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7d9798f1
2010-03-03 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/7682756> Assertion failure when replacing the contents of a <select>
* fast/dom/remove-children-notification-order-expected.txt: Added.
* fast/dom/remove-children-notification-order.html: Added.
2010-03-03 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
[GTK] build slaves need working geoclue service
......
<select id="target">
<option>FAIL</option>
</select>
<p id="result">
FAIL: Test did not run
</p>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
var target = document.getElementById("target");
target.appendChild(document.createElement("link"));
target.offsetTop;
target.innerHTML = "<option>PASS</option>";
document.getElementById("result").innerHTML = target.value;
</script>
2010-03-03 Dan Bernstein <mitz@apple.com>
Reviewed by Sam Weinig.
<rdar://problem/7682756> Assertion failure when replacing the contents of a <select>
Test: fast/dom/remove-children-notification-order.html
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChildren): Changed to call childrenChanged()
before calling removedFromDocument() on each removed child, which matches
the order removeChild() does things, and avoids the assertion. This required
temporarily storing the removed children in a vector.
Also added comments about other discrepancies between this function and
removeChild().
2010-03-03 Adam Barth <abarth@webkit.org>
 
Reviewed by Darin Adler.
......
......@@ -396,33 +396,43 @@ bool ContainerNode::removeChildren()
document()->removeFocusedNodeOfSubtree(this, true);
forbidEventDispatch();
int childCountDelta = 0;
Vector<RefPtr<Node> > removedChildren;
while (RefPtr<Node> n = m_firstChild) {
childCountDelta--;
Node* next = n->nextSibling();
// Remove the node from the tree before calling detach or removedFromDocument (4427024, 4129744)
// Remove the node from the tree before calling detach or removedFromDocument (4427024, 4129744).
// removeChild() does this after calling detach(). There is no explanation for
// this discrepancy between removeChild() and its optimized version removeChildren().
n->setPreviousSibling(0);
n->setNextSibling(0);
n->setParent(0);
m_firstChild = next;
if (n == m_lastChild)
m_lastChild = 0;
if (n->attached())
n->detach();
if (n->inDocument())
n->removedFromDocument();
removedChildren.append(n.release());
}
allowEventDispatch();
size_t removedChildrenCount = removedChildren.size();
// Dispatch a single post-removal mutation event denoting a modified subtree.
childrenChanged(false, 0, 0, childCountDelta);
childrenChanged(false, 0, 0, -removedChildrenCount);
dispatchSubtreeModifiedEvent();
for (size_t i = 0; i < removedChildrenCount; ++i) {
Node* removedChild = removedChildren[i].get();
if (removedChild->inDocument())
removedChild->removedFromDocument();
// removeChild() calls removedFromTree(true) if the child was not in the
// document. There is no explanation for this discrepancy between removeChild()
// and its optimized version removeChildren().
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment