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

Side by Side Diff: Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp

Issue 296703009: Oilpan: move custom element objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix compilation issue pointed out by clang Created 6 years, 6 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/dom/custom/CustomElementUpgradeCandidateMap.h" 32 #include "core/dom/custom/CustomElementUpgradeCandidateMap.h"
33 33
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 PassOwnPtrWillBeRawPtr<CustomElementUpgradeCandidateMap> CustomElementUpgradeCan didateMap::create()
39 {
40 return adoptPtrWillBeNoop(new CustomElementUpgradeCandidateMap());
41 }
42
38 CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap() 43 CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap()
39 { 44 {
45 #if !ENABLE(OILPAN)
46 // With Oilpan enabled, the observer table keeps a weak reference to the
47 // element; no need for explicit removal.
40 UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().ke ys(); 48 UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().ke ys();
41 for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begi n().keys(); it != end; ++it) 49 for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begi n().keys(); it != end; ++it)
42 unobserve(*it); 50 unobserve(*it);
51 #endif
43 } 52 }
44 53
45 void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri ptor, Element* element) 54 void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri ptor, Element* element)
46 { 55 {
47 observe(element); 56 observe(element);
48 57
49 UpgradeCandidateMap::AddResult result = m_upgradeCandidates.add(element, des criptor); 58 UpgradeCandidateMap::AddResult result = m_upgradeCandidates.add(element, des criptor);
50 ASSERT_UNUSED(result, result.isNewEntry); 59 ASSERT_UNUSED(result, result.isNewEntry);
51 60
52 UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descript or); 61 UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descript or);
53 ElementSet* elements; 62 ElementSet* elements;
54 if (it == m_unresolvedDefinitions.end()) 63 if (it == m_unresolvedDefinitions.end())
55 elements = &m_unresolvedDefinitions.add(descriptor, ElementSet()).stored Value->value; 64 elements = m_unresolvedDefinitions.add(descriptor, adoptPtrWillBeNoop(ne w ElementSet())).storedValue->value.get();
56 else 65 else
57 elements = &it->value; 66 elements = it->value.get();
58 elements->add(element); 67 elements->add(element);
59 } 68 }
60 69
61 void CustomElementUpgradeCandidateMap::remove(Element* element)
62 {
63 unobserve(element);
64 removeCommon(element);
65 }
66
67 void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element) 70 void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element)
68 { 71 {
69 CustomElementObserver::elementWasDestroyed(element); 72 CustomElementObserver::elementWasDestroyed(element);
70 removeCommon(element);
71 }
72
73 void CustomElementUpgradeCandidateMap::removeCommon(Element* element)
74 {
75 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element); 73 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
76 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end()); 74 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end());
77 75
78 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value); 76 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value);
79 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end()); 77 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
80 elements->value.remove(element); 78 elements->value->remove(element);
81 m_upgradeCandidates.remove(candidate); 79 m_upgradeCandidates.remove(candidate);
82 } 80 }
83 81
84 void CustomElementUpgradeCandidateMap::elementDidFinishParsingChildren(Element* element) 82 void CustomElementUpgradeCandidateMap::elementDidFinishParsingChildren(Element* element)
85 { 83 {
86 // An upgrade candidate finished parsing; reorder so that eventual 84 // An upgrade candidate finished parsing; reorder so that eventual
87 // upgrade order matches finished-parsing order. 85 // upgrade order matches finished-parsing order.
88 moveToEnd(element); 86 moveToEnd(element);
89 } 87 }
90 88
91 void CustomElementUpgradeCandidateMap::moveToEnd(Element* element) 89 void CustomElementUpgradeCandidateMap::moveToEnd(Element* element)
92 { 90 {
93 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element); 91 UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
94 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end()); 92 ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end());
95 93
96 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value); 94 UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(ca ndidate->value);
97 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end()); 95 ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
98 elements->value.appendOrMoveToLast(element); 96 elements->value->appendOrMoveToLast(element);
99 } 97 }
100 98
101 ListHashSet<Element*> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor (const CustomElementDescriptor& descriptor) 99 PassOwnPtrWillBeRawPtr<CustomElementUpgradeCandidateMap::ElementSet> CustomEleme ntUpgradeCandidateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& d escriptor)
102 { 100 {
103 const ListHashSet<Element*>& candidates = m_unresolvedDefinitions.take(descr iptor); 101 OwnPtrWillBeRawPtr<ElementSet> candidates = m_unresolvedDefinitions.take(des criptor);
104 102
105 for (ElementSet::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate) { 103 if (!candidates)
104 return nullptr;
105
106 for (ElementSet::const_iterator candidate = candidates->begin(); candidate ! = candidates->end(); ++candidate) {
106 unobserve(*candidate); 107 unobserve(*candidate);
107 m_upgradeCandidates.remove(*candidate); 108 m_upgradeCandidates.remove(*candidate);
108 } 109 }
110 return candidates.release();
111 }
109 112
110 return candidates; 113 void CustomElementUpgradeCandidateMap::trace(Visitor* visitor)
114 {
115 visitor->trace(m_upgradeCandidates);
116 visitor->trace(m_unresolvedDefinitions);
117 CustomElementObserver::trace(visitor);
111 } 118 }
112 119
113 } 120 }
OLDNEW
« no previous file with comments | « Source/core/dom/custom/CustomElementUpgradeCandidateMap.h ('k') | Source/core/html/imports/HTMLImportLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698