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-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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 412 |
413 Element* HTMLCollection::namedItem(const AtomicString& name) const { | 413 Element* HTMLCollection::namedItem(const AtomicString& name) const { |
414 // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem
.asp | 414 // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem
.asp |
415 // This method first searches for an object with a matching id | 415 // This method first searches for an object with a matching id |
416 // attribute. If a match is not found, the method then searches for an | 416 // attribute. If a match is not found, the method then searches for an |
417 // object with a matching name attribute, but only on those elements | 417 // object with a matching name attribute, but only on those elements |
418 // that are allowed a name attribute. | 418 // that are allowed a name attribute. |
419 updateIdNameCache(); | 419 updateIdNameCache(); |
420 | 420 |
421 const NamedItemCache& cache = namedItemCache(); | 421 const NamedItemCache& cache = namedItemCache(); |
422 HeapVector<Member<Element>>* idResults = cache.getElementsById(name); | 422 const auto* idResults = cache.getElementsById(name); |
423 if (idResults && !idResults->isEmpty()) | 423 if (idResults && !idResults->isEmpty()) |
424 return idResults->front(); | 424 return idResults->front(); |
425 | 425 |
426 HeapVector<Member<Element>>* nameResults = cache.getElementsByName(name); | 426 const auto* nameResults = cache.getElementsByName(name); |
427 if (nameResults && !nameResults->isEmpty()) | 427 if (nameResults && !nameResults->isEmpty()) |
428 return nameResults->front(); | 428 return nameResults->front(); |
429 | 429 |
430 return nullptr; | 430 return nullptr; |
431 } | 431 } |
432 | 432 |
433 bool HTMLCollection::namedPropertyQuery(const AtomicString& name, | 433 bool HTMLCollection::namedPropertyQuery(const AtomicString& name, |
434 ExceptionState&) { | 434 ExceptionState&) { |
435 return namedItem(name); | 435 return namedItem(name); |
436 } | 436 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 void HTMLCollection::namedItems(const AtomicString& name, | 505 void HTMLCollection::namedItems(const AtomicString& name, |
506 HeapVector<Member<Element>>& result) const { | 506 HeapVector<Member<Element>>& result) const { |
507 DCHECK(result.isEmpty()); | 507 DCHECK(result.isEmpty()); |
508 if (name.isEmpty()) | 508 if (name.isEmpty()) |
509 return; | 509 return; |
510 | 510 |
511 updateIdNameCache(); | 511 updateIdNameCache(); |
512 | 512 |
513 const NamedItemCache& cache = namedItemCache(); | 513 const NamedItemCache& cache = namedItemCache(); |
514 if (HeapVector<Member<Element>>* idResults = cache.getElementsById(name)) { | 514 if (const auto* idResults = cache.getElementsById(name)) |
515 for (const auto& element : *idResults) | 515 result.appendVector(*idResults); |
516 result.push_back(element); | 516 if (const auto* nameResults = cache.getElementsByName(name)) |
517 } | 517 result.appendVector(*nameResults); |
518 if (HeapVector<Member<Element>>* nameResults = | |
519 cache.getElementsByName(name)) { | |
520 for (const auto& element : *nameResults) | |
521 result.push_back(element); | |
522 } | |
523 } | 518 } |
524 | 519 |
525 HTMLCollection::NamedItemCache::NamedItemCache() {} | 520 HTMLCollection::NamedItemCache::NamedItemCache() {} |
526 | 521 |
527 DEFINE_TRACE(HTMLCollection) { | 522 DEFINE_TRACE(HTMLCollection) { |
528 visitor->trace(m_namedItemCache); | 523 visitor->trace(m_namedItemCache); |
529 visitor->trace(m_collectionItemsCache); | 524 visitor->trace(m_collectionItemsCache); |
530 LiveNodeListBase::trace(visitor); | 525 LiveNodeListBase::trace(visitor); |
531 } | 526 } |
532 | 527 |
533 } // namespace blink | 528 } // namespace blink |
OLD | NEW |