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

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

Issue 280123002: Oilpan: move LiveNodeList collections to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have NodeRareData clear out NodeListsNodeData instead. Created 6 years, 7 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/HTMLFormControlsCollection.h ('k') | Source/core/html/HTMLFormElement.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, 2010, 2011, 2012 Apple Inc. All r ights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 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 29 matching lines...) Expand all
40 40
41 HTMLFormControlsCollection::HTMLFormControlsCollection(ContainerNode& ownerNode) 41 HTMLFormControlsCollection::HTMLFormControlsCollection(ContainerNode& ownerNode)
42 : HTMLCollection(ownerNode, FormControls, OverridesItemAfter) 42 : HTMLCollection(ownerNode, FormControls, OverridesItemAfter)
43 , m_cachedElement(0) 43 , m_cachedElement(0)
44 , m_cachedElementOffsetInArray(0) 44 , m_cachedElementOffsetInArray(0)
45 { 45 {
46 ASSERT(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode)); 46 ASSERT(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode));
47 ScriptWrappable::init(this); 47 ScriptWrappable::init(this);
48 } 48 }
49 49
50 PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(Contai nerNode& ownerNode, CollectionType) 50 PassRefPtrWillBeRawPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::c reate(ContainerNode& ownerNode, CollectionType)
51 { 51 {
52 return adoptRef(new HTMLFormControlsCollection(ownerNode)); 52 return adoptRefWillBeNoop(new HTMLFormControlsCollection(ownerNode));
53 } 53 }
54 54
55 HTMLFormControlsCollection::~HTMLFormControlsCollection() 55 HTMLFormControlsCollection::~HTMLFormControlsCollection()
56 { 56 {
57 } 57 }
58 58
59 const FormAssociatedElement::List& HTMLFormControlsCollection::formControlElemen ts() const 59 const FormAssociatedElement::List& HTMLFormControlsCollection::formControlElemen ts() const
60 { 60 {
61 ASSERT(isHTMLFormElement(ownerNode()) || isHTMLFieldSetElement(ownerNode())) ; 61 ASSERT(isHTMLFormElement(ownerNode()) || isHTMLFieldSetElement(ownerNode())) ;
62 if (isHTMLFormElement(ownerNode())) 62 if (isHTMLFormElement(ownerNode()))
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return item; 146 return item;
147 147
148 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name) ; 148 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name) ;
149 } 149 }
150 150
151 void HTMLFormControlsCollection::updateIdNameCache() const 151 void HTMLFormControlsCollection::updateIdNameCache() const
152 { 152 {
153 if (hasValidIdNameCache()) 153 if (hasValidIdNameCache())
154 return; 154 return;
155 155
156 OwnPtr<NamedItemCache> cache = NamedItemCache::create(); 156 OwnPtrWillBeRawPtr<NamedItemCache> cache = NamedItemCache::create();
157 HashSet<StringImpl*> foundInputElements; 157 HashSet<StringImpl*> foundInputElements;
158 158
159 const FormAssociatedElement::List& elementsArray = formControlElements(); 159 const FormAssociatedElement::List& elementsArray = formControlElements();
160 160
161 for (unsigned i = 0; i < elementsArray.size(); ++i) { 161 for (unsigned i = 0; i < elementsArray.size(); ++i) {
162 FormAssociatedElement* associatedElement = elementsArray[i]; 162 FormAssociatedElement* associatedElement = elementsArray[i];
163 if (associatedElement->isEnumeratable()) { 163 if (associatedElement->isEnumeratable()) {
164 HTMLElement* element = toHTMLElement(associatedElement); 164 HTMLElement* element = toHTMLElement(associatedElement);
165 const AtomicString& idAttrVal = element->getIdAttribute(); 165 const AtomicString& idAttrVal = element->getIdAttribute();
166 const AtomicString& nameAttrVal = element->getNameAttribute(); 166 const AtomicString& nameAttrVal = element->getNameAttribute();
(...skipping 18 matching lines...) Expand all
185 cache->addElementWithId(idAttrVal, element); 185 cache->addElementWithId(idAttrVal, element);
186 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu tElements.contains(nameAttrVal.impl())) 186 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu tElements.contains(nameAttrVal.impl()))
187 cache->addElementWithName(nameAttrVal, element); 187 cache->addElementWithName(nameAttrVal, element);
188 } 188 }
189 } 189 }
190 190
191 // Set the named item cache last as traversing the tree may cause cache inva lidation. 191 // Set the named item cache last as traversing the tree may cause cache inva lidation.
192 setNamedItemCache(cache.release()); 192 setNamedItemCache(cache.release());
193 } 193 }
194 194
195 void HTMLFormControlsCollection::namedGetter(const AtomicString& name, bool& rad ioNodeListEnabled, RefPtr<RadioNodeList>& radioNodeList, bool& elementEnabled, R efPtr<Element>& element) 195 void HTMLFormControlsCollection::namedGetter(const AtomicString& name, bool& rad ioNodeListEnabled, RefPtrWillBeRawPtr<RadioNodeList>& radioNodeList, bool& eleme ntEnabled, RefPtr<Element>& element)
196 { 196 {
197 Vector<RefPtr<Element> > namedItems; 197 WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems;
198 this->namedItems(name, namedItems); 198 this->namedItems(name, namedItems);
199 199
200 if (namedItems.isEmpty()) 200 if (namedItems.isEmpty())
201 return; 201 return;
202 202
203 if (namedItems.size() == 1) { 203 if (namedItems.size() == 1) {
204 elementEnabled = true; 204 elementEnabled = true;
205 element = namedItems.first(); 205 // FIXME: Oilpan: remove the call to |get| when Element becomes [Garbage Collected].
206 element = namedItems.at(0).get();
206 return; 207 return;
207 } 208 }
208 209
209 radioNodeListEnabled = true; 210 radioNodeListEnabled = true;
210 radioNodeList = ownerNode().radioNodeList(name); 211 radioNodeList = ownerNode().radioNodeList(name);
211 } 212 }
212 213
213 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names) 214 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names)
214 { 215 {
215 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in terfaces.html#htmlformcontrolscollection-0: 216 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in terfaces.html#htmlformcontrolscollection-0:
(...skipping 15 matching lines...) Expand all
231 const AtomicString& nameAttribute = element->getNameAttribute(); 232 const AtomicString& nameAttribute = element->getNameAttribute();
232 if (!nameAttribute.isEmpty()) { 233 if (!nameAttribute.isEmpty()) {
233 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA ttribute); 234 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA ttribute);
234 if (addResult.isNewEntry) 235 if (addResult.isNewEntry)
235 names.append(nameAttribute); 236 names.append(nameAttribute);
236 } 237 }
237 } 238 }
238 } 239 }
239 240
240 } 241 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLFormControlsCollection.h ('k') | Source/core/html/HTMLFormElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698