| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 #define ClassCollection_h | 31 #define ClassCollection_h |
| 32 | 32 |
| 33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 34 #include "core/dom/SpaceSplitString.h" | 34 #include "core/dom/SpaceSplitString.h" |
| 35 #include "core/html/HTMLCollection.h" | 35 #include "core/html/HTMLCollection.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 class ClassCollection final : public HTMLCollection { | 39 class ClassCollection final : public HTMLCollection { |
| 40 public: | 40 public: |
| 41 // classNames argument is an AtomicString because it is common for Elements to
share the same class names. | 41 // classNames argument is an AtomicString because it is common for Elements to |
| 42 // It is also used to construct a SpaceSplitString (m_classNames) and its cons
tructor requires an AtomicString. | 42 // share the same class names. It is also used to construct a |
| 43 // SpaceSplitString (m_classNames) and its constructor requires an |
| 44 // AtomicString. |
| 43 static ClassCollection* create(ContainerNode& rootNode, | 45 static ClassCollection* create(ContainerNode& rootNode, |
| 44 CollectionType type, | 46 CollectionType type, |
| 45 const AtomicString& classNames) { | 47 const AtomicString& classNames) { |
| 46 ASSERT_UNUSED(type, type == ClassCollectionType); | 48 ASSERT_UNUSED(type, type == ClassCollectionType); |
| 47 return new ClassCollection(rootNode, classNames); | 49 return new ClassCollection(rootNode, classNames); |
| 48 } | 50 } |
| 49 | 51 |
| 50 ~ClassCollection() override; | 52 ~ClassCollection() override; |
| 51 | 53 |
| 52 bool elementMatches(const Element&) const; | 54 bool elementMatches(const Element&) const; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 68 if (!testElement.hasClass()) | 70 if (!testElement.hasClass()) |
| 69 return false; | 71 return false; |
| 70 if (!m_classNames.size()) | 72 if (!m_classNames.size()) |
| 71 return false; | 73 return false; |
| 72 return testElement.classNames().containsAll(m_classNames); | 74 return testElement.classNames().containsAll(m_classNames); |
| 73 } | 75 } |
| 74 | 76 |
| 75 } // namespace blink | 77 } // namespace blink |
| 76 | 78 |
| 77 #endif // ClassCollection_h | 79 #endif // ClassCollection_h |
| OLD | NEW |