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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 FormAssociatedElement* associatedElement = associatedElements[i]; | 97 FormAssociatedElement* associatedElement = associatedElements[i]; |
98 if (associatedElement->isEnumeratable()) { | 98 if (associatedElement->isEnumeratable()) { |
99 m_cachedElement = toHTMLElement(associatedElement); | 99 m_cachedElement = toHTMLElement(associatedElement); |
100 m_cachedElementOffsetInArray = i; | 100 m_cachedElementOffsetInArray = i; |
101 return m_cachedElement; | 101 return m_cachedElement; |
102 } | 102 } |
103 } | 103 } |
104 return 0; | 104 return 0; |
105 } | 105 } |
106 | 106 |
107 void HTMLFormControlsCollection::invalidateCache() const | 107 void HTMLFormControlsCollection::invalidateCache(Document* oldDocument) const |
108 { | 108 { |
109 HTMLCollection::invalidateCache(); | 109 HTMLCollection::invalidateCache(oldDocument); |
110 m_cachedElement = 0; | 110 m_cachedElement = 0; |
111 m_cachedElementOffsetInArray = 0; | 111 m_cachedElementOffsetInArray = 0; |
112 } | 112 } |
113 | 113 |
114 static HTMLElement* firstNamedItem(const Vector<FormAssociatedElement*>& element
sArray, | 114 static HTMLElement* firstNamedItem(const Vector<FormAssociatedElement*>& element
sArray, |
115 const Vector<HTMLImageElement*>* imageElementsArray, const QualifiedName& at
trName, const String& name) | 115 const Vector<HTMLImageElement*>* imageElementsArray, const QualifiedName& at
trName, const String& name) |
116 { | 116 { |
117 ASSERT(attrName == idAttr || attrName == nameAttr); | 117 ASSERT(attrName == idAttr || attrName == nameAttr); |
118 | 118 |
119 for (unsigned i = 0; i < elementsArray.size(); ++i) { | 119 for (unsigned i = 0; i < elementsArray.size(); ++i) { |
(...skipping 23 matching lines...) Expand all Loading... |
143 // attribute. If a match is not found, the method then searches for an | 143 // attribute. If a match is not found, the method then searches for an |
144 // object with a matching name attribute, but only on those elements | 144 // object with a matching name attribute, but only on those elements |
145 // that are allowed a name attribute. | 145 // that are allowed a name attribute. |
146 const Vector<HTMLImageElement*>* imagesElements = ownerNode()->hasTagName(fi
eldsetTag) ? 0 : &formImageElements(); | 146 const Vector<HTMLImageElement*>* imagesElements = ownerNode()->hasTagName(fi
eldsetTag) ? 0 : &formImageElements(); |
147 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements
, idAttr, name)) | 147 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements
, idAttr, name)) |
148 return item; | 148 return item; |
149 | 149 |
150 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name)
; | 150 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name)
; |
151 } | 151 } |
152 | 152 |
153 void HTMLFormControlsCollection::updateNameCache() const | 153 void HTMLFormControlsCollection::updateIdNameCache() const |
154 { | 154 { |
155 if (hasNameCache()) | 155 if (hasValidIdNameCache()) |
156 return; | 156 return; |
157 | 157 |
158 HashSet<StringImpl*> foundInputElements; | 158 HashSet<StringImpl*> foundInputElements; |
159 | 159 |
160 const Vector<FormAssociatedElement*>& elementsArray = formControlElements(); | 160 const Vector<FormAssociatedElement*>& elementsArray = formControlElements(); |
161 | 161 |
162 for (unsigned i = 0; i < elementsArray.size(); ++i) { | 162 for (unsigned i = 0; i < elementsArray.size(); ++i) { |
163 FormAssociatedElement* associatedElement = elementsArray[i]; | 163 FormAssociatedElement* associatedElement = elementsArray[i]; |
164 if (associatedElement->isEnumeratable()) { | 164 if (associatedElement->isEnumeratable()) { |
165 HTMLElement* element = toHTMLElement(associatedElement); | 165 HTMLElement* element = toHTMLElement(associatedElement); |
(...skipping 16 matching lines...) Expand all Loading... |
182 HTMLImageElement* element = imageElementsArray[i]; | 182 HTMLImageElement* element = imageElementsArray[i]; |
183 const AtomicString& idAttrVal = element->getIdAttribute(); | 183 const AtomicString& idAttrVal = element->getIdAttribute(); |
184 const AtomicString& nameAttrVal = element->getNameAttribute(); | 184 const AtomicString& nameAttrVal = element->getNameAttribute(); |
185 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) | 185 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) |
186 appendIdCache(idAttrVal, element); | 186 appendIdCache(idAttrVal, element); |
187 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) | 187 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) |
188 appendNameCache(nameAttrVal, element); | 188 appendNameCache(nameAttrVal, element); |
189 } | 189 } |
190 } | 190 } |
191 | 191 |
192 setHasNameCache(); | 192 setHasValidIdNameCache(); |
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, RefPtr<RadioNodeList>& radioNodeList, bool& elementEnabled, R
efPtr<Element>& element) |
196 { | 196 { |
197 Vector<RefPtr<Element> > namedItems; | 197 Vector<RefPtr<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 |
(...skipping 28 matching lines...) Expand all Loading... |
231 const AtomicString& nameAttribute = element->getNameAttribute(); | 231 const AtomicString& nameAttribute = element->getNameAttribute(); |
232 if (!nameAttribute.isEmpty()) { | 232 if (!nameAttribute.isEmpty()) { |
233 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 233 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
234 if (addResult.isNewEntry) | 234 if (addResult.isNewEntry) |
235 names.append(nameAttribute); | 235 names.append(nameAttribute); |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 } | 240 } |
OLD | NEW |