Modified: trunk/Source/WebCore/ChangeLog (111414 => 111415)
--- trunk/Source/WebCore/ChangeLog 2012-03-20 18:12:49 UTC (rev 111414)
+++ trunk/Source/WebCore/ChangeLog 2012-03-20 18:18:22 UTC (rev 111415)
@@ -1,3 +1,18 @@
+2012-03-20 Sheriff Bot <[email protected]>
+
+ Unreviewed, rolling out r111310.
+ http://trac.webkit.org/changeset/111310
+ https://bugs.webkit.org/show_bug.cgi?id=81683
+
+ Broke layout test
+ dom/xhtml/level3/core/nodereplacechild30.xhtml (Requested by
+ aklein on #webkit).
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::replaceChild):
+ (WebCore::ContainerNode::appendChild):
+ (WebCore::ContainerNode::parserAddChild):
+
2012-03-20 Gyuyoung Kim <[email protected]>
Convert hasSpellingMarker to use Internals interface.
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (111414 => 111415)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-03-20 18:12:49 UTC (rev 111414)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-03-20 18:18:22 UTC (rev 111415)
@@ -284,28 +284,29 @@
if (ec)
return false;
- NodeVector targets;
- collectTargetNodes(newChild.get(), targets);
+ bool isFragment = newChild->nodeType() == DOCUMENT_FRAGMENT_NODE && !newChild->isShadowRoot();
// Add the new child(ren)
- for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- Node* child = it->get();
-
+ RefPtr<Node> child = isFragment ? newChild->firstChild() : newChild;
+ while (child) {
// If the new child is already in the right place, we're done.
if (prev && (prev == child || prev == child->previousSibling()))
break;
+ // For a fragment we have more children to do.
+ RefPtr<Node> nextChild = isFragment ? child->nextSibling() : 0;
+
// Remove child from its old position.
if (ContainerNode* oldParent = child->parentNode())
- oldParent->removeChild(child, ec);
+ oldParent->removeChild(child.get(), ec);
if (ec)
return false;
// Due to arbitrary code running in response to a DOM mutation event it's
- // possible that "next" is no longer a child of "this".
+ // possible that "prev" is no longer a child of "this".
// It's also possible that "child" has been inserted elsewhere.
// In either of those cases, we'll just stop.
- if (next && next->parentNode() != this)
+ if (prev && prev->parentNode() != this)
break;
if (child->parentNode())
break;
@@ -314,22 +315,38 @@
ASSERT(!child->previousSibling());
#if ENABLE(INSPECTOR)
- InspectorInstrumentation::willInsertDOMNode(document(), child, this);
+ InspectorInstrumentation::willInsertDOMNode(document(), child.get(), this);
#endif
- treeScope()->adoptIfNeeded(child);
+ treeScope()->adoptIfNeeded(child.get());
- // Add child before "next".
+ // Add child after "prev".
forbidEventDispatch();
- if (next)
- insertBeforeCommon(next.get(), child);
- else
- appendChildToContainer(child, this);
+ Node* next;
+ if (prev) {
+ next = prev->nextSibling();
+ ASSERT(m_firstChild != next);
+ prev->setNextSibling(child.get());
+ } else {
+ next = m_firstChild;
+ m_firstChild = child.get();
+ }
+ if (next) {
+ ASSERT(m_lastChild != prev);
+ ASSERT(next->previousSibling() == prev);
+ next->setPreviousSibling(child.get());
+ } else {
+ ASSERT(m_lastChild == prev);
+ m_lastChild = child.get();
+ }
+ child->setParent(this);
+ child->setPreviousSibling(prev.get());
+ child->setNextSibling(next);
allowEventDispatch();
- childrenChanged(false, prev.get(), next.get(), 1);
- notifyChildInserted(child);
-
+ childrenChanged(false, prev.get(), next, 1);
+ notifyChildInserted(child.get());
+
// Add child to the rendering tree
if (attached() && !child->attached() && child->parentNode() == this) {
if (shouldLazyAttach)
@@ -340,8 +357,10 @@
// Now that the child is attached to the render tree, dispatch
// the relevant mutation events.
- dispatchChildInsertionEvents(child);
+ dispatchChildInsertionEvents(child.get());
+
prev = child;
+ child = nextChild.release();
}
dispatchSubtreeModifiedEvent();
@@ -620,7 +639,13 @@
// Append child to the end of the list
forbidEventDispatch();
- appendChildToContainer(child, this);
+ child->setParent(this);
+ if (m_lastChild) {
+ child->setPreviousSibling(m_lastChild);
+ m_lastChild->setNextSibling(child);
+ } else
+ m_firstChild = child;
+ m_lastChild = child;
allowEventDispatch();
// Send notification about the children change.
@@ -653,7 +678,7 @@
forbidEventDispatch();
Node* last = m_lastChild;
// FIXME: This method should take a PassRefPtr.
- appendChildToContainer(newChild.get(), this);
+ appendChildToContainer<Node, ContainerNode>(newChild.get(), this);
treeScope()->adoptIfNeeded(newChild.get());
allowEventDispatch();