OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NamedItemCache& cache = createNamedItemCache(); |
156 HashSet<StringImpl*> foundInputElements; | 157 HashSet<StringImpl*> foundInputElements; |
157 | 158 |
158 const Vector<FormAssociatedElement*>& elementsArray = formControlElements(); | 159 const Vector<FormAssociatedElement*>& elementsArray = formControlElements(); |
159 | 160 |
160 for (unsigned i = 0; i < elementsArray.size(); ++i) { | 161 for (unsigned i = 0; i < elementsArray.size(); ++i) { |
161 FormAssociatedElement* associatedElement = elementsArray[i]; | 162 FormAssociatedElement* associatedElement = elementsArray[i]; |
162 if (associatedElement->isEnumeratable()) { | 163 if (associatedElement->isEnumeratable()) { |
163 HTMLElement* element = toHTMLElement(associatedElement); | 164 HTMLElement* element = toHTMLElement(associatedElement); |
164 const AtomicString& idAttrVal = element->getIdAttribute(); | 165 const AtomicString& idAttrVal = element->getIdAttribute(); |
165 const AtomicString& nameAttrVal = element->getNameAttribute(); | 166 const AtomicString& nameAttrVal = element->getNameAttribute(); |
166 if (!idAttrVal.isEmpty()) { | 167 if (!idAttrVal.isEmpty()) { |
167 appendIdCache(idAttrVal, element); | 168 cache.addElementWithId(idAttrVal, element); |
168 foundInputElements.add(idAttrVal.impl()); | 169 foundInputElements.add(idAttrVal.impl()); |
169 } | 170 } |
170 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { | 171 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { |
171 appendNameCache(nameAttrVal, element); | 172 cache.addElementWithName(nameAttrVal, element); |
172 foundInputElements.add(nameAttrVal.impl()); | 173 foundInputElements.add(nameAttrVal.impl()); |
173 } | 174 } |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 if (isHTMLFormElement(ownerNode())) { | 178 if (isHTMLFormElement(ownerNode())) { |
178 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); | 179 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); |
179 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { | 180 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { |
180 HTMLImageElement* element = imageElementsArray[i]; | 181 HTMLImageElement* element = imageElementsArray[i]; |
181 const AtomicString& idAttrVal = element->getIdAttribute(); | 182 const AtomicString& idAttrVal = element->getIdAttribute(); |
182 const AtomicString& nameAttrVal = element->getNameAttribute(); | 183 const AtomicString& nameAttrVal = element->getNameAttribute(); |
183 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) | 184 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) |
184 appendIdCache(idAttrVal, element); | 185 cache.addElementWithId(idAttrVal, element); |
185 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) | 186 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) |
186 appendNameCache(nameAttrVal, element); | 187 cache.addElementWithName(nameAttrVal, element); |
187 } | 188 } |
188 } | 189 } |
189 | |
190 setHasValidIdNameCache(); | |
191 } | 190 } |
192 | 191 |
193 void HTMLFormControlsCollection::namedGetter(const AtomicString& name, bool& rad
ioNodeListEnabled, RefPtr<RadioNodeList>& radioNodeList, bool& elementEnabled, R
efPtr<Element>& element) | 192 void HTMLFormControlsCollection::namedGetter(const AtomicString& name, bool& rad
ioNodeListEnabled, RefPtr<RadioNodeList>& radioNodeList, bool& elementEnabled, R
efPtr<Element>& element) |
194 { | 193 { |
195 Vector<RefPtr<Element> > namedItems; | 194 Vector<RefPtr<Element> > namedItems; |
196 this->namedItems(name, namedItems); | 195 this->namedItems(name, namedItems); |
197 | 196 |
198 if (namedItems.isEmpty()) | 197 if (namedItems.isEmpty()) |
199 return; | 198 return; |
200 | 199 |
(...skipping 28 matching lines...) Expand all Loading... |
229 const AtomicString& nameAttribute = element->getNameAttribute(); | 228 const AtomicString& nameAttribute = element->getNameAttribute(); |
230 if (!nameAttribute.isEmpty()) { | 229 if (!nameAttribute.isEmpty()) { |
231 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 230 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
232 if (addResult.isNewEntry) | 231 if (addResult.isNewEntry) |
233 names.append(nameAttribute); | 232 names.append(nameAttribute); |
234 } | 233 } |
235 } | 234 } |
236 } | 235 } |
237 | 236 |
238 } | 237 } |
OLD | NEW |