OLD | NEW |
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All r
ights reserved. |
5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 25 matching lines...) Expand all Loading... |
36 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection>
, public LiveNodeListBase { | 36 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection>
, public LiveNodeListBase { |
37 public: | 37 public: |
38 enum ItemAfterOverrideType { | 38 enum ItemAfterOverrideType { |
39 OverridesItemAfter, | 39 OverridesItemAfter, |
40 DoesNotOverrideItemAfter, | 40 DoesNotOverrideItemAfter, |
41 }; | 41 }; |
42 | 42 |
43 static PassRefPtr<HTMLCollection> create(ContainerNode& base, CollectionType
); | 43 static PassRefPtr<HTMLCollection> create(ContainerNode& base, CollectionType
); |
44 virtual ~HTMLCollection(); | 44 virtual ~HTMLCollection(); |
45 virtual void invalidateCache(Document* oldDocument = 0) const OVERRIDE; | 45 virtual void invalidateCache(Document* oldDocument = 0) const OVERRIDE; |
| 46 void invalidateCacheForAttribute(const QualifiedName*) const; |
46 | 47 |
47 // DOM API | 48 // DOM API |
48 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } | 49 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } |
49 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } | 50 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(
*this, offset); } |
50 virtual Element* namedItem(const AtomicString& name) const; | 51 virtual Element* namedItem(const AtomicString& name) const; |
51 bool namedPropertyQuery(const AtomicString&, ExceptionState&); | 52 bool namedPropertyQuery(const AtomicString&, ExceptionState&); |
52 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); | 53 void namedPropertyEnumerator(Vector<String>& names, ExceptionState&); |
53 | 54 |
54 // Non-DOM API | 55 // Non-DOM API |
55 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; | 56 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void unregisterIdNameCacheFromDocument(Document& document) const | 134 void unregisterIdNameCacheFromDocument(Document& document) const |
134 { | 135 { |
135 ASSERT(hasValidIdNameCache()); | 136 ASSERT(hasValidIdNameCache()); |
136 document.decrementNodeListWithIdNameCacheCount(); | 137 document.decrementNodeListWithIdNameCacheCount(); |
137 } | 138 } |
138 | 139 |
139 const unsigned m_overridesItemAfter : 1; | 140 const unsigned m_overridesItemAfter : 1; |
140 const unsigned m_shouldOnlyIncludeDirectChildren : 1; | 141 const unsigned m_shouldOnlyIncludeDirectChildren : 1; |
141 mutable OwnPtr<NamedItemCache> m_namedItemCache; | 142 mutable OwnPtr<NamedItemCache> m_namedItemCache; |
142 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; | 143 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache
; |
| 144 }; |
143 | 145 |
144 friend class LiveNodeListBase; | 146 DEFINE_TYPE_CASTS(HTMLCollection, LiveNodeListBase, collection, isHTMLCollection
Type(collection->type()), isHTMLCollectionType(collection.type())); |
145 }; | 147 |
| 148 inline void HTMLCollection::invalidateCacheForAttribute(const QualifiedName* att
rName) const |
| 149 { |
| 150 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *
attrName)) |
| 151 invalidateCache(); |
| 152 else if (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr) |
| 153 invalidateIdNameCacheMaps(); |
| 154 } |
146 | 155 |
147 } // namespace | 156 } // namespace |
148 | 157 |
149 #endif | 158 #endif |
OLD | NEW |