Modified: trunk/Source/WebCore/ChangeLog (149126 => 149127)
--- trunk/Source/WebCore/ChangeLog 2013-04-25 18:32:06 UTC (rev 149126)
+++ trunk/Source/WebCore/ChangeLog 2013-04-25 18:33:22 UTC (rev 149127)
@@ -1,5 +1,21 @@
2013-04-25 Ryosuke Niwa <[email protected]>
+ cloneChildNodes looks for deleteButtonController in each level of recursion
+ https://bugs.webkit.org/show_bug.cgi?id=115146
+
+ Reviewed by Andreas Kling.
+
+ Obtain the delete button controller upfront, and shallow copy descendents of each child
+ so that we don't look for the delete button controller inside cloneNode called on each child.
+
+ Performance Tests: DOM/CloneNodes.html
+
+ * dom/ContainerNode.cpp:
+ (WebCore::cloneChildNodesAvoidingDeleteButon): Extracted.
+ (WebCore::ContainerNode::cloneChildNodes):
+
+2013-04-25 Ryosuke Niwa <[email protected]>
+
HTMLOptionsCollection's namedItem and name getter should return the first item
https://bugs.webkit.org/show_bug.cgi?id=115150
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (149126 => 149127)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2013-04-25 18:32:06 UTC (rev 149126)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2013-04-25 18:33:22 UTC (rev 149127)
@@ -2,7 +2,7 @@
* Copyright (C) 1999 Lars Knoll ([email protected])
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2001 Dirk Mueller ([email protected])
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -831,21 +831,36 @@
invalidateNodeListCachesInAncestors();
}
+inline static void cloneChildNodesAvoidingDeleteButton(ContainerNode* parent, ContainerNode* clonedParent, HTMLElement* deleteButtonContainerElement)
+{
+ ExceptionCode ec = 0;
+ for (Node* child = parent->firstChild(); child && !ec; child = child->nextSibling()) {
+
+#if ENABLE(DELETION_UI)
+ if (child == deleteButtonContainerElement)
+ continue;
+#else
+ UNUSED_PARAM(deleteButtonContainerElement);
+#endif
+
+ RefPtr<Node> clonedChild = child->cloneNode(false);
+ clonedParent->appendChild(clonedChild, ec);
+
+ if (!ec && child->isContainerNode())
+ cloneChildNodesAvoidingDeleteButton(toContainerNode(child), toContainerNode(clonedChild.get()), deleteButtonContainerElement);
+ }
+}
+
void ContainerNode::cloneChildNodes(ContainerNode *clone)
{
#if ENABLE(DELETION_UI)
HTMLElement* deleteButtonContainerElement = 0;
if (Frame* frame = document()->frame())
deleteButtonContainerElement = frame->editor()->deleteButtonController()->containerElement();
+ cloneChildNodesAvoidingDeleteButton(this, clone, deleteButtonContainerElement);
+#else
+ cloneChildNodesAvoidingDeleteButton(this, clone, 0);
#endif
- ExceptionCode ec = 0;
- for (Node* n = firstChild(); n && !ec; n = n->nextSibling()) {
-#if ENABLE(DELETION_UI)
- if (n == deleteButtonContainerElement)
- continue;
-#endif
- clone->appendChild(n->cloneNode(true), ec);
- }
}
bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const