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

Side by Side Diff: Source/core/html/HTMLCollection.cpp

Issue 492453002: Make it clear a DocumentNameCollection can only contain HTMLElements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Clean up Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/DocumentNameCollection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2008, 2011, 2012, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2003-2008, 2011, 2012, 2014 Apple Inc. All rights 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 static inline bool isMatchingHTMLElement(const HTMLCollection& htmlCollection, c onst HTMLElement& element) 204 static inline bool isMatchingHTMLElement(const HTMLCollection& htmlCollection, c onst HTMLElement& element)
205 { 205 {
206 switch (htmlCollection.type()) { 206 switch (htmlCollection.type()) {
207 case DocImages: 207 case DocImages:
208 return element.hasTagName(imgTag); 208 return element.hasTagName(imgTag);
209 case DocScripts: 209 case DocScripts:
210 return element.hasTagName(scriptTag); 210 return element.hasTagName(scriptTag);
211 case DocForms: 211 case DocForms:
212 return element.hasTagName(formTag); 212 return element.hasTagName(formTag);
213 case DocumentNamedItems:
214 return toDocumentNameCollection(htmlCollection).elementMatches(element);
213 case TableTBodies: 215 case TableTBodies:
214 return element.hasTagName(tbodyTag); 216 return element.hasTagName(tbodyTag);
215 case TRCells: 217 case TRCells:
216 return element.hasTagName(tdTag) || element.hasTagName(thTag); 218 return element.hasTagName(tdTag) || element.hasTagName(thTag);
217 case TSectionRows: 219 case TSectionRows:
218 return element.hasTagName(trTag); 220 return element.hasTagName(trTag);
219 case SelectOptions: 221 case SelectOptions:
220 return element.hasTagName(optionTag); 222 return element.hasTagName(optionTag);
221 case SelectedOptions: 223 case SelectedOptions:
222 return isHTMLOptionElement(element) && toHTMLOptionElement(element).sele cted(); 224 return isHTMLOptionElement(element) && toHTMLOptionElement(element).sele cted();
(...skipping 13 matching lines...) Expand all
236 case DocLinks: 238 case DocLinks:
237 return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && elem ent.fastHasAttribute(hrefAttr); 239 return (element.hasTagName(aTag) || element.hasTagName(areaTag)) && elem ent.fastHasAttribute(hrefAttr);
238 case DocAnchors: 240 case DocAnchors:
239 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr); 241 return element.hasTagName(aTag) && element.fastHasAttribute(nameAttr);
240 case ClassCollectionType: 242 case ClassCollectionType:
241 case TagCollectionType: 243 case TagCollectionType:
242 case HTMLTagCollectionType: 244 case HTMLTagCollectionType:
243 case DocAll: 245 case DocAll:
244 case NodeChildren: 246 case NodeChildren:
245 case FormControls: 247 case FormControls:
246 case DocumentNamedItems:
247 case TableRows: 248 case TableRows:
248 case WindowNamedItems: 249 case WindowNamedItems:
249 case NameNodeListType: 250 case NameNodeListType:
250 case RadioNodeListType: 251 case RadioNodeListType:
251 case RadioImgNodeListType: 252 case RadioImgNodeListType:
252 case LabelsNodeListType: 253 case LabelsNodeListType:
253 ASSERT_NOT_REACHED(); 254 ASSERT_NOT_REACHED();
254 } 255 }
255 return false; 256 return false;
256 } 257 }
257 258
258 inline bool HTMLCollection::elementMatches(const Element& element) const 259 inline bool HTMLCollection::elementMatches(const Element& element) const
259 { 260 {
260 // These collections apply to any kind of Elements, not just HTMLElements. 261 // These collections apply to any kind of Elements, not just HTMLElements.
261 switch (type()) { 262 switch (type()) {
262 case DocAll: 263 case DocAll:
263 case NodeChildren: 264 case NodeChildren:
264 return true; 265 return true;
265 case ClassCollectionType: 266 case ClassCollectionType:
266 return toClassCollection(*this).elementMatches(element); 267 return toClassCollection(*this).elementMatches(element);
267 case TagCollectionType: 268 case TagCollectionType:
268 return toTagCollection(*this).elementMatches(element); 269 return toTagCollection(*this).elementMatches(element);
269 case HTMLTagCollectionType: 270 case HTMLTagCollectionType:
270 return toHTMLTagCollection(*this).elementMatches(element); 271 return toHTMLTagCollection(*this).elementMatches(element);
271 case DocumentNamedItems:
272 return toDocumentNameCollection(*this).elementMatches(element);
273 case WindowNamedItems: 272 case WindowNamedItems:
274 return toWindowNameCollection(*this).elementMatches(element); 273 return toWindowNameCollection(*this).elementMatches(element);
275 default: 274 default:
276 break; 275 break;
277 } 276 }
278 277
279 // The following only applies to HTMLElements. 278 // The following only applies to HTMLElements.
280 return element.isHTMLElement() && isMatchingHTMLElement(*this, toHTMLElement (element)); 279 return element.isHTMLElement() && isMatchingHTMLElement(*this, toHTMLElement (element));
281 } 280 }
282 281
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 502 }
504 503
505 void HTMLCollection::trace(Visitor* visitor) 504 void HTMLCollection::trace(Visitor* visitor)
506 { 505 {
507 visitor->trace(m_namedItemCache); 506 visitor->trace(m_namedItemCache);
508 visitor->trace(m_collectionIndexCache); 507 visitor->trace(m_collectionIndexCache);
509 LiveNodeListBase::trace(visitor); 508 LiveNodeListBase::trace(visitor);
510 } 509 }
511 510
512 } // namespace blink 511 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/DocumentNameCollection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698