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

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

Issue 67473002: Have ElementTraversal / NodeTraversal's next() methods take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master Created 7 years, 1 month 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/FormAssociatedElement.cpp ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (isLengthCacheValid()) 55 if (isLengthCacheValid())
56 return cachedLength() == 1; 56 return cachedLength() == 1;
57 if (isItemCacheValid()) 57 if (isItemCacheValid())
58 return cachedItem() && !cachedItemOffset() && !item(1); 58 return cachedItem() && !cachedItemOffset() && !item(1);
59 return item(0) && !item(1); 59 return item(0) && !item(1);
60 } 60 }
61 61
62 virtual Element* virtualItemAfter(unsigned& offsetInArray, Element*) const; 62 virtual Element* virtualItemAfter(unsigned& offsetInArray, Element*) const;
63 63
64 Element* traverseFirstElement(unsigned& offsetInArray, ContainerNode* root) const; 64 Element* traverseFirstElement(unsigned& offsetInArray, ContainerNode* root) const;
65 Element* traverseForwardToOffset(unsigned offset, Element* currentElement, u nsigned& currentOffset, unsigned& offsetInArray, ContainerNode* root) const; 65 Element* traverseForwardToOffset(unsigned offset, Element& currentElement, u nsigned& currentOffset, unsigned& offsetInArray, ContainerNode* root) const;
66 66
67 protected: 67 protected:
68 HTMLCollection(Node* base, CollectionType, ItemAfterOverrideType); 68 HTMLCollection(Node* base, CollectionType, ItemAfterOverrideType);
69 69
70 virtual void updateNameCache() const; 70 virtual void updateNameCache() const;
71 71
72 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap; 72 typedef HashMap<StringImpl*, OwnPtr<Vector<Element*> > > NodeCacheMap;
73 Vector<Element*>* idCache(const AtomicString& name) const { return m_idCache .get(name.impl()); } 73 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()); } 74 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); } 75 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); } 76 void appendNameCache(const AtomicString& name, Element* element) const { app end(m_nameCache, name, element); }
77 77
78 private: 78 private:
79 bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) c onst; 79 bool checkForNameMatch(Element*, bool checkName, const AtomicString& name) c onst;
80 Element* traverseNextElement(unsigned& offsetInArray, Element* previous, Con tainerNode* root) const; 80 Element* traverseNextElement(unsigned& offsetInArray, Element& previous, Con tainerNode* root) const;
81 81
82 virtual bool isLiveNodeList() const OVERRIDE { ASSERT_NOT_REACHED(); return true; } 82 virtual bool isLiveNodeList() const OVERRIDE { ASSERT_NOT_REACHED(); return true; }
83 83
84 static void append(NodeCacheMap&, const AtomicString&, Element*); 84 static void append(NodeCacheMap&, const AtomicString&, Element*);
85 85
86 mutable NodeCacheMap m_idCache; 86 mutable NodeCacheMap m_idCache;
87 mutable NodeCacheMap m_nameCache; 87 mutable NodeCacheMap m_nameCache;
88 mutable unsigned m_cachedElementsArrayOffset; 88 mutable unsigned m_cachedElementsArrayOffset;
89 89
90 friend class LiveNodeListBase; 90 friend class LiveNodeListBase;
91 }; 91 };
92 92
93 } // namespace 93 } // namespace
94 94
95 #endif 95 #endif
OLDNEW
« no previous file with comments | « Source/core/html/FormAssociatedElement.cpp ('k') | Source/core/html/HTMLCollection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698