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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp
diff --git a/Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp b/Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp
index ccbbed39b8fba00d16423aee900933929ea26b33..998a6d5823b2a5fe07022e36d8516cf899ae385a 100644
--- a/Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp
+++ b/Source/core/dom/custom/CustomElementUpgradeCandidateMap.cpp
@@ -35,11 +35,20 @@
namespace WebCore {
+PassOwnPtrWillBeRawPtr<CustomElementUpgradeCandidateMap> CustomElementUpgradeCandidateMap::create()
+{
+ return adoptPtrWillBeNoop(new CustomElementUpgradeCandidateMap());
+}
+
CustomElementUpgradeCandidateMap::~CustomElementUpgradeCandidateMap()
{
+#if !ENABLE(OILPAN)
+ // With Oilpan enabled, the observer table keeps a weak reference to the
+ // element; no need for explicit removal.
UpgradeCandidateMap::const_iterator::Keys end = m_upgradeCandidates.end().keys();
for (UpgradeCandidateMap::const_iterator::Keys it = m_upgradeCandidates.begin().keys(); it != end; ++it)
unobserve(*it);
+#endif
}
void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descriptor, Element* element)
@@ -52,32 +61,21 @@ void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descri
UnresolvedDefinitionMap::iterator it = m_unresolvedDefinitions.find(descriptor);
ElementSet* elements;
if (it == m_unresolvedDefinitions.end())
- elements = &m_unresolvedDefinitions.add(descriptor, ElementSet()).storedValue->value;
+ elements = m_unresolvedDefinitions.add(descriptor, adoptPtrWillBeNoop(new ElementSet())).storedValue->value.get();
else
- elements = &it->value;
+ elements = it->value.get();
elements->add(element);
}
-void CustomElementUpgradeCandidateMap::remove(Element* element)
-{
- unobserve(element);
- removeCommon(element);
-}
-
void CustomElementUpgradeCandidateMap::elementWasDestroyed(Element* element)
{
CustomElementObserver::elementWasDestroyed(element);
- removeCommon(element);
-}
-
-void CustomElementUpgradeCandidateMap::removeCommon(Element* element)
-{
UpgradeCandidateMap::iterator candidate = m_upgradeCandidates.find(element);
ASSERT_WITH_SECURITY_IMPLICATION(candidate != m_upgradeCandidates.end());
UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(candidate->value);
ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
- elements->value.remove(element);
+ elements->value->remove(element);
m_upgradeCandidates.remove(candidate);
}
@@ -95,19 +93,28 @@ void CustomElementUpgradeCandidateMap::moveToEnd(Element* element)
UnresolvedDefinitionMap::iterator elements = m_unresolvedDefinitions.find(candidate->value);
ASSERT_WITH_SECURITY_IMPLICATION(elements != m_unresolvedDefinitions.end());
- elements->value.appendOrMoveToLast(element);
+ elements->value->appendOrMoveToLast(element);
}
-ListHashSet<Element*> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& descriptor)
+PassOwnPtrWillBeRawPtr<CustomElementUpgradeCandidateMap::ElementSet> CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& descriptor)
{
- const ListHashSet<Element*>& candidates = m_unresolvedDefinitions.take(descriptor);
+ OwnPtrWillBeRawPtr<ElementSet> candidates = m_unresolvedDefinitions.take(descriptor);
- for (ElementSet::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate) {
+ if (!candidates)
+ return nullptr;
+
+ for (ElementSet::const_iterator candidate = candidates->begin(); candidate != candidates->end(); ++candidate) {
unobserve(*candidate);
m_upgradeCandidates.remove(*candidate);
}
+ return candidates.release();
+}
- return candidates;
+void CustomElementUpgradeCandidateMap::trace(Visitor* visitor)
+{
+ visitor->trace(m_upgradeCandidates);
+ visitor->trace(m_unresolvedDefinitions);
+ CustomElementObserver::trace(visitor);
}
}
« 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