Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 342283005: Make collection caching code more consistent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 77fd24eda9f1ea4bb39e51cc0e0fda2cadfe1af8..7779c3a5c8d919aed1f7339b69af4f0e9b49686a 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -1098,7 +1098,7 @@ void ContainerNode::setHovered(bool over)
PassRefPtrWillBeRawPtr<HTMLCollection> ContainerNode::children()
{
- return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, NodeChildren);
+ return ensureCachedCollection<HTMLCollection>(NodeChildren);
}
unsigned ContainerNode::countChildren() const
@@ -1354,8 +1354,8 @@ PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagName(const
return nullptr;
if (document().isHTMLDocument())
- return ensureRareData().ensureNodeLists().addCache<HTMLTagCollection>(*this, HTMLTagCollectionType, localName);
- return ensureRareData().ensureNodeLists().addCache<TagCollection>(*this, TagCollectionType, localName);
+ return ensureCachedCollection<HTMLTagCollection>(HTMLTagCollectionType, localName);
+ return ensureCachedCollection<TagCollection>(TagCollectionType, localName);
}
PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName)
@@ -1366,28 +1366,28 @@ PassRefPtrWillBeRawPtr<TagCollection> ContainerNode::getElementsByTagNameNS(cons
if (namespaceURI == starAtom)
return getElementsByTagName(localName);
- return ensureRareData().ensureNodeLists().addCache(*this, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
+ return ensureCachedCollection<TagCollection>(TagCollectionType, namespaceURI.isEmpty() ? nullAtom : namespaceURI, localName);
}
// Takes an AtomicString in argument because it is common for elements to share the same name attribute.
// Therefore, the NameNodeList factory function expects an AtomicString type.
PassRefPtrWillBeRawPtr<NameNodeList> ContainerNode::getElementsByName(const AtomicString& elementName)
{
- return ensureRareData().ensureNodeLists().addCache<NameNodeList>(*this, NameNodeListType, elementName);
+ return ensureCachedCollection<NameNodeList>(NameNodeListType, elementName);
}
// Takes an AtomicString in argument because it is common for elements to share the same set of class names.
// Therefore, the ClassNodeList factory function expects an AtomicString type.
PassRefPtrWillBeRawPtr<ClassCollection> ContainerNode::getElementsByClassName(const AtomicString& classNames)
{
- return ensureRareData().ensureNodeLists().addCache<ClassCollection>(*this, ClassCollectionType, classNames);
+ return ensureCachedCollection<ClassCollection>(ClassCollectionType, classNames);
}
PassRefPtrWillBeRawPtr<RadioNodeList> ContainerNode::radioNodeList(const AtomicString& name, bool onlyMatchImgElements)
{
ASSERT(isHTMLFormElement(this) || isHTMLFieldSetElement(this));
CollectionType type = onlyMatchImgElements ? RadioImgNodeListType : RadioNodeListType;
- return ensureRareData().ensureNodeLists().addCache<RadioNodeList>(*this, type, name);
+ return ensureCachedCollection<RadioNodeList>(type, name);
}
Element* ContainerNode::getElementById(const AtomicString& id) const
@@ -1410,6 +1410,11 @@ Element* ContainerNode::getElementById(const AtomicString& id) const
return 0;
}
+NodeListsNodeData& ContainerNode::ensureNodeLists()
+{
+ return ensureRareData().ensureNodeLists();
+}
+
#if ENABLE(ASSERT)
bool childAttachedAllowedWhenAttachingChildren(ContainerNode* node)
{
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698