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

Unified Diff: Source/core/dom/TagCollection.h

Issue 143453010: Have getElementsByClassName() / getElementsByTagName*() return an HTMLCollection (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Null HTMLCollection handling Created 6 years, 11 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
Index: Source/core/dom/TagCollection.h
diff --git a/Source/core/dom/TagNodeList.h b/Source/core/dom/TagCollection.h
similarity index 50%
rename from Source/core/dom/TagNodeList.h
rename to Source/core/dom/TagCollection.h
index 282fffc0e06e61aa32ff487804cd12fb0ca65301..393741ed8d1fccfc472b8f0e761aae676f1c3ac1 100644
--- a/Source/core/dom/TagNodeList.h
+++ b/Source/core/dom/TagCollection.h
@@ -21,65 +21,63 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef TagNodeList_h
-#define TagNodeList_h
+#ifndef TagCollection_h
+#define TagCollection_h
#include "core/dom/Element.h"
-#include "core/dom/LiveNodeList.h"
+#include "core/html/HTMLCollection.h"
#include "wtf/text/AtomicString.h"
namespace WebCore {
-// NodeList that limits to a particular tag.
-class TagNodeList : public LiveNodeList {
+// Collection that limits to a particular tag.
+class TagCollection : public HTMLCollection {
public:
- static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
+ static PassRefPtr<TagCollection> create(ContainerNode* rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
{
ASSERT(namespaceURI != starAtom);
- return adoptRef(new TagNodeList(rootNode, TagNodeListType, namespaceURI, localName));
+ return adoptRef(new TagCollection(rootNode, TagCollectionType, namespaceURI, localName));
}
- static PassRefPtr<TagNodeList> create(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& localName)
+ static PassRefPtr<TagCollection> create(ContainerNode* rootNode, CollectionType type, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == TagNodeListType);
- return adoptRef(new TagNodeList(rootNode, TagNodeListType, starAtom, localName));
+ ASSERT_UNUSED(type, type == TagCollectionType);
+ return adoptRef(new TagCollection(rootNode, TagCollectionType, starAtom, localName));
}
- virtual ~TagNodeList();
+ virtual ~TagCollection();
-protected:
- TagNodeList(PassRefPtr<ContainerNode> rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
+ bool elementMatches(const Element&) const;
- virtual bool nodeMatches(const Element&) const OVERRIDE;
+protected:
+ TagCollection(ContainerNode* rootNode, CollectionType, const AtomicString& namespaceURI, const AtomicString& localName);
AtomicString m_namespaceURI;
AtomicString m_localName;
};
-class HTMLTagNodeList FINAL : public TagNodeList {
+class HTMLTagCollection FINAL : public TagCollection {
public:
- static PassRefPtr<HTMLTagNodeList> create(PassRefPtr<ContainerNode> rootNode, CollectionType type, const AtomicString& localName)
+ static PassRefPtr<HTMLTagCollection> create(ContainerNode* rootNode, CollectionType type, const AtomicString& localName)
{
- ASSERT_UNUSED(type, type == HTMLTagNodeListType);
- return adoptRef(new HTMLTagNodeList(rootNode, localName));
+ ASSERT_UNUSED(type, type == HTMLTagCollectionType);
+ return adoptRef(new HTMLTagCollection(rootNode, localName));
}
- bool nodeMatchesInlined(const Element&) const;
+ bool elementMatches(const Element&) const;
private:
- HTMLTagNodeList(PassRefPtr<ContainerNode> rootNode, const AtomicString& localName);
-
- virtual bool nodeMatches(const Element&) const OVERRIDE;
+ HTMLTagCollection(ContainerNode* rootNode, const AtomicString& localName);
AtomicString m_loweredLocalName;
};
-inline bool HTMLTagNodeList::nodeMatchesInlined(const Element& testNode) const
+inline bool HTMLTagCollection::elementMatches(const Element& testElement) const
{
// Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-getelementsbytagname
if (m_localName != starAtom) {
- const AtomicString& localName = testNode.isHTMLElement() ? m_loweredLocalName : m_localName;
- if (localName != testNode.localName())
+ const AtomicString& localName = testElement.isHTMLElement() ? m_loweredLocalName : m_localName;
+ if (localName != testElement.localName())
return false;
}
ASSERT(m_namespaceURI == starAtom);
@@ -88,4 +86,4 @@ inline bool HTMLTagNodeList::nodeMatchesInlined(const Element& testNode) const
} // namespace WebCore
-#endif // TagNodeList_h
+#endif // TagCollection_h

Powered by Google App Engine
This is Rietveld 408576698