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 25 matching lines...) Expand all Loading... |
36 using namespace HTMLNames; | 36 using namespace HTMLNames; |
37 | 37 |
38 // Since the collections are to be "live", we have to do the | 38 // Since the collections are to be "live", we have to do the |
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(0) | 43 , m_cachedElement(0) |
44 , m_cachedElementOffsetInArray(0) | 44 , m_cachedElementOffsetInArray(0) |
45 { | 45 { |
46 ASSERT(ownerNode.hasTagName(formTag) || ownerNode.hasTagName(fieldsetTag)); | 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 PassRefPtr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(Contai
nerNode& ownerNode, CollectionType) |
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().hasTagName(formTag) || ownerNode().hasTagName(fieldsetTag
)); | 61 ASSERT(isHTMLFormElement(ownerNode()) || isHTMLFieldSetElement(ownerNode()))
; |
62 if (ownerNode().hasTagName(formTag)) | 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 Vector<HTMLImageElement*>& HTMLFormControlsCollection::formImageElements()
const | 67 const Vector<HTMLImageElement*>& HTMLFormControlsCollection::formImageElements()
const |
68 { | 68 { |
69 return toHTMLFormElement(ownerNode()).imageElements(); | 69 return toHTMLFormElement(ownerNode()).imageElements(); |
70 } | 70 } |
71 | 71 |
72 static unsigned findFormAssociatedElement(const Vector<FormAssociatedElement*>&
associatedElements, Element* element) | 72 static unsigned findFormAssociatedElement(const Vector<FormAssociatedElement*>&
associatedElements, Element* element) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 | 136 |
137 Element* HTMLFormControlsCollection::namedItem(const AtomicString& name) const | 137 Element* HTMLFormControlsCollection::namedItem(const AtomicString& name) const |
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 Vector<HTMLImageElement*>* imagesElements = ownerNode().hasTagName(fie
ldsetTag) ? 0 : &formImageElements(); | 144 const Vector<HTMLImageElement*>* imagesElements = isHTMLFieldSetElement(owne
rNode()) ? 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; |
(...skipping 12 matching lines...) Expand all Loading... |
167 appendIdCache(idAttrVal, element); | 167 appendIdCache(idAttrVal, element); |
168 foundInputElements.add(idAttrVal.impl()); | 168 foundInputElements.add(idAttrVal.impl()); |
169 } | 169 } |
170 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { | 170 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal) { |
171 appendNameCache(nameAttrVal, element); | 171 appendNameCache(nameAttrVal, element); |
172 foundInputElements.add(nameAttrVal.impl()); | 172 foundInputElements.add(nameAttrVal.impl()); |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 if (ownerNode().hasTagName(formTag)) { | 177 if (isHTMLFormElement(ownerNode())) { |
178 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); | 178 const Vector<HTMLImageElement*>& imageElementsArray = formImageElements(
); |
179 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { | 179 for (unsigned i = 0; i < imageElementsArray.size(); ++i) { |
180 HTMLImageElement* element = imageElementsArray[i]; | 180 HTMLImageElement* element = imageElementsArray[i]; |
181 const AtomicString& idAttrVal = element->getIdAttribute(); | 181 const AtomicString& idAttrVal = element->getIdAttribute(); |
182 const AtomicString& nameAttrVal = element->getNameAttribute(); | 182 const AtomicString& nameAttrVal = element->getNameAttribute(); |
183 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) | 183 if (!idAttrVal.isEmpty() && !foundInputElements.contains(idAttrVal.i
mpl())) |
184 appendIdCache(idAttrVal, element); | 184 appendIdCache(idAttrVal, element); |
185 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) | 185 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && !foundInpu
tElements.contains(nameAttrVal.impl())) |
186 appendNameCache(nameAttrVal, element); | 186 appendNameCache(nameAttrVal, element); |
187 } | 187 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 const AtomicString& nameAttribute = element->getNameAttribute(); | 229 const AtomicString& nameAttribute = element->getNameAttribute(); |
230 if (!nameAttribute.isEmpty()) { | 230 if (!nameAttribute.isEmpty()) { |
231 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); | 231 HashSet<AtomicString>::AddResult addResult = existingNames.add(nameA
ttribute); |
232 if (addResult.isNewEntry) | 232 if (addResult.isNewEntry) |
233 names.append(nameAttribute); | 233 names.append(nameAttribute); |
234 } | 234 } |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 } | 238 } |
OLD | NEW |