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

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: Use LinkedHashSet for ElementSet instead. 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..262fd682a2a1dcd18e60da936c4534fe228e12b2 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);
haraken 2014/05/26 15:40:23 Just help me understand: As far as I see the code,
sof 2014/05/26 16:41:08 The weakly held Elements keep the CustomElementObs
haraken 2014/05/27 01:08:45 Correct me if I'm wrong:
sof 2014/05/27 05:29:51 It is triggered by the call to wasDestroyed() in ~
haraken 2014/05/27 05:47:30 Sorry, I was misreading the call path to CustomEle
sof 2014/05/27 11:59:14 That matches my understanding also. I've been comp
+#endif
}
void CustomElementUpgradeCandidateMap::add(const CustomElementDescriptor& descriptor, Element* element)
@@ -52,9 +61,9 @@ 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;
else
- elements = &it->value;
+ elements = it->value;
elements->add(element);
}
@@ -77,7 +86,7 @@ void CustomElementUpgradeCandidateMap::removeCommon(Element* element)
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);
haraken 2014/05/26 15:40:23 Can this be candidate->remove() ? We won't want to
sof 2014/05/26 16:41:08 Can't be - this is removing it from another table.
}
@@ -95,19 +104,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)
+const CustomElementUpgradeCandidateMap::ElementSet* CustomElementUpgradeCandidateMap::takeUpgradeCandidatesFor(const CustomElementDescriptor& descriptor)
{
- const ListHashSet<Element*>& candidates = m_unresolvedDefinitions.take(descriptor);
+ const ElementSet* candidates = m_unresolvedDefinitions.take(descriptor);
+
+ if (!candidates)
+ return 0;
haraken 2014/05/26 15:40:23 Can this happen? If no, we might want to keep Elem
sof 2014/05/26 15:46:18 It will happen if you call registerElement() befor
haraken 2014/05/27 01:08:45 Just help me understand: Before this CL, we were u
sof 2014/05/27 11:59:14 hashSet.take()'s return type is HashTraits<ValueTy
- for (ElementSet::const_iterator candidate = candidates.begin(); candidate != candidates.end(); ++candidate) {
+ for (ElementSet::const_iterator candidate = candidates->begin(); candidate != candidates->end(); ++candidate) {
unobserve(*candidate);
m_upgradeCandidates.remove(*candidate);
}
-
return candidates;
}
+void CustomElementUpgradeCandidateMap::trace(Visitor* visitor)
+{
+ visitor->trace(m_upgradeCandidates);
+ visitor->trace(m_unresolvedDefinitions);
+ CustomElementObserver::trace(visitor);
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698