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

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

Issue 120383002: HTMLCollection should not inherit NodeList (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | « no previous file | Source/core/html/HTMLCollection.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) 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, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2006, 2007 Apple Inc. 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 23 matching lines...) Expand all
34 namespace WebCore { 34 namespace WebCore {
35 35
36 class Element; 36 class Element;
37 37
38 enum NodeListRootType { 38 enum NodeListRootType {
39 NodeListIsRootedAtNode, 39 NodeListIsRootedAtNode,
40 NodeListIsRootedAtDocument, 40 NodeListIsRootedAtDocument,
41 NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr, 41 NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr,
42 }; 42 };
43 43
44 class LiveNodeListBase : public NodeList { 44 class LiveNodeListBase {
45 public: 45 public:
46 enum ItemAfterOverrideType { 46 enum ItemAfterOverrideType {
47 OverridesItemAfter, 47 OverridesItemAfter,
48 DoesNotOverrideItemAfter, 48 DoesNotOverrideItemAfter,
49 }; 49 };
50 50
51 LiveNodeListBase(Node* ownerNode, NodeListRootType rootType, NodeListInvalid ationType invalidationType, 51 LiveNodeListBase(Node* ownerNode, NodeListRootType rootType, NodeListInvalid ationType invalidationType,
52 bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, Ite mAfterOverrideType itemAfterOverrideType) 52 bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, Ite mAfterOverrideType itemAfterOverrideType)
53 : m_ownerNode(ownerNode) 53 : m_ownerNode(ownerNode)
54 , m_cachedItem(0) 54 , m_cachedItem(0)
(...skipping 15 matching lines...) Expand all
70 if (collectionType != ChildNodeListType) 70 if (collectionType != ChildNodeListType)
71 document().registerNodeList(this); 71 document().registerNodeList(this);
72 } 72 }
73 73
74 virtual ~LiveNodeListBase() 74 virtual ~LiveNodeListBase()
75 { 75 {
76 if (type() != ChildNodeListType) 76 if (type() != ChildNodeListType)
77 document().unregisterNodeList(this); 77 document().unregisterNodeList(this);
78 } 78 }
79 79
80 // DOM API 80 unsigned length() const;
81 virtual unsigned length() const OVERRIDE; 81 Node* item(unsigned offset) const;
82 virtual Node* item(unsigned offset) const OVERRIDE;
83 82
84 ALWAYS_INLINE bool hasIdNameCache() const { return !isNodeList(type()); } 83 ALWAYS_INLINE bool hasIdNameCache() const { return !isNodeList(type()); }
85 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis tIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemref Attr; } 84 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeLis tIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemref Attr; }
86 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta tic_cast<NodeListInvalidationType>(m_invalidationType); } 85 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return sta tic_cast<NodeListInvalidationType>(m_invalidationType); }
87 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp e>(m_collectionType); } 86 ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionTyp e>(m_collectionType); }
88 Node* ownerNode() const { return m_ownerNode.get(); } 87 Node* ownerNode() const { return m_ownerNode.get(); }
89 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const 88 ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const
90 { 89 {
91 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType( ), *attrName)) 90 if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType( ), *attrName))
92 invalidateCache(); 91 invalidateCache();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return attrName == HTMLNames::hrefAttr; 178 return attrName == HTMLNames::hrefAttr;
180 case InvalidateOnItemAttrChange: 179 case InvalidateOnItemAttrChange:
181 case DoNotInvalidateOnAttributeChanges: 180 case DoNotInvalidateOnAttributeChanges:
182 return false; 181 return false;
183 case InvalidateOnAnyAttrChange: 182 case InvalidateOnAnyAttrChange:
184 return true; 183 return true;
185 } 184 }
186 return false; 185 return false;
187 } 186 }
188 187
189 class LiveNodeList : public LiveNodeListBase { 188 class LiveNodeList : public NodeList, public LiveNodeListBase {
190 public: 189 public:
191 LiveNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, Node ListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRoo tedAtNode) 190 LiveNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, Node ListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRoo tedAtNode)
192 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, collecti onType == ChildNodeListType, 191 : LiveNodeListBase(ownerNode.get(), rootType, invalidationType, collecti onType == ChildNodeListType,
193 collectionType, DoesNotOverrideItemAfter) 192 collectionType, DoesNotOverrideItemAfter)
194 { } 193 { }
195 194
196 virtual Node* namedItem(const AtomicString&) const OVERRIDE; 195 virtual unsigned length() const OVERRIDE FINAL { return LiveNodeListBase::le ngth(); }
196 virtual Node* item(unsigned offset) const OVERRIDE FINAL { return LiveNodeLi stBase::item(offset); }
197 virtual Node* namedItem(const AtomicString&) const OVERRIDE FINAL;
197 virtual bool nodeMatches(Element*) const = 0; 198 virtual bool nodeMatches(Element*) const = 0;
198 199
199 private: 200 private:
200 virtual bool isLiveNodeList() const OVERRIDE { return true; } 201 virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }
201 }; 202 };
202 203
203 } // namespace WebCore 204 } // namespace WebCore
204 205
205 #endif // LiveNodeList_h 206 #endif // LiveNodeList_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/HTMLCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698