Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: Source/core/html/HTMLAllCollection.cpp

Issue 280123002: Oilpan: move LiveNodeList collections to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase needed Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 #if ENABLE(OILPAN)
79 // FIXME: Oilpan: remove once Element becomes [GarbageCollected].
80 returnValue1 = PassRefPtr<Element>(namedItems.at(0).get());
Mads Ager (chromium) 2014/05/15 10:54:24 Does the following work in both builds? // FIXME:
sof 2014/05/15 22:15:57 It works to drop down to a bare pointer, the FIXME
81 #else
78 returnValue1 = namedItems.at(0); 82 returnValue1 = namedItems.at(0);
83 #endif
79 return; 84 return;
80 } 85 }
81 86
82 // FIXME: HTML5 specification says this should be a HTMLCollection. 87 // 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 88 // http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-in terfaces.html#htmlallcollection
84 returnValue0Enabled = true; 89 returnValue0Enabled = true;
85 returnValue0 = NamedNodesCollection::create(namedItems); 90 returnValue0 = NamedNodesCollection::create(namedItems);
86 } 91 }
87 92
88 } // namespace WebCore 93 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698