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

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

Issue 305963014: Introduce and use type casting functions for several HTMLCollection types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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/bindings/v8/custom/V8HTMLCollectionCustom.cpp ('k') | Source/core/dom/TagCollection.h » ('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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 David Smith (catfish.man@gmail.com) 3 * Copyright (C) 2007 David Smith (catfish.man@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 bool elementMatches(const Element&) const; 51 bool elementMatches(const Element&) const;
52 52
53 private: 53 private:
54 ClassCollection(ContainerNode& rootNode, const AtomicString& classNames); 54 ClassCollection(ContainerNode& rootNode, const AtomicString& classNames);
55 55
56 SpaceSplitString m_classNames; 56 SpaceSplitString m_classNames;
57 AtomicString m_originalClassNames; 57 AtomicString m_originalClassNames;
58 }; 58 };
59 59
60 DEFINE_TYPE_CASTS(ClassCollection, LiveNodeListBase, collection, collection->typ e() == ClassCollectionType, collection.type() == ClassCollectionType);
61
60 inline bool ClassCollection::elementMatches(const Element& testElement) const 62 inline bool ClassCollection::elementMatches(const Element& testElement) const
61 { 63 {
62 if (!testElement.hasClass()) 64 if (!testElement.hasClass())
63 return false; 65 return false;
64 if (!m_classNames.size()) 66 if (!m_classNames.size())
65 return false; 67 return false;
66 // FIXME: DOM4 allows getElementsByClassName to return non StyledElement. 68 // FIXME: DOM4 allows getElementsByClassName to return non StyledElement.
67 // https://bugs.webkit.org/show_bug.cgi?id=94718 69 // https://bugs.webkit.org/show_bug.cgi?id=94718
68 if (!testElement.isStyledElement()) 70 if (!testElement.isStyledElement())
69 return false; 71 return false;
70 return testElement.classNames().containsAll(m_classNames); 72 return testElement.classNames().containsAll(m_classNames);
71 } 73 }
72 74
73 } // namespace WebCore 75 } // namespace WebCore
74 76
75 #endif // ClassCollection_h 77 #endif // ClassCollection_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8HTMLCollectionCustom.cpp ('k') | Source/core/dom/TagCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698