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 13 matching lines...) Expand all Loading... |
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 #include "core/dom/NamedNodesCollection.h" | 30 #include "core/dom/NamedNodesCollection.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 PassRefPtr<HTMLAllCollection> HTMLAllCollection::create(ContainerNode& node, Col
lectionType type) | 34 PassRefPtrWillBeRawPtr<HTMLAllCollection> HTMLAllCollection::create(ContainerNod
e& node, CollectionType type) |
35 { | 35 { |
36 return adoptRef(new HTMLAllCollection(node, type)); | 36 return adoptRefWillBeNoop(new HTMLAllCollection(node, type)); |
37 } | 37 } |
38 | 38 |
39 HTMLAllCollection::HTMLAllCollection(ContainerNode& node, CollectionType type) | 39 HTMLAllCollection::HTMLAllCollection(ContainerNode& node, CollectionType type) |
40 : HTMLCollection(node, type, DoesNotOverrideItemAfter) | 40 : HTMLCollection(node, type, DoesNotOverrideItemAfter) |
41 { | 41 { |
42 ScriptWrappable::init(this); | 42 ScriptWrappable::init(this); |
43 } | 43 } |
44 | 44 |
45 HTMLAllCollection::~HTMLAllCollection() | 45 HTMLAllCollection::~HTMLAllCollection() |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigne
d index) const | 49 Element* HTMLAllCollection::namedItemWithIndex(const AtomicString& name, unsigne
d index) const |
50 { | 50 { |
51 updateIdNameCache(); | 51 updateIdNameCache(); |
52 | 52 |
53 const NamedItemCache& cache = namedItemCache(); | 53 const NamedItemCache& cache = namedItemCache(); |
54 if (Vector<Element*>* elements = cache.getElementsById(name)) { | 54 if (WillBeHeapVector<RawPtrWillBeMember<Element> >* elements = cache.getElem
entsById(name)) { |
55 if (index < elements->size()) | 55 if (index < elements->size()) |
56 return elements->at(index); | 56 return elements->at(index); |
57 index -= elements->size(); | 57 index -= elements->size(); |
58 } | 58 } |
59 | 59 |
60 if (Vector<Element*>* elements = cache.getElementsByName(name)) { | 60 if (WillBeHeapVector<RawPtrWillBeMember<Element> >* elements = cache.getElem
entsByName(name)) { |
61 if (index < elements->size()) | 61 if (index < elements->size()) |
62 return elements->at(index); | 62 return elements->at(index); |
63 } | 63 } |
64 | 64 |
65 return 0; | 65 return 0; |
66 } | 66 } |
67 | 67 |
68 void HTMLAllCollection::namedGetter(const AtomicString& name, bool& returnValue0
Enabled, RefPtr<NodeList>& returnValue0, bool& returnValue1Enabled, RefPtr<Eleme
nt>& returnValue1) | 68 void HTMLAllCollection::namedGetter(const AtomicString& name, bool& returnValue0
Enabled, RefPtrWillBeRawPtr<NodeList>& returnValue0, bool& returnValue1Enabled,
RefPtr<Element>& returnValue1) |
69 { | 69 { |
70 Vector<RefPtr<Element> > namedItems; | 70 WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems; |
71 this->namedItems(name, namedItems); | 71 this->namedItems(name, namedItems); |
72 | 72 |
73 if (!namedItems.size()) | 73 if (!namedItems.size()) |
74 return; | 74 return; |
75 | 75 |
76 if (namedItems.size() == 1) { | 76 if (namedItems.size() == 1) { |
77 returnValue1Enabled = true; | 77 returnValue1Enabled = true; |
78 returnValue1 = namedItems.at(0); | 78 // FIXME: Oilpan: remove the call to |get| when Element becomes [Garbage
Collected]. |
| 79 returnValue1 = namedItems.at(0).get(); |
79 return; | 80 return; |
80 } | 81 } |
81 | 82 |
82 // FIXME: HTML5 specification says this should be a HTMLCollection. | 83 // FIXME: HTML5 specification says this should be a HTMLCollection. |
83 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlallcollection | 84 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in
terfaces.html#htmlallcollection |
84 returnValue0Enabled = true; | 85 returnValue0Enabled = true; |
85 returnValue0 = NamedNodesCollection::create(namedItems); | 86 returnValue0 = NamedNodesCollection::create(namedItems); |
86 } | 87 } |
87 | 88 |
88 } // namespace WebCore | 89 } // namespace WebCore |
OLD | NEW |