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

Side by Side Diff: Source/core/html/HTMLCollection.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 | « Source/core/dom/LiveNodeList.h ('k') | Source/core/html/HTMLCollection.cpp » ('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 * 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 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 13 matching lines...) Expand all
24 #define HTMLCollection_h 24 #define HTMLCollection_h
25 25
26 #include "core/dom/LiveNodeList.h" 26 #include "core/dom/LiveNodeList.h"
27 #include "core/html/CollectionType.h" 27 #include "core/html/CollectionType.h"
28 #include "wtf/Forward.h" 28 #include "wtf/Forward.h"
29 #include "wtf/HashMap.h" 29 #include "wtf/HashMap.h"
30 #include "wtf/Vector.h" 30 #include "wtf/Vector.h"
31 31
32 namespace WebCore { 32 namespace WebCore {
33 33
34 class HTMLCollection : public LiveNodeListBase { 34 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection> , public LiveNodeListBase {
35 public: 35 public:
36 static PassRefPtr<HTMLCollection> create(Node* base, CollectionType); 36 static PassRefPtr<HTMLCollection> create(Node* base, CollectionType);
37 virtual ~HTMLCollection(); 37 virtual ~HTMLCollection();
38 38
39 // DOM API 39 // DOM API
40 virtual Node* namedItem(const AtomicString& name) const; 40 virtual Node* namedItem(const AtomicString& name) const;
41 41
42 // Non-DOM API 42 // Non-DOM API
43 virtual bool hasNamedItem(const AtomicString& name) const;
44 void namedItems(const AtomicString& name, Vector<RefPtr<Node> >&) const; 43 void namedItems(const AtomicString& name, Vector<RefPtr<Node> >&) const;
45 bool isEmpty() const 44 bool isEmpty() const
46 { 45 {
47 if (isLengthCacheValid()) 46 if (isLengthCacheValid())
48 return !cachedLength(); 47 return !cachedLength();
49 if (isItemCacheValid()) 48 if (isItemCacheValid())
50 return !cachedItem(); 49 return !cachedItem();
51 return !item(0); 50 return !item(0);
52 } 51 }
53 bool hasExactlyOneItem() const 52 bool hasExactlyOneItem() const
(...skipping 18 matching lines...) Expand all
72 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap; 71 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap;
73 Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache .get(name.impl()); } 72 Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache .get(name.impl()); }
74 Vector<Element*>* nameCache(const AtomicString& name) const { return m_nameC ache.get(name.impl()); } 73 Vector<Element*>* nameCache(const AtomicString& name) const { return m_nameC ache.get(name.impl()); }
75 void appendIdCache(const AtomicString& name, Element* element) const { appen d(m_idCache, name, element); } 74 void appendIdCache(const AtomicString& name, Element* element) const { appen d(m_idCache, name, element); }
76 void appendNameCache(const AtomicString& name, Element* element) const { app end(m_nameCache, name, element); } 75 void appendNameCache(const AtomicString& name, Element* element) const { app end(m_nameCache, name, element); }
77 76
78 private: 77 private:
79 bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) c onst; 78 bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) c onst;
80 Element* traverseNextElement(unsigned& offsetInArray, Element& previous, Con tainerNode* root) const; 79 Element* traverseNextElement(unsigned& offsetInArray, Element& previous, Con tainerNode* root) const;
81 80
82 virtual bool isLiveNodeList() const OVERRIDE { ASSERT_NOT_REACHED(); return true; }
83
84 static void append(NodeCacheMap&, const AtomicString&, Element*); 81 static void append(NodeCacheMap&, const AtomicString&, Element*);
85 82
86 mutable NodeCacheMap m_idCache; 83 mutable NodeCacheMap m_idCache;
87 mutable NodeCacheMap m_nameCache; 84 mutable NodeCacheMap m_nameCache;
88 mutable unsigned m_cachedElementsArrayOffset; 85 mutable unsigned m_cachedElementsArrayOffset;
89 86
90 friend class LiveNodeListBase; 87 friend class LiveNodeListBase;
91 }; 88 };
92 89
93 } // namespace 90 } // namespace
94 91
95 #endif 92 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/LiveNodeList.h ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698