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

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

Issue 137433008: Have HTMLCollection::item() return an Element as per specification (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 10 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
« no previous file with comments | « Source/core/html/HTMLAllCollection.idl ('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 26 matching lines...) Expand all
37 OverridesItemAfter, 37 OverridesItemAfter,
38 DoesNotOverrideItemAfter, 38 DoesNotOverrideItemAfter,
39 }; 39 };
40 40
41 static PassRefPtr<HTMLCollection> create(ContainerNode* base, CollectionType ); 41 static PassRefPtr<HTMLCollection> create(ContainerNode* base, CollectionType );
42 virtual ~HTMLCollection(); 42 virtual ~HTMLCollection();
43 virtual void invalidateCache() const OVERRIDE; 43 virtual void invalidateCache() const OVERRIDE;
44 44
45 // DOM API 45 // DOM API
46 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); } 46 unsigned length() const { return m_collectionIndexCache.nodeCount(*this); }
47 Node* item(unsigned offset) const { return m_collectionIndexCache.nodeAt(*th is, offset); } 47 Element* item(unsigned offset) const { return m_collectionIndexCache.nodeAt( *this, offset); }
48 virtual Element* namedItem(const AtomicString& name) const; 48 virtual Element* namedItem(const AtomicString& name) const;
49 49
50 // Non-DOM API 50 // Non-DOM API
51 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const; 51 void namedItems(const AtomicString& name, Vector<RefPtr<Element> >&) const;
52 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); } 52 bool isEmpty() const { return m_collectionIndexCache.isEmpty(*this); }
53 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne Node(*this); } 53 bool hasExactlyOneItem() const { return m_collectionIndexCache.hasExactlyOne Node(*this); }
54 54
55 // CollectionIndexCache API. 55 // CollectionIndexCache API.
56 bool canTraverseBackward() const { return !overridesItemAfter(); } 56 bool canTraverseBackward() const { return !overridesItemAfter(); }
57 Element* itemBefore(const Node* previousItem) const;
57 Element* traverseToFirstElement(const ContainerNode& root) const; 58 Element* traverseToFirstElement(const ContainerNode& root) const;
58 Element* traverseForwardToOffset(unsigned offset, Node& currentElement, unsi gned& currentOffset, const ContainerNode& root) const; 59 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u nsigned& currentOffset, const ContainerNode& root) const;
59 60
60 protected: 61 protected:
61 HTMLCollection(ContainerNode* base, CollectionType, ItemAfterOverrideType); 62 HTMLCollection(ContainerNode* base, CollectionType, ItemAfterOverrideType);
62 63
63 bool overridesItemAfter() const { return m_overridesItemAfter; } 64 bool overridesItemAfter() const { return m_overridesItemAfter; }
64 virtual Element* virtualItemAfter(Element*) const; 65 virtual Element* virtualItemAfter(Element*) const;
65 66
66 virtual void updateNameCache() const; 67 virtual void updateNameCache() const;
67 bool hasNameCache() const { return m_isNameCacheValid; } 68 bool hasNameCache() const { return m_isNameCacheValid; }
68 void setHasNameCache() const { m_isNameCacheValid = true; } 69 void setHasNameCache() const { m_isNameCacheValid = true; }
(...skipping 13 matching lines...) Expand all
82 { 83 {
83 m_idCache.clear(); 84 m_idCache.clear();
84 m_nameCache.clear(); 85 m_nameCache.clear();
85 m_isNameCacheValid = false; 86 m_isNameCacheValid = false;
86 } 87 }
87 88
88 const unsigned m_overridesItemAfter : 1; 89 const unsigned m_overridesItemAfter : 1;
89 mutable unsigned m_isNameCacheValid : 1; 90 mutable unsigned m_isNameCacheValid : 1;
90 mutable NodeCacheMap m_idCache; 91 mutable NodeCacheMap m_idCache;
91 mutable NodeCacheMap m_nameCache; 92 mutable NodeCacheMap m_nameCache;
92 mutable CollectionIndexCache<HTMLCollection> m_collectionIndexCache; 93 mutable CollectionIndexCache<HTMLCollection, Element> m_collectionIndexCache ;
93 94
94 friend class LiveNodeListBase; 95 friend class LiveNodeListBase;
95 }; 96 };
96 97
97 } // namespace 98 } // namespace
98 99
99 #endif 100 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAllCollection.idl ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698