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

Side by Side Diff: Source/core/dom/TagCollection.h

Issue 355163004: Move HTMLTagCollection to its own file (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/TagCollection.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #ifndef TagCollection_h 24 #ifndef TagCollection_h
25 #define TagCollection_h 25 #define TagCollection_h
26 26
27 #include "core/dom/Element.h"
28 #include "core/html/HTMLCollection.h" 27 #include "core/html/HTMLCollection.h"
29 #include "wtf/text/AtomicString.h" 28 #include "wtf/text/AtomicString.h"
30 29
31 namespace WebCore { 30 namespace WebCore {
32 31
33 // Collection that limits to a particular tag. 32 // Collection that limits to a particular tag.
34 class TagCollection : public HTMLCollection { 33 class TagCollection : public HTMLCollection {
35 public: 34 public:
36 static PassRefPtrWillBeRawPtr<TagCollection> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName) 35 static PassRefPtrWillBeRawPtr<TagCollection> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)
37 { 36 {
(...skipping 13 matching lines...) Expand all
51 50
52 protected: 51 protected:
53 TagCollection(ContainerNode& rootNode, CollectionType, const AtomicString& n amespaceURI, const AtomicString& localName); 52 TagCollection(ContainerNode& rootNode, CollectionType, const AtomicString& n amespaceURI, const AtomicString& localName);
54 53
55 AtomicString m_namespaceURI; 54 AtomicString m_namespaceURI;
56 AtomicString m_localName; 55 AtomicString m_localName;
57 }; 56 };
58 57
59 DEFINE_TYPE_CASTS(TagCollection, LiveNodeListBase, collection, collection->type( ) == TagCollectionType, collection.type() == TagCollectionType); 58 DEFINE_TYPE_CASTS(TagCollection, LiveNodeListBase, collection, collection->type( ) == TagCollectionType, collection.type() == TagCollectionType);
60 59
61 class HTMLTagCollection FINAL : public TagCollection {
62 public:
63 static PassRefPtrWillBeRawPtr<HTMLTagCollection> create(ContainerNode& rootN ode, CollectionType type, const AtomicString& localName)
64 {
65 ASSERT_UNUSED(type, type == HTMLTagCollectionType);
66 return adoptRefWillBeNoop(new HTMLTagCollection(rootNode, localName));
67 }
68
69 bool elementMatches(const Element&) const;
70
71 private:
72 HTMLTagCollection(ContainerNode& rootNode, const AtomicString& localName);
73
74 AtomicString m_loweredLocalName;
75 };
76
77 DEFINE_TYPE_CASTS(HTMLTagCollection, LiveNodeListBase, collection, collection->t ype() == HTMLTagCollectionType, collection.type() == HTMLTagCollectionType);
78
79 inline bool HTMLTagCollection::elementMatches(const Element& testElement) const
80 {
81 // Implements http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#conce pt-getelementsbytagname
82 if (m_localName != starAtom) {
83 const AtomicString& localName = testElement.isHTMLElement() ? m_loweredL ocalName : m_localName;
84 if (localName != testElement.localName())
85 return false;
86 }
87 ASSERT(m_namespaceURI == starAtom);
88 return true;
89 }
90
91 } // namespace WebCore 60 } // namespace WebCore
92 61
93 #endif // TagCollection_h 62 #endif // TagCollection_h
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/TagCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698