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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 28 matching lines...) Expand all
39 // calculation every time if anything has changed. 39 // calculation every time if anything has changed.
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(nullptr) 43 , m_cachedElement(nullptr)
44 , m_cachedElementOffsetInArray(0) 44 , m_cachedElementOffsetInArray(0)
45 { 45 {
46 ASSERT(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode)); 46 ASSERT(isHTMLFormElement(ownerNode) || isHTMLFieldSetElement(ownerNode));
47 } 47 }
48 48
49 PassRefPtrWillBeRawPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::c reate(ContainerNode& ownerNode, CollectionType type) 49 RawPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ContainerN ode& ownerNode, CollectionType type)
50 { 50 {
51 ASSERT_UNUSED(type, type == FormControls); 51 ASSERT_UNUSED(type, type == FormControls);
52 return adoptRefWillBeNoop(new HTMLFormControlsCollection(ownerNode)); 52 return (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()))
63 return toHTMLFormElement(ownerNode()).associatedElements(); 63 return toHTMLFormElement(ownerNode()).associatedElements();
64 return toHTMLFieldSetElement(ownerNode()).associatedElements(); 64 return toHTMLFieldSetElement(ownerNode()).associatedElements();
65 } 65 }
66 66
67 const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>& HTMLFormControlsCo llection::formImageElements() const 67 const HeapVector<Member<HTMLImageElement>>& HTMLFormControlsCollection::formImag eElements() const
68 { 68 {
69 return toHTMLFormElement(ownerNode()).imageElements(); 69 return toHTMLFormElement(ownerNode()).imageElements();
70 } 70 }
71 71
72 static unsigned findFormAssociatedElement(const FormAssociatedElement::List& ass ociatedElements, Element* element) 72 static unsigned findFormAssociatedElement(const FormAssociatedElement::List& ass ociatedElements, Element* element)
73 { 73 {
74 unsigned i = 0; 74 unsigned i = 0;
75 for (; i < associatedElements.size(); ++i) { 75 for (; i < associatedElements.size(); ++i) {
76 FormAssociatedElement* associatedElement = associatedElements[i]; 76 FormAssociatedElement* associatedElement = associatedElements[i];
77 if (associatedElement->isEnumeratable() && toHTMLElement(associatedEleme nt) == element) 77 if (associatedElement->isEnumeratable() && toHTMLElement(associatedEleme nt) == element)
(...skipping 25 matching lines...) Expand all
103 } 103 }
104 104
105 void HTMLFormControlsCollection::invalidateCache(Document* oldDocument) const 105 void HTMLFormControlsCollection::invalidateCache(Document* oldDocument) const
106 { 106 {
107 HTMLCollection::invalidateCache(oldDocument); 107 HTMLCollection::invalidateCache(oldDocument);
108 m_cachedElement = nullptr; 108 m_cachedElement = nullptr;
109 m_cachedElementOffsetInArray = 0; 109 m_cachedElementOffsetInArray = 0;
110 } 110 }
111 111
112 static HTMLElement* firstNamedItem(const FormAssociatedElement::List& elementsAr ray, 112 static HTMLElement* firstNamedItem(const FormAssociatedElement::List& elementsAr ray,
113 const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>* imageElementsA rray, const QualifiedName& attrName, const String& name) 113 const HeapVector<Member<HTMLImageElement>>* imageElementsArray, const Qualif iedName& attrName, const String& name)
114 { 114 {
115 ASSERT(attrName == idAttr || attrName == nameAttr); 115 ASSERT(attrName == idAttr || attrName == nameAttr);
116 116
117 for (unsigned i = 0; i < elementsArray.size(); ++i) { 117 for (unsigned i = 0; i < elementsArray.size(); ++i) {
118 HTMLElement* element = toHTMLElement(elementsArray[i]); 118 HTMLElement* element = toHTMLElement(elementsArray[i]);
119 if (elementsArray[i]->isEnumeratable() && element->fastGetAttribute(attr Name) == name) 119 if (elementsArray[i]->isEnumeratable() && element->fastGetAttribute(attr Name) == name)
120 return element; 120 return element;
121 } 121 }
122 122
123 if (!imageElementsArray) 123 if (!imageElementsArray)
(...skipping 10 matching lines...) Expand all
134 return nullptr; 134 return nullptr;
135 } 135 }
136 136
137 HTMLElement* HTMLFormControlsCollection::namedItem(const AtomicString& name) con st 137 HTMLElement* HTMLFormControlsCollection::namedItem(const AtomicString& name) con st
138 { 138 {
139 // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/namedit em.asp 139 // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/namedit em.asp
140 // This method first searches for an object with a matching id 140 // This method first searches for an object with a matching id
141 // attribute. If a match is not found, the method then searches for an 141 // attribute. If a match is not found, the method then searches for an
142 // object with a matching name attribute, but only on those elements 142 // object with a matching name attribute, but only on those elements
143 // that are allowed a name attribute. 143 // that are allowed a name attribute.
144 const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>* imagesElements = isHTMLFieldSetElement(ownerNode()) ? 0 : &formImageElements(); 144 const HeapVector<Member<HTMLImageElement>>* imagesElements = isHTMLFieldSetE lement(ownerNode()) ? 0 : &formImageElements();
145 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements , idAttr, name)) 145 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements , idAttr, name))
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 OwnPtrWillBeRawPtr<NamedItemCache> cache = NamedItemCache::create(); 156 RawPtr<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();
167 if (!idAttrVal.isEmpty()) { 167 if (!idAttrVal.isEmpty()) {
168 cache->addElementWithId(idAttrVal, element); 168 cache->addElementWithId(idAttrVal, element);
169 foundInputElements.add(idAttrVal.impl()); 169 foundInputElements.add(idAttrVal.impl());
170 } 170 }
171 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { 171 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) {
172 cache->addElementWithName(nameAttrVal, element); 172 cache->addElementWithName(nameAttrVal, element);
173 foundInputElements.add(nameAttrVal.impl()); 173 foundInputElements.add(nameAttrVal.impl());
174 } 174 }
175 } 175 }
176 } 176 }
177 177
178 if (isHTMLFormElement(ownerNode())) { 178 if (isHTMLFormElement(ownerNode())) {
179 const WillBeHeapVector<RawPtrWillBeMember<HTMLImageElement>>& imageEleme ntsArray = formImageElements(); 179 const HeapVector<Member<HTMLImageElement>>& imageElementsArray = formIma geElements();
180 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { 180 for (unsigned i = 0; i < imageElementsArray.size(); ++i) {
181 HTMLImageElement* element = imageElementsArray[i]; 181 HTMLImageElement* element = imageElementsArray[i];
182 const AtomicString& idAttrVal = element->getIdAttribute(); 182 const AtomicString& idAttrVal = element->getIdAttribute();
183 const AtomicString& nameAttrVal = element->getNameAttribute(); 183 const AtomicString& nameAttrVal = element->getNameAttribute();
184 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i mpl())) 184 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i mpl()))
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, RadioNode ListOrElement& returnValue) 195 void HTMLFormControlsCollection::namedGetter(const AtomicString& name, RadioNode ListOrElement& returnValue)
196 { 196 {
197 WillBeHeapVector<RefPtrWillBeMember<Element>> namedItems; 197 HeapVector<Member<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 if (isHTMLImageElement(*namedItems[0])) 204 if (isHTMLImageElement(*namedItems[0]))
205 UseCounter::count(document(), UseCounter::FormControlsCollectionName AccessForImageElement); 205 UseCounter::count(document(), UseCounter::FormControlsCollectionName AccessForImageElement);
206 returnValue.setElement(namedItems.at(0)); 206 returnValue.setElement(namedItems.at(0));
207 return; 207 return;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 } 240 }
241 241
242 DEFINE_TRACE(HTMLFormControlsCollection) 242 DEFINE_TRACE(HTMLFormControlsCollection)
243 { 243 {
244 visitor->trace(m_cachedElement); 244 visitor->trace(m_cachedElement);
245 HTMLCollection::trace(visitor); 245 HTMLCollection::trace(visitor);
246 } 246 }
247 247
248 } // namespace blink 248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698