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

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

Issue 2384273007: reflow comments in core/html/*.{cpp,h},core/html/imports (Closed)
Patch Set: comments Created 4 years, 2 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
5 * rights reserved.
5 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 6 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
6 * 7 *
7 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * 12 *
12 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 const AtomicString& nameAttrVal = element->getNameAttribute(); 174 const AtomicString& nameAttrVal = element->getNameAttribute();
174 if (!idAttrVal.isEmpty() && 175 if (!idAttrVal.isEmpty() &&
175 !foundInputElements.contains(idAttrVal.impl())) 176 !foundInputElements.contains(idAttrVal.impl()))
176 cache->addElementWithId(idAttrVal, element); 177 cache->addElementWithId(idAttrVal, element);
177 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal && 178 if (!nameAttrVal.isEmpty() && idAttrVal != nameAttrVal &&
178 !foundInputElements.contains(nameAttrVal.impl())) 179 !foundInputElements.contains(nameAttrVal.impl()))
179 cache->addElementWithName(nameAttrVal, element); 180 cache->addElementWithName(nameAttrVal, element);
180 } 181 }
181 } 182 }
182 183
183 // Set the named item cache last as traversing the tree may cause cache invali dation. 184 // Set the named item cache last as traversing the tree may cause cache
185 // invalidation.
184 setNamedItemCache(cache); 186 setNamedItemCache(cache);
185 } 187 }
186 188
187 void HTMLFormControlsCollection::namedGetter( 189 void HTMLFormControlsCollection::namedGetter(
188 const AtomicString& name, 190 const AtomicString& name,
189 RadioNodeListOrElement& returnValue) { 191 RadioNodeListOrElement& returnValue) {
190 HeapVector<Member<Element>> namedItems; 192 HeapVector<Member<Element>> namedItems;
191 this->namedItems(name, namedItems); 193 this->namedItems(name, namedItems);
192 194
193 if (namedItems.isEmpty()) 195 if (namedItems.isEmpty())
194 return; 196 return;
195 197
196 if (namedItems.size() == 1) { 198 if (namedItems.size() == 1) {
197 if (!isHTMLImageElement(*namedItems[0])) 199 if (!isHTMLImageElement(*namedItems[0]))
198 returnValue.setElement(namedItems.at(0)); 200 returnValue.setElement(namedItems.at(0));
199 return; 201 return;
200 } 202 }
201 203
202 // This path never returns a RadioNodeList for <img> because 204 // This path never returns a RadioNodeList for <img> because
203 // onlyMatchingImgElements flag is false by default. 205 // onlyMatchingImgElements flag is false by default.
204 returnValue.setRadioNodeList(ownerNode().radioNodeList(name)); 206 returnValue.setRadioNodeList(ownerNode().radioNodeList(name));
205 if (isHTMLFieldSetElement(ownerNode())) 207 if (isHTMLFieldSetElement(ownerNode()))
206 UseCounter::count( 208 UseCounter::count(
207 document(), 209 document(),
208 UseCounter::FormControlsCollectionReturnsRadioNodeListForFieldSet); 210 UseCounter::FormControlsCollectionReturnsRadioNodeListForFieldSet);
209 } 211 }
210 212
211 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names) { 213 void HTMLFormControlsCollection::supportedPropertyNames(Vector<String>& names) {
212 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-inte rfaces.html#htmlformcontrolscollection-0: 214 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-inte rfaces.html#htmlformcontrolscollection-0:
213 // The supported property names consist of the non-empty values of all the id and name attributes 215 // The supported property names consist of the non-empty values of all the id
214 // of all the elements represented by the collection, in tree order, ignoring later duplicates, 216 // and name attributes of all the elements represented by the collection, in
215 // with the id of an element preceding its name if it contributes both, they d iffer from each 217 // tree order, ignoring later duplicates, with the id of an element preceding
216 // other, and neither is the duplicate of an earlier entry. 218 // its name if it contributes both, they differ from each other, and neither
219 // is the duplicate of an earlier entry.
217 HashSet<AtomicString> existingNames; 220 HashSet<AtomicString> existingNames;
218 unsigned length = this->length(); 221 unsigned length = this->length();
219 for (unsigned i = 0; i < length; ++i) { 222 for (unsigned i = 0; i < length; ++i) {
220 HTMLElement* element = item(i); 223 HTMLElement* element = item(i);
221 DCHECK(element); 224 DCHECK(element);
222 const AtomicString& idAttribute = element->getIdAttribute(); 225 const AtomicString& idAttribute = element->getIdAttribute();
223 if (!idAttribute.isEmpty()) { 226 if (!idAttribute.isEmpty()) {
224 HashSet<AtomicString>::AddResult addResult = 227 HashSet<AtomicString>::AddResult addResult =
225 existingNames.add(idAttribute); 228 existingNames.add(idAttribute);
226 if (addResult.isNewEntry) 229 if (addResult.isNewEntry)
227 names.append(idAttribute); 230 names.append(idAttribute);
228 } 231 }
229 const AtomicString& nameAttribute = element->getNameAttribute(); 232 const AtomicString& nameAttribute = element->getNameAttribute();
230 if (!nameAttribute.isEmpty()) { 233 if (!nameAttribute.isEmpty()) {
231 HashSet<AtomicString>::AddResult addResult = 234 HashSet<AtomicString>::AddResult addResult =
232 existingNames.add(nameAttribute); 235 existingNames.add(nameAttribute);
233 if (addResult.isNewEntry) 236 if (addResult.isNewEntry)
234 names.append(nameAttribute); 237 names.append(nameAttribute);
235 } 238 }
236 } 239 }
237 } 240 }
238 241
239 DEFINE_TRACE(HTMLFormControlsCollection) { 242 DEFINE_TRACE(HTMLFormControlsCollection) {
240 visitor->trace(m_cachedElement); 243 visitor->trace(m_cachedElement);
241 HTMLCollection::trace(visitor); 244 HTMLCollection::trace(visitor);
242 } 245 }
243 246
244 } // namespace blink 247 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698