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

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

Issue 176933013: Pass rootNode by reference when constructing node lists / collections (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/HTMLCollection.h ('k') | Source/core/html/HTMLFormControlsCollection.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 * 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 case NameNodeListType: 151 case NameNodeListType:
152 case RadioNodeListType: 152 case RadioNodeListType:
153 case RadioImgNodeListType: 153 case RadioImgNodeListType:
154 case LabelsNodeListType: 154 case LabelsNodeListType:
155 break; 155 break;
156 } 156 }
157 ASSERT_NOT_REACHED(); 157 ASSERT_NOT_REACHED();
158 return DoNotInvalidateOnAttributeChanges; 158 return DoNotInvalidateOnAttributeChanges;
159 } 159 }
160 160
161 HTMLCollection::HTMLCollection(ContainerNode* ownerNode, CollectionType type, It emAfterOverrideType itemAfterOverrideType) 161 HTMLCollection::HTMLCollection(ContainerNode& ownerNode, CollectionType type, It emAfterOverrideType itemAfterOverrideType)
162 : LiveNodeListBase(ownerNode, rootTypeFromCollectionType(type), invalidation TypeExcludingIdAndNameAttributes(type), type) 162 : LiveNodeListBase(ownerNode, rootTypeFromCollectionType(type), invalidation TypeExcludingIdAndNameAttributes(type), type)
163 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter) 163 , m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter)
164 , m_shouldOnlyIncludeDirectChildren(shouldTypeOnlyIncludeDirectChildren(type )) 164 , m_shouldOnlyIncludeDirectChildren(shouldTypeOnlyIncludeDirectChildren(type ))
165 , m_hasValidIdNameCache(false) 165 , m_hasValidIdNameCache(false)
166 { 166 {
167 ScriptWrappable::init(this); 167 ScriptWrappable::init(this);
168 } 168 }
169 169
170 PassRefPtr<HTMLCollection> HTMLCollection::create(ContainerNode* base, Collectio nType type) 170 PassRefPtr<HTMLCollection> HTMLCollection::create(ContainerNode& base, Collectio nType type)
171 { 171 {
172 return adoptRef(new HTMLCollection(base, type, DoesNotOverrideItemAfter)); 172 return adoptRef(new HTMLCollection(base, type, DoesNotOverrideItemAfter));
173 } 173 }
174 174
175 HTMLCollection::~HTMLCollection() 175 HTMLCollection::~HTMLCollection()
176 { 176 {
177 if (hasValidIdNameCache()) 177 if (hasValidIdNameCache())
178 unregisterIdNameCacheFromDocument(document()); 178 unregisterIdNameCacheFromDocument(document());
179 // HTMLNameCollection, ClassCollection and TagCollection remove cache by the mselves. 179 // HTMLNameCollection, ClassCollection and TagCollection remove cache by the mselves.
180 if (type() != WindowNamedItems && type() != DocumentNamedItems && type() != ClassCollectionType 180 if (type() != WindowNamedItems && type() != DocumentNamedItems && type() != ClassCollectionType
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element) 479 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element* element)
480 { 480 {
481 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).storedValue ->value; 481 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).storedValue ->value;
482 if (!vector) 482 if (!vector)
483 vector = adoptPtr(new Vector<Element*>); 483 vector = adoptPtr(new Vector<Element*>);
484 vector->append(element); 484 vector->append(element);
485 } 485 }
486 486
487 } // namespace WebCore 487 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCollection.h ('k') | Source/core/html/HTMLFormControlsCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698