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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 { | 51 { |
52 return adoptRef(new HTMLFormControlsCollection(ownerNode)); | 52 return adoptRef(new HTMLFormControlsCollection(ownerNode)); |
53 } | 53 } |
54 | 54 |
55 HTMLFormControlsCollection::~HTMLFormControlsCollection() | 55 HTMLFormControlsCollection::~HTMLFormControlsCollection() |
56 { | 56 { |
57 } | 57 } |
58 | 58 |
59 const Vector<FormAssociatedElement*>& HTMLFormControlsCollection::formControlEle
ments() const | 59 const Vector<FormAssociatedElement*>& HTMLFormControlsCollection::formControlEle
ments() const |
60 { | 60 { |
61 ASSERT(ownerNode()); | 61 ASSERT(ownerNode().hasTagName(formTag) || ownerNode().hasTagName(fieldsetTag
)); |
62 ASSERT(ownerNode()->hasTagName(formTag) || ownerNode()->hasTagName(fieldsetT
ag)); | 62 if (ownerNode().hasTagName(formTag)) |
63 if (ownerNode()->hasTagName(formTag)) | 63 return toHTMLFormElement(ownerNode()).associatedElements(); |
64 return toHTMLFormElement(ownerNode())->associatedElements(); | 64 return toHTMLFieldSetElement(ownerNode()).associatedElements(); |
65 return toHTMLFieldSetElement(ownerNode())->associatedElements(); | |
66 } | 65 } |
67 | 66 |
68 const Vector<HTMLImageElement*>& HTMLFormControlsCollection::formImageElements()
const | 67 const Vector<HTMLImageElement*>& HTMLFormControlsCollection::formImageElements()
const |
69 { | 68 { |
70 ASSERT(ownerNode()); | 69 return toHTMLFormElement(ownerNode()).imageElements(); |
71 return toHTMLFormElement(ownerNode())->imageElements(); | |
72 } | 70 } |
73 | 71 |
74 static unsigned findFormAssociatedElement(const Vector<FormAssociatedElement*>&
associatedElements, Element* element) | 72 static unsigned findFormAssociatedElement(const Vector<FormAssociatedElement*>&
associatedElements, Element* element) |
75 { | 73 { |
76 unsigned i = 0; | 74 unsigned i = 0; |
77 for (; i < associatedElements.size(); ++i) { | 75 for (; i < associatedElements.size(); ++i) { |
78 FormAssociatedElement* associatedElement = associatedElements[i]; | 76 FormAssociatedElement* associatedElement = associatedElements[i]; |
79 if (associatedElement->isEnumeratable() && toHTMLElement(associatedEleme
nt) == element) | 77 if (associatedElement->isEnumeratable() && toHTMLElement(associatedEleme
nt) == element) |
80 break; | 78 break; |
81 } | 79 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return 0; | 134 return 0; |
137 } | 135 } |
138 | 136 |
139 Element* HTMLFormControlsCollection::namedItem(const AtomicString& name) const | 137 Element* HTMLFormControlsCollection::namedItem(const AtomicString& name) const |
140 { | 138 { |
141 // 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 |
142 // This method first searches for an object with a matching id | 140 // This method first searches for an object with a matching id |
143 // 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 |
144 // object with a matching name attribute, but only on those elements | 142 // object with a matching name attribute, but only on those elements |
145 // that are allowed a name attribute. | 143 // that are allowed a name attribute. |
146 const Vector<HTMLImageElement*>* imagesElements = ownerNode()->hasTagName(fi
eldsetTag) ? 0 : &formImageElements(); | 144 const Vector<HTMLImageElement*>* imagesElements = ownerNode().hasTagName(fie
ldsetTag) ? 0 : &formImageElements(); |
147 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements
, idAttr, name)) | 145 if (HTMLElement* item = firstNamedItem(formControlElements(), imagesElements
, idAttr, name)) |
148 return item; | 146 return item; |
149 | 147 |
150 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name)
; | 148 return firstNamedItem(formControlElements(), imagesElements, nameAttr, name)
; |
151 } | 149 } |
152 | 150 |
153 void HTMLFormControlsCollection::updateIdNameCache() const | 151 void HTMLFormControlsCollection::updateIdNameCache() const |
154 { | 152 { |
155 if (hasValidIdNameCache()) | 153 if (hasValidIdNameCache()) |
156 return; | 154 return; |
(...skipping 12 matching lines...) Expand all Loading... |
169 appendIdCache(idAttrVal, element); | 167 appendIdCache(idAttrVal, element); |
170 foundInputElements.add(idAttrVal.impl()); | 168 foundInputElements.add(idAttrVal.impl()); |
171 } | 169 } |
172 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { | 170 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { |
173 appendNameCache(nameAttrVal, element); | 171 appendNameCache(nameAttrVal, element); |
174 foundInputElements.add(nameAttrVal.impl()); | 172 foundInputElements.add(nameAttrVal.impl()); |
175 } | 173 } |
176 } | 174 } |
177 } | 175 } |
178 | 176 |
179 if (ownerNode()->hasTagName(formTag)) { | 177 if (ownerNode().hasTagName(formTag)) { |
180 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); | 178 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); |
181 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { | 179 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { |
182 HTMLImageElement* element = imageElementsArray[i]; | 180 HTMLImageElement* element = imageElementsArray[i]; |
183 const AtomicString& idAttrVal = element->getIdAttribute(); | 181 const AtomicString& idAttrVal = element->getIdAttribute(); |
184 const AtomicString& nameAttrVal = element->getNameAttribute(); | 182 const AtomicString& nameAttrVal = element->getNameAttribute(); |
185 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) | 183 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) |
186 appendIdCache(idAttrVal, element); | 184 appendIdCache(idAttrVal, element); |
187 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) | 185 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) |
188 appendNameCache(nameAttrVal, element); | 186 appendNameCache(nameAttrVal, element); |
189 } | 187 } |
(...skipping 10 matching lines...) Expand all Loading... |
200 if (namedItems.isEmpty()) | 198 if (namedItems.isEmpty()) |
201 return; | 199 return; |
202 | 200 |
203 if (namedItems.size() == 1) { | 201 if (namedItems.size() == 1) { |
204 elementEnabled = true; | 202 elementEnabled = true; |
205 element = namedItems.first(); | 203 element = namedItems.first(); |
206 return; | 204 return; |
207 } | 205 } |
208 | 206 |
209 radioNodeListEnabled = true; | 207 radioNodeListEnabled = true; |
210 radioNodeList = ownerNode()->radioNodeList(name); | 208 radioNodeList = ownerNode().radioNodeList(name); |
211 } | 209 } |
212 | 210 |
213 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names) | 211 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names) |
214 { | 212 { |
215 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlformcontrolscollection-0: | 213 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlformcontrolscollection-0: |
216 // The supported property names consist of the non-empty values of all the i
d and name attributes | 214 // The supported property names consist of the non-empty values of all the i
d and name attributes |
217 // of all the elements represented by the collection, in tree order, ignorin
g later duplicates, | 215 // of all the elements represented by the collection, in tree order, ignorin
g later duplicates, |
218 // with the id of an element preceding its name if it contributes both, they
differ from each | 216 // with the id of an element preceding its name if it contributes both, they
differ from each |
219 // other, and neither is the duplicate of an earlier entry. | 217 // other, and neither is the duplicate of an earlier entry. |
220 HashSet<AtomicString> existingNames; | 218 HashSet<AtomicString> existingNames; |
(...skipping 10 matching lines...) Expand all Loading... |
231 const AtomicString& nameAttribute = element->getNameAttribute(); | 229 const AtomicString& nameAttribute = element->getNameAttribute(); |
232 if (!nameAttribute.isEmpty()) { | 230 if (!nameAttribute.isEmpty()) { |
233 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 231 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
234 if (addResult.isNewEntry) | 232 if (addResult.isNewEntry) |
235 names.append(nameAttribute); | 233 names.append(nameAttribute); |
236 } | 234 } |
237 } | 235 } |
238 } | 236 } |
239 | 237 |
240 } | 238 } |
OLD | NEW |