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, 2008, 2011, 2012 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 template <> inline bool isMatchingElement(const HTMLCollection& htmlCollection,
const Element& element) | 194 template <> inline bool isMatchingElement(const HTMLCollection& htmlCollection,
const Element& element) |
195 { | 195 { |
196 CollectionType type = htmlCollection.type(); | 196 CollectionType type = htmlCollection.type(); |
197 | 197 |
198 // These collections apply to any kind of Elements, not just HTMLElements. | 198 // These collections apply to any kind of Elements, not just HTMLElements. |
199 switch (type) { | 199 switch (type) { |
200 case DocAll: | 200 case DocAll: |
201 case NodeChildren: | 201 case NodeChildren: |
202 return true; | 202 return true; |
203 case ClassCollectionType: | 203 case ClassCollectionType: |
204 return static_cast<const ClassCollection&>(htmlCollection).elementMatche
s(element); | 204 return toClassCollection(htmlCollection).elementMatches(element); |
205 case TagCollectionType: | 205 case TagCollectionType: |
206 return static_cast<const TagCollection&>(htmlCollection).elementMatches(
element); | 206 return toTagCollection(htmlCollection).elementMatches(element); |
207 case HTMLTagCollectionType: | 207 case HTMLTagCollectionType: |
208 return static_cast<const HTMLTagCollection&>(htmlCollection).elementMatc
hes(element); | 208 return toHTMLTagCollection(htmlCollection).elementMatches(element); |
209 default: | 209 default: |
210 break; | 210 break; |
211 } | 211 } |
212 | 212 |
213 // The following only applies to HTMLElements. | 213 // The following only applies to HTMLElements. |
214 if (!element.isHTMLElement()) | 214 if (!element.isHTMLElement()) |
215 return false; | 215 return false; |
216 | 216 |
217 switch (type) { | 217 switch (type) { |
218 case DocImages: | 218 case DocImages: |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 do { | 332 do { |
333 previous = ElementTraversal::previousSibling(*previous); | 333 previous = ElementTraversal::previousSibling(*previous); |
334 } while (previous && !isMatchingElement(nodeList, *previous)); | 334 } while (previous && !isMatchingElement(nodeList, *previous)); |
335 return previous; | 335 return previous; |
336 } | 336 } |
337 | 337 |
338 Element* HTMLCollection::traverseToFirstElement() const | 338 Element* HTMLCollection::traverseToFirstElement() const |
339 { | 339 { |
340 switch (type()) { | 340 switch (type()) { |
341 case HTMLTagCollectionType: | 341 case HTMLTagCollectionType: |
342 return firstMatchingElement(static_cast<const HTMLTagCollection&>(*this)
); | 342 return firstMatchingElement(toHTMLTagCollection(*this)); |
343 case ClassCollectionType: | 343 case ClassCollectionType: |
344 return firstMatchingElement(static_cast<const ClassCollection&>(*this)); | 344 return firstMatchingElement(toClassCollection(*this)); |
345 default: | 345 default: |
346 if (overridesItemAfter()) | 346 if (overridesItemAfter()) |
347 return virtualItemAfter(0); | 347 return virtualItemAfter(0); |
348 if (shouldOnlyIncludeDirectChildren()) | 348 if (shouldOnlyIncludeDirectChildren()) |
349 return firstMatchingChildElement(*this); | 349 return firstMatchingChildElement(*this); |
350 return firstMatchingElement(*this); | 350 return firstMatchingElement(*this); |
351 } | 351 } |
352 } | 352 } |
353 | 353 |
354 Element* HTMLCollection::traverseToLastElement() const | 354 Element* HTMLCollection::traverseToLastElement() const |
(...skipping 11 matching lines...) Expand all Loading... |
366 if (shouldOnlyIncludeDirectChildren()) | 366 if (shouldOnlyIncludeDirectChildren()) |
367 return nextMatchingChildElement(*this, previous); | 367 return nextMatchingChildElement(*this, previous); |
368 return nextMatchingElement(*this, previous); | 368 return nextMatchingElement(*this, previous); |
369 } | 369 } |
370 | 370 |
371 Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element& curre
ntElement, unsigned& currentOffset) const | 371 Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element& curre
ntElement, unsigned& currentOffset) const |
372 { | 372 { |
373 ASSERT(currentOffset < offset); | 373 ASSERT(currentOffset < offset); |
374 switch (type()) { | 374 switch (type()) { |
375 case HTMLTagCollectionType: | 375 case HTMLTagCollectionType: |
376 return traverseMatchingElementsForwardToOffset(static_cast<const HTMLTag
Collection&>(*this), offset, currentElement, currentOffset); | 376 return traverseMatchingElementsForwardToOffset(toHTMLTagCollection(*this
), offset, currentElement, currentOffset); |
377 case ClassCollectionType: | 377 case ClassCollectionType: |
378 return traverseMatchingElementsForwardToOffset(static_cast<const ClassCo
llection&>(*this), offset, currentElement, currentOffset); | 378 return traverseMatchingElementsForwardToOffset(toClassCollection(*this),
offset, currentElement, currentOffset); |
379 default: | 379 default: |
380 if (overridesItemAfter()) { | 380 if (overridesItemAfter()) { |
381 Element* next = ¤tElement; | 381 Element* next = ¤tElement; |
382 while ((next = virtualItemAfter(next))) { | 382 while ((next = virtualItemAfter(next))) { |
383 if (++currentOffset == offset) | 383 if (++currentOffset == offset) |
384 return next; | 384 return next; |
385 } | 385 } |
386 return 0; | 386 return 0; |
387 } | 387 } |
388 if (shouldOnlyIncludeDirectChildren()) { | 388 if (shouldOnlyIncludeDirectChildren()) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 516 } |
517 | 517 |
518 void HTMLCollection::trace(Visitor* visitor) | 518 void HTMLCollection::trace(Visitor* visitor) |
519 { | 519 { |
520 visitor->trace(m_namedItemCache); | 520 visitor->trace(m_namedItemCache); |
521 visitor->trace(m_collectionIndexCache); | 521 visitor->trace(m_collectionIndexCache); |
522 LiveNodeListBase::trace(visitor); | 522 LiveNodeListBase::trace(visitor); |
523 } | 523 } |
524 | 524 |
525 } // namespace WebCore | 525 } // namespace WebCore |
OLD | NEW |