Commit 8e1efe5b authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Get rid of unnecessary isChildNodeList() virtual call in clearChildNodeListCache()

This CL inlines clearChildNodeListCache() in the caller as there is only one to
avoid an unnecessary isChildNodeList() virtual call. The calling method is
invalidateNodeListCachesInAncestors(), which this CL moves from Node to
ContainerNode to make sure it is only called for ContainerNodes (Only
ContainerNodes' node lists have caches that need invalidation).

R=adamk@chromium.org, esprehn@chromium.org

Review URL: https://codereview.chromium.org/413763004

git-svn-id: svn://svn.chromium.org/blink/trunk@179056 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1a87ea2e
......@@ -1324,6 +1324,30 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Nod
}
}
void ContainerNode::invalidateNodeListCachesInAncestors(const QualifiedName* attrName, Element* attributeOwnerElement)
{
if (hasRareData() && (!attrName || isAttributeNode())) {
if (NodeListsNodeData* lists = rareData()->nodeLists()) {
if (ChildNodeList* childNodeList = lists->childNodeList(*this))
childNodeList->invalidateCache();
}
}
// Modifications to attributes that are not associated with an Element can't invalidate NodeList caches.
if (attrName && !attributeOwnerElement)
return;
if (!document().shouldInvalidateNodeListCaches(attrName))
return;
document().invalidateNodeListCaches(attrName);
for (ContainerNode* node = this; node; node = node->parentNode()) {
if (NodeListsNodeData* lists = node->nodeLists())
lists->invalidateCaches(attrName);
}
}
PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagName(const AtomicString& localName)
{
if (localName.isNull())
......
......@@ -178,6 +178,8 @@ public:
protected:
ContainerNode(TreeScope*, ConstructionType = CreateContainer);
void invalidateNodeListCachesInAncestors(const QualifiedName* attrName = 0, Element* attributeOwnerElement = 0);
#if !ENABLE(OILPAN)
void removeDetachedChildren();
#endif
......
......@@ -838,28 +838,6 @@ unsigned Node::nodeIndex() const
return count;
}
void Node::invalidateNodeListCachesInAncestors(const QualifiedName* attrName, Element* attributeOwnerElement)
{
if (hasRareData() && (!attrName || isAttributeNode())) {
if (NodeListsNodeData* lists = rareData()->nodeLists())
lists->clearChildNodeListCache();
}
// Modifications to attributes that are not associated with an Element can't invalidate NodeList caches.
if (attrName && !attributeOwnerElement)
return;
if (!document().shouldInvalidateNodeListCaches(attrName))
return;
document().invalidateNodeListCaches(attrName);
for (Node* node = this; node; node = node->parentNode()) {
if (NodeListsNodeData* lists = node->nodeLists())
lists->invalidateCaches(attrName);
}
}
NodeListsNodeData* Node::nodeLists()
{
return hasRareData() ? rareData()->nodeLists() : 0;
......
......@@ -591,7 +591,6 @@ public:
void showTreeForThisAcrossFrame() const;
#endif
void invalidateNodeListCachesInAncestors(const QualifiedName* attrName = 0, Element* attributeOwnerElement = 0);
NodeListsNodeData* nodeLists();
void clearNodeLists();
......
......@@ -37,10 +37,10 @@ class NodeListsNodeData FINAL : public NoBaseWillBeGarbageCollectedFinalized<Nod
WTF_MAKE_NONCOPYABLE(NodeListsNodeData);
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
void clearChildNodeListCache()
ChildNodeList* childNodeList(ContainerNode& node)
{
if (m_childNodeList && m_childNodeList->isChildNodeList())
toChildNodeList(m_childNodeList)->invalidateCache();
ASSERT_UNUSED(node, !m_childNodeList || node == m_childNodeList->virtualOwnerNode());
return toChildNodeList(m_childNodeList);
}
PassRefPtrWillBeRawPtr<ChildNodeList> ensureChildNodeList(ContainerNode& node)
......
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