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 22 matching lines...) Expand all Loading... |
33 #include "core/html/HTMLElement.h" | 33 #include "core/html/HTMLElement.h" |
34 #include "core/html/HTMLObjectElement.h" | 34 #include "core/html/HTMLObjectElement.h" |
35 #include "core/html/HTMLOptionElement.h" | 35 #include "core/html/HTMLOptionElement.h" |
36 #include "core/html/HTMLOptionsCollection.h" | 36 #include "core/html/HTMLOptionsCollection.h" |
37 #include "core/html/HTMLTagCollection.h" | 37 #include "core/html/HTMLTagCollection.h" |
38 #include "core/html/WindowNameCollection.h" | 38 #include "core/html/WindowNameCollection.h" |
39 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
| 43 namespace { |
| 44 |
| 45 class HTMLCollectionIterationSource final : public ValueIterable<Element*>::Iter
ationSource { |
| 46 public: |
| 47 explicit HTMLCollectionIterationSource(HTMLCollection* collection) |
| 48 : m_collection(collection) |
| 49 { |
| 50 } |
| 51 |
| 52 bool next(ScriptState* scriptState, Element*& value, ExceptionState& excepti
onState) override |
| 53 { |
| 54 if (m_index >= m_collection->length()) { |
| 55 value = nullptr; |
| 56 return false; |
| 57 } |
| 58 value = m_collection->item(m_index); |
| 59 return true; |
| 60 } |
| 61 |
| 62 DEFINE_INLINE_VIRTUAL_TRACE() |
| 63 { |
| 64 visitor->trace(m_collection); |
| 65 ValueIterable<Element*>::IterationSource::trace(visitor); |
| 66 } |
| 67 |
| 68 private: |
| 69 const RefPtrWillBeMember<HTMLCollection> m_collection; |
| 70 }; |
| 71 |
| 72 } // namespace |
| 73 |
| 74 ValueIterable<Element*>::IterationSource* HTMLCollection::startIteration(ScriptS
tate*, ExceptionState&) |
| 75 { |
| 76 return new HTMLCollectionIterationSource(this); |
| 77 } |
| 78 |
43 using namespace HTMLNames; | 79 using namespace HTMLNames; |
44 | 80 |
45 static bool shouldTypeOnlyIncludeDirectChildren(CollectionType type) | 81 static bool shouldTypeOnlyIncludeDirectChildren(CollectionType type) |
46 { | 82 { |
47 switch (type) { | 83 switch (type) { |
48 case ClassCollectionType: | 84 case ClassCollectionType: |
49 case TagCollectionType: | 85 case TagCollectionType: |
50 case HTMLTagCollectionType: | 86 case HTMLTagCollectionType: |
51 case DocAll: | 87 case DocAll: |
52 case DocAnchors: | 88 case DocAnchors: |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 534 } |
499 | 535 |
500 DEFINE_TRACE(HTMLCollection) | 536 DEFINE_TRACE(HTMLCollection) |
501 { | 537 { |
502 visitor->trace(m_namedItemCache); | 538 visitor->trace(m_namedItemCache); |
503 visitor->trace(m_collectionItemsCache); | 539 visitor->trace(m_collectionItemsCache); |
504 LiveNodeListBase::trace(visitor); | 540 LiveNodeListBase::trace(visitor); |
505 } | 541 } |
506 | 542 |
507 } // namespace blink | 543 } // namespace blink |
OLD | NEW |