| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 || element.hasLocalName(framesetTag) | 302 || element.hasLocalName(framesetTag) |
| 303 || element.hasLocalName(iframeTag) | 303 || element.hasLocalName(iframeTag) |
| 304 || element.hasLocalName(imgTag) | 304 || element.hasLocalName(imgTag) |
| 305 || element.hasLocalName(inputTag) | 305 || element.hasLocalName(inputTag) |
| 306 || element.hasLocalName(objectTag) | 306 || element.hasLocalName(objectTag) |
| 307 || element.hasLocalName(selectTag); | 307 || element.hasLocalName(selectTag); |
| 308 } | 308 } |
| 309 | 309 |
| 310 inline Element* firstMatchingChildElement(const HTMLCollection& nodeList, const
ContainerNode& root) | 310 inline Element* firstMatchingChildElement(const HTMLCollection& nodeList, const
ContainerNode& root) |
| 311 { | 311 { |
| 312 Element* element = ElementTraversal::firstWithin(root); | 312 Element* element = ElementTraversal::firstChild(root); |
| 313 while (element && !isMatchingElement(nodeList, *element)) | 313 while (element && !isMatchingElement(nodeList, *element)) |
| 314 element = ElementTraversal::nextSkippingChildren(*element, &root); | 314 element = ElementTraversal::nextSibling(*element); |
| 315 return element; | 315 return element; |
| 316 } | 316 } |
| 317 | 317 |
| 318 inline Element* nextMatchingChildElement(const HTMLCollection& nodeList, Element
& current, const ContainerNode& root) | 318 inline Element* nextMatchingChildElement(const HTMLCollection& nodeList, Element
& current) |
| 319 { | 319 { |
| 320 Element* next = ¤t; | 320 Element* next = ¤t; |
| 321 do { | 321 do { |
| 322 next = ElementTraversal::nextSkippingChildren(*next, &root); | 322 next = ElementTraversal::nextSibling(*next); |
| 323 } while (next && !isMatchingElement(nodeList, *next)); | 323 } while (next && !isMatchingElement(nodeList, *next)); |
| 324 return next; | 324 return next; |
| 325 } | 325 } |
| 326 | 326 |
| 327 Element* HTMLCollection::traverseToFirstElement(const ContainerNode& root) const | 327 Element* HTMLCollection::traverseToFirstElement(const ContainerNode& root) const |
| 328 { | 328 { |
| 329 switch (type()) { | 329 switch (type()) { |
| 330 case HTMLTagCollectionType: | 330 case HTMLTagCollectionType: |
| 331 return firstMatchingElement(static_cast<const HTMLTagCollection&>(*this)
, root); | 331 return firstMatchingElement(static_cast<const HTMLTagCollection&>(*this)
, root); |
| 332 case ClassCollectionType: | 332 case ClassCollectionType: |
| 333 return firstMatchingElement(static_cast<const ClassCollection&>(*this),
root); | 333 return firstMatchingElement(static_cast<const ClassCollection&>(*this),
root); |
| 334 default: | 334 default: |
| 335 if (overridesItemAfter()) | 335 if (overridesItemAfter()) |
| 336 return virtualItemAfter(0); | 336 return virtualItemAfter(0); |
| 337 if (shouldOnlyIncludeDirectChildren()) | 337 if (shouldOnlyIncludeDirectChildren()) |
| 338 return firstMatchingChildElement(*this, root); | 338 return firstMatchingChildElement(*this, root); |
| 339 return firstMatchingElement(*this, root); | 339 return firstMatchingElement(*this, root); |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 inline Element* HTMLCollection::traverseNextElement(Element& previous, const Con
tainerNode& root) const | 343 inline Element* HTMLCollection::traverseNextElement(Element& previous, const Con
tainerNode& root) const |
| 344 { | 344 { |
| 345 if (overridesItemAfter()) | 345 if (overridesItemAfter()) |
| 346 return virtualItemAfter(&previous); | 346 return virtualItemAfter(&previous); |
| 347 if (shouldOnlyIncludeDirectChildren()) | 347 if (shouldOnlyIncludeDirectChildren()) |
| 348 return nextMatchingChildElement(*this, previous, root); | 348 return nextMatchingChildElement(*this, previous); |
| 349 return nextMatchingElement(*this, previous, root); | 349 return nextMatchingElement(*this, previous, root); |
| 350 } | 350 } |
| 351 | 351 |
| 352 Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element& curre
ntElement, unsigned& currentOffset, const ContainerNode& root) const | 352 Element* HTMLCollection::traverseForwardToOffset(unsigned offset, Element& curre
ntElement, unsigned& currentOffset, const ContainerNode& root) const |
| 353 { | 353 { |
| 354 ASSERT(currentOffset < offset); | 354 ASSERT(currentOffset < offset); |
| 355 switch (type()) { | 355 switch (type()) { |
| 356 case HTMLTagCollectionType: | 356 case HTMLTagCollectionType: |
| 357 return traverseMatchingElementsForwardToOffset(static_cast<const HTMLTag
Collection&>(*this), offset, currentElement, currentOffset, root); | 357 return traverseMatchingElementsForwardToOffset(static_cast<const HTMLTag
Collection&>(*this), offset, currentElement, currentOffset, root); |
| 358 case ClassCollectionType: | 358 case ClassCollectionType: |
| 359 return traverseMatchingElementsForwardToOffset(static_cast<const ClassCo
llection&>(*this), offset, currentElement, currentOffset, root); | 359 return traverseMatchingElementsForwardToOffset(static_cast<const ClassCo
llection&>(*this), offset, currentElement, currentOffset, root); |
| 360 default: | 360 default: |
| 361 if (overridesItemAfter()) { | 361 if (overridesItemAfter()) { |
| 362 Element* next = ¤tElement; | 362 Element* next = ¤tElement; |
| 363 while ((next = virtualItemAfter(next))) { | 363 while ((next = virtualItemAfter(next))) { |
| 364 if (++currentOffset == offset) | 364 if (++currentOffset == offset) |
| 365 return next; | 365 return next; |
| 366 } | 366 } |
| 367 return 0; | 367 return 0; |
| 368 } | 368 } |
| 369 if (shouldOnlyIncludeDirectChildren()) { | 369 if (shouldOnlyIncludeDirectChildren()) { |
| 370 Element* next = ¤tElement; | 370 Element* next = ¤tElement; |
| 371 while ((next = nextMatchingChildElement(*this, *next, root))) { | 371 while ((next = nextMatchingChildElement(*this, *next))) { |
| 372 if (++currentOffset == offset) | 372 if (++currentOffset == offset) |
| 373 return next; | 373 return next; |
| 374 } | 374 } |
| 375 return 0; | 375 return 0; |
| 376 } | 376 } |
| 377 return traverseMatchingElementsForwardToOffset(*this, offset, currentEle
ment, currentOffset, root); | 377 return traverseMatchingElementsForwardToOffset(*this, offset, currentEle
ment, currentOffset, root); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 Element* HTMLCollection::namedItem(const AtomicString& name) const | 381 Element* HTMLCollection::namedItem(const AtomicString& name) const |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 | 478 |
| 479 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) | 479 void HTMLCollection::append(NodeCacheMap& map, const AtomicString& key, Element*
element) |
| 480 { | 480 { |
| 481 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).storedValue
->value; | 481 OwnPtr<Vector<Element*> >& vector = map.add(key.impl(), nullptr).storedValue
->value; |
| 482 if (!vector) | 482 if (!vector) |
| 483 vector = adoptPtr(new Vector<Element*>); | 483 vector = adoptPtr(new Vector<Element*>); |
| 484 vector->append(element); | 484 vector->append(element); |
| 485 } | 485 } |
| 486 | 486 |
| 487 } // namespace WebCore | 487 } // namespace WebCore |
| OLD | NEW |