Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index fd41385f5e66706985d6ce3cd400cdd814fe8de0..8e5019fcaedeed564bda148645fe68080dd8a23d 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -328,10 +328,15 @@ void Node::clearRareData() |
ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegistry()->isEmpty()); |
RenderObject* renderer = m_data.m_rareData->renderer(); |
- if (isElementNode()) |
- delete static_cast<ElementRareData*>(m_data.m_rareData); |
- else |
- delete static_cast<NodeRareData*>(m_data.m_rareData); |
+ if (isElementNode()) { |
+ ElementRareData* rareData = static_cast<ElementRareData*>(m_data.m_rareData); |
+ rareData->dispose(); |
+ delete rareData; |
+ } else { |
+ NodeRareData* rareData = static_cast<NodeRareData*>(m_data.m_rareData); |
+ rareData->dispose(); |
+ delete rareData; |
+ } |
m_data.m_renderer = renderer; |
clearFlag(HasRareDataFlag); |
} |
@@ -1942,14 +1947,14 @@ void Node::didMoveToNewDocument(Document& oldDocument) |
} |
} |
- if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRegistry()) { |
+ if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registry = mutationObserverRegistry()) { |
for (size_t i = 0; i < registry->size(); ++i) { |
document().addMutationObserverTypes(registry->at(i)->mutationTypes()); |
} |
} |
- if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMutationObserverRegistry()) { |
- for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) { |
+ if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* transientRegistry = transientMutationObserverRegistry()) { |
+ for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) { |
document().addMutationObserverTypes((*iter)->mutationTypes()); |
} |
} |
@@ -2039,7 +2044,7 @@ void Node::clearEventTargetData() |
eventTargetDataMap().remove(this); |
} |
-Vector<OwnPtr<MutationObserverRegistration> >* Node::mutationObserverRegistry() |
+WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* Node::mutationObserverRegistry() |
{ |
if (!hasRareData()) |
return 0; |
@@ -2049,7 +2054,7 @@ Vector<OwnPtr<MutationObserverRegistration> >* Node::mutationObserverRegistry() |
return &data->registry; |
} |
-HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry() |
+WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* Node::transientMutationObserverRegistry() |
{ |
if (!hasRareData()) |
return 0; |
@@ -2060,7 +2065,7 @@ HashSet<MutationObserverRegistration*>* Node::transientMutationObserverRegistry( |
} |
template<typename Registry> |
-static inline void collectMatchingObserversForMutation(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, Registry* registry, Node& target, MutationObserver::MutationType type, const QualifiedName* attributeName) |
+static inline void collectMatchingObserversForMutation(WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordDeliveryOptions>& observers, Registry* registry, Node& target, MutationObserver::MutationType type, const QualifiedName* attributeName) |
{ |
if (!registry) |
return; |
@@ -2068,14 +2073,14 @@ static inline void collectMatchingObserversForMutation(HashMap<MutationObserver* |
const MutationObserverRegistration& registration = **iter; |
if (registration.shouldReceiveMutationFrom(target, type, attributeName)) { |
MutationRecordDeliveryOptions deliveryOptions = registration.deliveryOptions(); |
- HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(®istration.observer(), deliveryOptions); |
+ WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordDeliveryOptions>::AddResult result = observers.add(®istration.observer(), deliveryOptions); |
if (!result.isNewEntry) |
result.storedValue->value |= deliveryOptions; |
} |
} |
} |
-void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const QualifiedName* attributeName) |
+void Node::getRegisteredMutationObserversOfType(WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, MutationRecordDeliveryOptions>& observers, MutationObserver::MutationType type, const QualifiedName* attributeName) |
{ |
ASSERT((type == MutationObserver::Attributes && attributeName) || !attributeName); |
collectMatchingObserversForMutation(observers, mutationObserverRegistry(), *this, type, attributeName); |
@@ -2089,7 +2094,7 @@ void Node::getRegisteredMutationObserversOfType(HashMap<MutationObserver*, Mutat |
void Node::registerMutationObserver(MutationObserver& observer, MutationObserverOptions options, const HashSet<AtomicString>& attributeFilter) |
{ |
MutationObserverRegistration* registration = 0; |
- Vector<OwnPtr<MutationObserverRegistration> >& registry = ensureRareData().ensureMutationObserverData().registry; |
+ WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >& registry = ensureRareData().ensureMutationObserverData().registry; |
for (size_t i = 0; i < registry.size(); ++i) { |
if (®istry[i]->observer() == &observer) { |
registration = registry[i].get(); |
@@ -2107,7 +2112,7 @@ void Node::registerMutationObserver(MutationObserver& observer, MutationObserver |
void Node::unregisterMutationObserver(MutationObserverRegistration* registration) |
{ |
- Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRegistry(); |
+ WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registry = mutationObserverRegistry(); |
ASSERT(registry); |
if (!registry) |
return; |
@@ -2121,6 +2126,10 @@ void Node::unregisterMutationObserver(MutationObserverRegistration* registration |
// before that, in case |this| is destroyed (see MutationObserverRegistration::m_registrationNodeKeepAlive). |
// FIXME: Simplify the registration/transient registration logic to make this understandable by humans. |
RefPtr<Node> protect(this); |
+#if ENABLE(OILPAN) |
haraken
2014/04/21 06:00:34
So I think it would be nice if we could drop the #
sof
2014/04/21 12:45:16
Done + adjusted the comment.
|
+ // Promptly dispose of the MutationObserverRegistration object. |
+ registration->dispose(); |
+#endif |
registry->remove(index); |
} |
@@ -2131,7 +2140,7 @@ void Node::registerTransientMutationObserver(MutationObserverRegistration* regis |
void Node::unregisterTransientMutationObserver(MutationObserverRegistration* registration) |
{ |
- HashSet<MutationObserverRegistration*>* transientRegistry = transientMutationObserverRegistry(); |
+ WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* transientRegistry = transientMutationObserverRegistry(); |
ASSERT(transientRegistry); |
if (!transientRegistry) |
return; |
@@ -2146,14 +2155,14 @@ void Node::notifyMutationObserversNodeWillDetach() |
return; |
for (Node* node = parentNode(); node; node = node->parentNode()) { |
- if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->mutationObserverRegistry()) { |
+ if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registry = node->mutationObserverRegistry()) { |
const size_t size = registry->size(); |
for (size_t i = 0; i < size; ++i) |
registry->at(i)->observedSubtreeNodeWillDetach(*this); |
} |
- if (HashSet<MutationObserverRegistration*>* transientRegistry = node->transientMutationObserverRegistry()) { |
- for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) |
+ if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* transientRegistry = node->transientMutationObserverRegistry()) { |
+ for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) |
(*iter)->observedSubtreeNodeWillDetach(*this); |
} |
} |