- Revision
- 109026
- Author
- ad...@chromium.org
- Date
- 2012-02-27 14:53:25 -0800 (Mon, 27 Feb 2012)
Log Message
Move WebCore-internal DOM notification methods from Node to ContainerNode where appropriate
https://bugs.webkit.org/show_bug.cgi?id=79697
Reviewed by Ryosuke Niwa.
insertedIntoTree/removedFromTree are only used by subclasses of
ContainerNode. Moreover, attempting to make use of these notifications
in a non-container Node would currently not work, because
Node::removedFromDocument/insertedIntoDocument do not dispatch to these methods.
Rather than adding useless calls to an always-empty virtual method,
this patch moves these methods to ContainerNode.
Meanwhile, childrenChanged moves to ContainerNode for an obvious reason:
non-container Nodes have no children to change.
No new tests, refactoring only.
* dom/Attr.cpp:
(WebCore::Attr::childrenChanged): Remove call to now-nonexistent Node::childrenChanged.
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChild): Check that the removed child is a container node before notifying it of removal.
(WebCore::ContainerNode::parserRemoveChild): ditto.
(WebCore::ContainerNode::insertedIntoTree): Remove call to now-nonexistent Node::insertedIntoTree.
(WebCore::ContainerNode::removedFromTree): Remove call to now-nonexistent Node::removedFromTree.
(WebCore::ContainerNode::childrenChanged): Remove call to now-nonexistent Node::childrenChanged.
(WebCore::notifyChildInserted): Check that the inserted child is a container node before notifying it of insertion.
* dom/ContainerNode.h:
(ContainerNode): Migrate comments from Node.h, point back at it for more notification methods.
* dom/Node.h:
(Node): Move methods, update comments to point at ContainerNode.h.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (109025 => 109026)
--- trunk/Source/WebCore/ChangeLog 2012-02-27 22:19:27 UTC (rev 109025)
+++ trunk/Source/WebCore/ChangeLog 2012-02-27 22:53:25 UTC (rev 109026)
@@ -1,3 +1,36 @@
+2012-02-27 Adam Klein <ad...@chromium.org>
+
+ Move WebCore-internal DOM notification methods from Node to ContainerNode where appropriate
+ https://bugs.webkit.org/show_bug.cgi?id=79697
+
+ Reviewed by Ryosuke Niwa.
+
+ insertedIntoTree/removedFromTree are only used by subclasses of
+ ContainerNode. Moreover, attempting to make use of these notifications
+ in a non-container Node would currently not work, because
+ Node::removedFromDocument/insertedIntoDocument do not dispatch to these methods.
+ Rather than adding useless calls to an always-empty virtual method,
+ this patch moves these methods to ContainerNode.
+
+ Meanwhile, childrenChanged moves to ContainerNode for an obvious reason:
+ non-container Nodes have no children to change.
+
+ No new tests, refactoring only.
+
+ * dom/Attr.cpp:
+ (WebCore::Attr::childrenChanged): Remove call to now-nonexistent Node::childrenChanged.
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::removeChild): Check that the removed child is a container node before notifying it of removal.
+ (WebCore::ContainerNode::parserRemoveChild): ditto.
+ (WebCore::ContainerNode::insertedIntoTree): Remove call to now-nonexistent Node::insertedIntoTree.
+ (WebCore::ContainerNode::removedFromTree): Remove call to now-nonexistent Node::removedFromTree.
+ (WebCore::ContainerNode::childrenChanged): Remove call to now-nonexistent Node::childrenChanged.
+ (WebCore::notifyChildInserted): Check that the inserted child is a container node before notifying it of insertion.
+ * dom/ContainerNode.h:
+ (ContainerNode): Migrate comments from Node.h, point back at it for more notification methods.
+ * dom/Node.h:
+ (Node): Move methods, update comments to point at ContainerNode.h.
+
2012-02-27 Chris Rogers <crog...@google.com>
Implement static compression curve parameters for DynamicsCompressorNode
Modified: trunk/Source/WebCore/dom/Attr.cpp (109025 => 109026)
--- trunk/Source/WebCore/dom/Attr.cpp 2012-02-27 22:19:27 UTC (rev 109025)
+++ trunk/Source/WebCore/dom/Attr.cpp 2012-02-27 22:53:25 UTC (rev 109026)
@@ -172,8 +172,6 @@
if (m_ignoreChildrenChanged > 0)
return;
- Node::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
-
invalidateNodeListsCacheAfterAttributeChanged(m_attribute->name());
// FIXME: We should include entity references in the value
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (109025 => 109026)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-02-27 22:19:27 UTC (rev 109025)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-02-27 22:53:25 UTC (rev 109026)
@@ -463,8 +463,8 @@
if (child->inDocument())
child->removedFromDocument();
- else
- child->removedFromTree(true);
+ else if (child->isContainerNode())
+ toContainerNode(child.get())->removedFromTree(true);
dispatchSubtreeModifiedEvent();
@@ -513,8 +513,8 @@
childrenChanged(true, prev, next, -1);
if (oldChild->inDocument())
oldChild->removedFromDocument();
- else
- oldChild->removedFromTree(true);
+ else if (oldChild->isContainerNode())
+ toContainerNode(oldChild)->removedFromTree(true);
}
// this differs from other remove functions because it forcibly removes all the children,
@@ -812,21 +812,24 @@
{
if (!deep)
return;
- for (Node* child = m_firstChild; child; child = child->nextSibling())
- child->insertedIntoTree(true);
+ for (Node* child = m_firstChild; child; child = child->nextSibling()) {
+ if (child->isContainerNode())
+ toContainerNode(child)->insertedIntoTree(true);
+ }
}
void ContainerNode::removedFromTree(bool deep)
{
if (!deep)
return;
- for (Node* child = m_firstChild; child; child = child->nextSibling())
- child->removedFromTree(true);
+ for (Node* child = m_firstChild; child; child = child->nextSibling()) {
+ if (child->isContainerNode())
+ toContainerNode(child)->removedFromTree(true);
+ }
}
void ContainerNode::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
{
- Node::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
if (!changedByParser && childCountDelta)
document()->updateRangesAfterChildrenChanged(this);
invalidateNodeListsCacheAfterChildrenChanged();
@@ -1085,8 +1088,8 @@
Node* parentOrHostNode = c->parentOrHostNode();
if (parentOrHostNode && parentOrHostNode->inDocument())
c->insertedIntoDocument();
- else
- c->insertedIntoTree(true);
+ else if (c->isContainerNode())
+ toContainerNode(c.get())->insertedIntoTree(true);
document->incDOMTreeVersion();
}
Modified: trunk/Source/WebCore/dom/ContainerNode.h (109025 => 109026)
--- trunk/Source/WebCore/dom/ContainerNode.h 2012-02-27 22:19:27 UTC (rev 109025)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2012-02-27 22:53:25 UTC (rev 109026)
@@ -79,11 +79,21 @@
virtual void setHovered(bool = true) OVERRIDE;
virtual void insertedIntoDocument() OVERRIDE;
virtual void removedFromDocument() OVERRIDE;
- virtual void insertedIntoTree(bool deep) OVERRIDE;
- virtual void removedFromTree(bool deep) OVERRIDE;
- virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange) OVERRIDE;
+ // -----------------------------------------------------------------------------
+ // Notification of document structure changes (see Node.h for more notification methods)
+
+ // These functions are called whenever you are connected or disconnected from a tree. That tree may be the main
+ // document tree, or it could be another disconnected tree. Override these functions to do any work that depends
+ // on connectedness to some ancestor (e.g., an ancestor <form>).
+ virtual void insertedIntoTree(bool deep);
+ virtual void removedFromTree(bool deep);
+
+ // Notifies the node that it's list of children have changed (either by adding or removing child nodes), or a child
+ // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE has changed its value.
+ virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
+
protected:
ContainerNode(Document*, ConstructionType = CreateContainer);
Modified: trunk/Source/WebCore/dom/Node.h (109025 => 109026)
--- trunk/Source/WebCore/dom/Node.h 2012-02-27 22:19:27 UTC (rev 109025)
+++ trunk/Source/WebCore/dom/Node.h 2012-02-27 22:53:25 UTC (rev 109026)
@@ -510,7 +510,7 @@
RenderStyle* computedStyle(PseudoId pseudoElementSpecifier = NOPSEUDO) { return virtualComputedStyle(pseudoElementSpecifier); }
// -----------------------------------------------------------------------------
- // Notification of document structure changes
+ // Notification of document structure changes (see ContainerNode.h for more notification methods)
// Notifies the node that it has been inserted into the document. This is called during document parsing, and also
// when a node is added through the DOM methods insertBefore(), appendChild() or replaceChild(). Note that this only
@@ -528,16 +528,6 @@
// dispatching, and is called _after_ the node is removed from the tree.
virtual void removedFromDocument();
- // These functions are called whenever you are connected or disconnected from a tree. That tree may be the main
- // document tree, or it could be another disconnected tree. Override these functions to do any work that depends
- // on connectedness to some ancestor (e.g., an ancestor <form> for example).
- virtual void insertedIntoTree(bool /*deep*/) { }
- virtual void removedFromTree(bool /*deep*/) { }
-
- // Notifies the node that it's list of children have changed (either by adding or removing child nodes), or a child
- // node that is of the type CDATA_SECTION_NODE, TEXT_NODE or COMMENT_NODE has changed its value.
- virtual void childrenChanged(bool /*changedByParser*/ = false, Node* /*beforeChange*/ = 0, Node* /*afterChange*/ = 0, int /*childCountDelta*/ = 0) { }
-
#ifndef NDEBUG
virtual void formatForDebugger(char* buffer, unsigned length) const;