- Revision
- 140784
- Author
- [email protected]
- Date
- 2013-01-24 22:45:39 -0800 (Thu, 24 Jan 2013)
Log Message
Refactoring: The name ContainerNode::removeChildren and ContainerNde::removeAllChilren() is confusing
https://bugs.webkit.org/show_bug.cgi?id=107640
Reviewed by Eric Seidel.
This change renames unsafe removeAllChilren() function to
removeDetachedChildren() and move it to protected visibility.
In theory, the removed nodes should be detached() before. But some
tests violates that assumption. It should be fixed.
No new tests. No behavior change.
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeDetachedChildren):
(WebCore::ContainerNode::takeAllChildrenFrom):
(WebCore::ContainerNode::~ContainerNode):
* dom/ContainerNode.h:
(ContainerNode):
* dom/ContainerNodeAlgorithms.h:
(WebCore::removeDetachedChildrenInContainer):
(WebCore):
* dom/Document.cpp:
(WebCore::Document::removedLastRef):
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::~ShadowRoot):
* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::detach):
* svg/SVGElementInstance.h:
(SVGElementInstance):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (140783 => 140784)
--- trunk/Source/WebCore/ChangeLog 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/ChangeLog 2013-01-25 06:45:39 UTC (rev 140784)
@@ -1,3 +1,36 @@
+2013-01-24 Hajime Morrita <[email protected]>
+
+ Refactoring: The name ContainerNode::removeChildren and ContainerNde::removeAllChilren() is confusing
+ https://bugs.webkit.org/show_bug.cgi?id=107640
+
+ Reviewed by Eric Seidel.
+
+ This change renames unsafe removeAllChilren() function to
+ removeDetachedChildren() and move it to protected visibility.
+
+ In theory, the removed nodes should be detached() before. But some
+ tests violates that assumption. It should be fixed.
+
+ No new tests. No behavior change.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::removeDetachedChildren):
+ (WebCore::ContainerNode::takeAllChildrenFrom):
+ (WebCore::ContainerNode::~ContainerNode):
+ * dom/ContainerNode.h:
+ (ContainerNode):
+ * dom/ContainerNodeAlgorithms.h:
+ (WebCore::removeDetachedChildrenInContainer):
+ (WebCore):
+ * dom/Document.cpp:
+ (WebCore::Document::removedLastRef):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::~ShadowRoot):
+ * svg/SVGElementInstance.cpp:
+ (WebCore::SVGElementInstance::detach):
+ * svg/SVGElementInstance.h:
+ (SVGElementInstance):
+
2013-01-24 Keishi Hattori <[email protected]>
Adjust design of the Calendar Picker
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (140783 => 140784)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2013-01-25 06:45:39 UTC (rev 140784)
@@ -90,16 +90,17 @@
toContainerNode(node)->removeChildren();
}
-void ContainerNode::removeAllChildren()
+void ContainerNode::removeDetachedChildren()
{
- removeAllChildrenInContainer<Node, ContainerNode>(this);
+ // FIXME: We should be able to ASSERT(!attached()) here: https://bugs.webkit.org/show_bug.cgi?id=107801
+ removeDetachedChildrenInContainer<Node, ContainerNode>(this);
}
void ContainerNode::takeAllChildrenFrom(ContainerNode* oldParent)
{
NodeVector children;
getChildNodes(oldParent, children);
- oldParent->removeAllChildren();
+ oldParent->removeDetachedChildren();
for (unsigned i = 0; i < children.size(); ++i) {
ExceptionCode ec = 0;
@@ -123,7 +124,7 @@
if (AXObjectCache::accessibilityEnabled() && documentInternal() && documentInternal()->axObjectCacheExists())
documentInternal()->axObjectCache()->remove(this);
- removeAllChildren();
+ removeDetachedChildren();
}
static inline bool isChildTypeAllowed(ContainerNode* newParent, Node* child)
Modified: trunk/Source/WebCore/dom/ContainerNode.h (140783 => 140784)
--- trunk/Source/WebCore/dom/ContainerNode.h 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2013-01-25 06:45:39 UTC (rev 140784)
@@ -101,11 +101,7 @@
void parserRemoveChild(Node*);
void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild);
- // FIXME: It's not good to have two functions with such similar names, especially public functions.
- // How do removeChildren and removeAllChildren differ?
void removeChildren();
- void removeAllChildren();
-
void takeAllChildrenFrom(ContainerNode*);
void cloneChildNodes(ContainerNode* clone);
@@ -154,6 +150,7 @@
template<class GenericNode, class GenericNodeContainer>
friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
+ void removeDetachedChildren();
void setFirstChild(Node* child) { m_firstChild = child; }
void setLastChild(Node* child) { m_lastChild = child; }
Modified: trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h (140783 => 140784)
--- trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h 2013-01-25 06:45:39 UTC (rev 140784)
@@ -78,7 +78,7 @@
// Helper functions for TreeShared-derived classes, which have a 'Node' style interface
// This applies to 'ContainerNode' and 'SVGElementInstance'
template<class GenericNode, class GenericNodeContainer>
-inline void removeAllChildrenInContainer(GenericNodeContainer* container)
+inline void removeDetachedChildrenInContainer(GenericNodeContainer* container)
{
// List of nodes to be deleted.
GenericNode* head = 0;
@@ -120,7 +120,7 @@
container->setLastChild(child);
}
-// Helper methods for removeAllChildrenInContainer, hidden from WebCore namespace
+// Helper methods for removeDetachedChildrenInContainer, hidden from WebCore namespace
namespace Private {
template<class GenericNode, class GenericNodeContainer, bool dispatchRemovalNotification>
Modified: trunk/Source/WebCore/dom/Document.cpp (140783 => 140784)
--- trunk/Source/WebCore/dom/Document.cpp 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-01-25 06:45:39 UTC (rev 140784)
@@ -656,7 +656,7 @@
if (m_guardRefCount) {
// If removing a child removes the last self-only ref, we don't
// want the scope to be destructed until after
- // removeAllChildren returns, so we guard ourselves with an
+ // removeDetachedChildren returns, so we guard ourselves with an
// extra self-only ref.
guardRef();
@@ -677,10 +677,10 @@
detachParser();
- // removeAllChildren() doesn't always unregister IDs,
+ // removeDetachedChildren() doesn't always unregister IDs,
// so tear down scope information upfront to avoid having stale references in the map.
destroyTreeScopeData();
- removeAllChildren();
+ removeDetachedChildren();
m_markers->detach();
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (140783 => 140784)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2013-01-25 06:45:39 UTC (rev 140784)
@@ -86,7 +86,7 @@
// We must remove all of our children first before the TreeScope destructor
// runs so we don't go through TreeScopeAdopter for each child with a
// destructed tree scope in each descendant.
- removeAllChildren();
+ removeDetachedChildren();
// We must call clearRareData() here since a ShadowRoot class inherits TreeScope
// as well as Node. See a comment on TreeScope.h for the reason.
Modified: trunk/Source/WebCore/svg/SVGElementInstance.cpp (140783 => 140784)
--- trunk/Source/WebCore/svg/SVGElementInstance.cpp 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/svg/SVGElementInstance.cpp 2013-01-25 06:45:39 UTC (rev 140784)
@@ -101,7 +101,7 @@
m_directUseElement = 0;
m_correspondingUseElement = 0;
- removeAllChildrenInContainer<SVGElementInstance, SVGElementInstance>(this);
+ removeDetachedChildrenInContainer<SVGElementInstance, SVGElementInstance>(this);
}
PassRefPtr<SVGElementInstanceList> SVGElementInstance::childNodes()
Modified: trunk/Source/WebCore/svg/SVGElementInstance.h (140783 => 140784)
--- trunk/Source/WebCore/svg/SVGElementInstance.h 2013-01-25 06:38:54 UTC (rev 140783)
+++ trunk/Source/WebCore/svg/SVGElementInstance.h 2013-01-25 06:45:39 UTC (rev 140784)
@@ -161,7 +161,7 @@
friend void appendChildToContainer(GenericNode* child, GenericNodeContainer* container);
template<class GenericNode, class GenericNodeContainer>
- friend void removeAllChildrenInContainer(GenericNodeContainer* container);
+ friend void removeDetachedChildrenInContainer(GenericNodeContainer*);
template<class GenericNode, class GenericNodeContainer>
friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer* container);