OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 12 matching lines...) Expand all Loading... |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/html/HTMLAllCollection.h" | 27 #include "core/html/HTMLAllCollection.h" |
28 | 28 |
29 #include "core/dom/Element.h" | 29 #include "core/dom/Element.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(Node* node, CollectionTy
pe type) | 33 PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(const Handle<Node>& node
, CollectionType type) |
34 { | 34 { |
35 return adoptRef(new HTMLAllCollection(node, type)); | 35 return adoptRef(new HTMLAllCollection(node, type)); |
36 } | 36 } |
37 | 37 |
38 HTMLAllCollection::HTMLAllCollection(Node* node, CollectionType type) | 38 HTMLAllCollection::HTMLAllCollection(const Handle<Node>& node, CollectionType ty
pe) |
39 : HTMLCollection(node, type, DoesNotOverrideItemAfter) | 39 : HTMLCollection(node, type, DoesNotOverrideItemAfter) |
40 { | 40 { |
41 ScriptWrappable::init(this); | 41 ScriptWrappable::init(this); |
42 } | 42 } |
43 | 43 |
44 HTMLAllCollection::~HTMLAllCollection() | 44 HTMLAllCollection::~HTMLAllCollection() |
45 { | 45 { |
46 } | 46 } |
47 | 47 |
48 Node* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigned i
ndex) const | 48 Result<Node> HTMLAllCollection::namedItemWithIndex(const AtomicString& name, uns
igned index) const |
49 { | 49 { |
50 updateNameCache(); | 50 updateNameCache(); |
51 | 51 |
52 if (CollectionRoot<Vector<Member<Element> > >* cache = idCache(name)) { | 52 if (CollectionRoot<Vector<Member<Element> > >* cache = idCache(name)) { |
53 if (index < (*cache)->size()) | 53 if (index < (*cache)->size()) |
54 return (*cache)->at(index).handle().raw(); | 54 return (*cache)->at(index); |
55 index -= (*cache)->size(); | 55 index -= (*cache)->size(); |
56 } | 56 } |
57 | 57 |
58 if (CollectionRoot<Vector<Member<Element> > >* cache = nameCache(name)) { | 58 if (CollectionRoot<Vector<Member<Element> > >* cache = nameCache(name)) { |
59 if (index < (*cache)->size()) | 59 if (index < (*cache)->size()) |
60 return (*cache)->at(index).handle().raw(); | 60 return (*cache)->at(index); |
61 } | 61 } |
62 | 62 |
63 return 0; | 63 return nullptr; |
64 } | 64 } |
65 | 65 |
66 } // namespace WebCore | 66 } // namespace WebCore |
OLD | NEW |