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

Side by Side Diff: Source/core/html/HTMLCollection.h

Issue 247263008: LiveNodeListBase code should not need to worry about id/name cache invalidation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bug fix Created 6 years, 8 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/html/CollectionType.h ('k') | no next file » | 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 * 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
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
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
OLDNEW
« no previous file with comments | « Source/core/html/CollectionType.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698